Skip to main content

Group

An element of a Group.

Constructors

new Group(__namedParameters)

new Group(__namedParameters: {
x: | string
| number
| bigint
| FieldVar
| Field;
y: | string
| number
| bigint
| FieldVar
| Field;
}): Group

Coerces anything group-like to a Group.

Parameters

__namedParameters

__namedParameters.x: | string | number | bigint | FieldVar | Field

__namedParameters.y: | string | number | bigint | FieldVar | Field

Returns

Group

Source

lib/provable/group.ts:50

Properties

x

x: Field;

Source

lib/provable/group.ts:21


y

y: Field;

Source

lib/provable/group.ts:22

Accessors

generator

get static generator(): Group

The generator g of the Group.

Returns

Group

Source

lib/provable/group.ts:27


zero

get static zero(): Group

Unique representation of the zero element of the Group (the identity element of addition in this Group).

Note: The zero element is represented as (0, 0).

// g + -g = 0
g.add(g.neg()).assertEquals(zero);
// g + 0 = g
g.add(zero).assertEquals(g);

Returns

Group

Source

lib/provable/group.ts:43

Methods

add()

add(g: Group): Group

Adds this Group element to another Group element.

let g1 = Group({ x: -1, y: 2})
let g2 = g1.add(g1)

Parameters

g: Group

Returns

Group

Source

lib/provable/group.ts:97


addNonZero()

addNonZero(g2: Group, allowZeroOutput: boolean): Group

Lower-level variant of add which doesn't handle the case where one of the operands is zero, and asserts that the output is non-zero.

Optionally, zero outputs can be allowed by setting allowZeroOutput to true.

Warning: If one of the inputs is zero, the result will be garbage and the proof useless. This case has to be prevented or handled separately by the caller of this method.

Parameters

g2: Group

allowZeroOutput: boolean= false

Returns

Group

Source

lib/provable/group.ts:136


assertEquals()

assertEquals(g: Group, message?: string): void

Assert that this Group element equals another Group element. Throws an error if the assertion fails.

g1.assertEquals(g2);

Parameters

g: Group

message?: string

Returns

void

Source

lib/provable/group.ts:200


equals()

equals(g: Group): Bool

Check if this Group element equals another Group element. Returns a Bool.

g1.equals(g1); // Bool(true)

Parameters

g: Group

Returns

Bool

Source

lib/provable/group.ts:216


isZero()

isZero(): Bool

Checks if this element is the zero element {x: 0, y: 0}.

Returns

Bool

Source

lib/provable/group.ts:84


neg()

neg(): Group

Negates this Group. Under the hood, it simply negates the y coordinate and leaves the x coordinate as is.

Returns

Group

Source

lib/provable/group.ts:165


scale()

scale(s: number | bigint | Field | Scalar): Group

Elliptic curve scalar multiplication. Scales the Group element n-times by itself, where n is the Scalar.

let s = Scalar(5);
let 5g = g.scale(s);

Parameters

s: number | bigint | Field | Scalar

Returns

Group

Source

lib/provable/group.ts:179


sub()

sub(g: Group): Group

Subtracts another Group element from this one.

Parameters

g: Group

Returns

Group

Source

lib/provable/group.ts:158


toFields()

toFields(): Field[]

Part of the Provable interface.

Returns an array containing this Group element as an array of Field elements.

Returns

Field[]

Source

lib/provable/group.ts:253


toJSON()

toJSON(): {
x: string;
y: string;
}

Serializes this Group element to a JSON object.

This operation does NOT affect the circuit and can't be used to prove anything about the representation of the element.

Returns

{
x: string;
y: string;
}
x
x: string;
y
y: string;

Source

lib/provable/group.ts:238


check()

static check(g: Group): unknown

Checks that a Group element is constraint properly by checking that the element is on the curve.

Parameters

g: Group

Returns

unknown

Source

lib/provable/group.ts:330


from()

static from(x: 
| string
| number
| bigint
| FieldVar
| Field, y:
| string
| number
| bigint
| FieldVar
| Field): Group

Coerces two x and y coordinates into a Group element.

Parameters

x: | string | number | bigint | FieldVar | Field

y: | string | number | bigint | FieldVar | Field

Returns

Group

Source

lib/provable/group.ts:260


fromFields()

static fromFields(__namedParameters: Field[]): Group

Part of the Provable interface.

Deserializes a Group element from a list of field elements.

Parameters

__namedParameters: Field[]

Returns

Group

Source

lib/provable/group.ts:290


fromJSON()

static fromJSON(__namedParameters: {
x: | string
| number
| bigint
| FieldVar
| Field;
y: | string
| number
| bigint
| FieldVar
| Field;
}): Group

Deserializes a JSON-like structure to a Group element.

This operation does NOT affect the circuit and can't be used to prove anything about the representation of the element.

Parameters

__namedParameters

__namedParameters.x: | string | number | bigint | FieldVar | Field

__namedParameters.y: | string | number | bigint | FieldVar | Field

Returns

Group

Source

lib/provable/group.ts:317


fromValue()

static fromValue(g: Group | {
x: number | bigint | Field;
y: number | bigint | Field;
}): Group

Parameters

g: Group | { x: number | bigint | Field; y: number | bigint | Field; }

Returns

Group

Source

lib/provable/group.ts:227


sizeInFields()

static sizeInFields(): number

Part of the Provable interface.

Returns 2.

Returns

number

Source

lib/provable/group.ts:299


toAuxiliary()

static toAuxiliary(g?: Group): never[]

Part of the Provable interface.

Returns an empty array.

Parameters

g?: Group

Returns

never[]

Source

lib/provable/group.ts:281


toFields()

static toFields(g: Group): Field[]

Part of the Provable interface.

Returns an array containing a Group element as an array of Field elements.

Parameters

g: Group

Returns

Field[]

Source

lib/provable/group.ts:272


toInput()

static toInput(x: Group): {
fields: Field[];
}

Parameters

x: Group

Returns

{
fields: Field[];
}
fields
fields: Field[];

Source

lib/provable/group.ts:350


toJSON()

static toJSON(g: Group): {
x: string;
y: string;
}

Serializes a Group element to a JSON object.

This operation does NOT affect the circuit and can't be used to prove anything about the representation of the element.

Parameters

g: Group

Returns

{
x: string;
y: string;
}
x
x: string;
y
y: string;

Source

lib/provable/group.ts:308


toValue()

static toValue(__namedParameters: Group): {
x: bigint;
y: bigint;
}

Parameters

__namedParameters: Group

Returns

{
x: bigint;
y: bigint;
}
x
x: bigint;
y
y: bigint;

Source

lib/provable/group.ts:223