Skip to main content

Group

o1js / Modules / Group

Class: Group

An element of a Group.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Group(«destructured»)

Coerces anything group-like to a Group.

Parameters

NameType
«destructured»Object
› xstring | number | bigint | FieldVar | Field
› ystring | number | bigint | FieldVar | Field

Defined in

lib/group.ts:47

Properties

x

x: Field

Defined in

lib/group.ts:15


y

y: Field

Defined in

lib/group.ts:16

Accessors

generator

Static get generator(): Group

The generator g of the Group.

Returns

Group

Defined in

lib/group.ts:21


zero

Static get 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

Defined in

lib/group.ts:37

Methods

#isConstant

Private #isConstant(): boolean

Returns

boolean

Defined in

lib/group.ts:99


#toProjective

Private #toProjective(): Object

Returns

Object

NameType
xbigint
ybigint
zbigint

Defined in

lib/group.ts:103


#toTuple

Private #toTuple(): [0, FieldVar, FieldVar]

Returns

[0, FieldVar, FieldVar]

Defined in

lib/group.ts:95


add

add(g): Group

Adds this Group element to another Group element.

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

Parameters

NameType
gGroup

Returns

Group

Defined in

lib/group.ts:127


assertEquals

assertEquals(g, message?): void

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

g1.assertEquals(g2);

Parameters

NameType
gGroup
message?string

Returns

void

Defined in

lib/group.ts:261


equals

equals(g): Bool

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

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

Parameters

NameType
gGroup

Returns

Bool

Defined in

lib/group.ts:277


isZero

isZero(): Bool

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

Returns

Bool

Defined in

lib/group.ts:114


neg

neg(): Group

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

Returns

Group

Defined in

lib/group.ts:225


scale

scale(s): 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

NameType
snumber | bigint | Scalar

Returns

Group

Defined in

lib/group.ts:239


sub

sub(g): Group

Subtracts another Group element from this one.

Parameters

NameType
gGroup

Returns

Group

Defined in

lib/group.ts:218


toFields

toFields(): Field[]

Part of the Provable interface.

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

Returns

Field[]

Defined in

lib/group.ts:304


toJSON

toJSON(): Object

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

Object

NameType
xstring
ystring

Defined in

lib/group.ts:289


#fromAffine

Static Private #fromAffine(«destructured»): Group

Parameters

NameType
«destructured»Object
› infinityboolean
› xbigint
› ybigint

Returns

Group

Defined in

lib/group.ts:79


#fromProjective

Static Private #fromProjective(«destructured»): Group

Parameters

NameType
«destructured»Object
› xbigint
› ybigint
› zbigint

Returns

Group

Defined in

lib/group.ts:91


add

Static add(g1, g2): Group

Deprecated

Please use the method .add on the instance instead

Adds a Group element to another one.

Parameters

NameType
g1Group
g2Group

Returns

Group

Defined in

lib/group.ts:323


assertEqual

Static assertEqual(g1, g2): void

Deprecated

Please use the method .assertEqual on the instance instead.

Assert that two Group elements are equal to another. Throws an error if the assertion fails.

Group.assertEquals(g1, g2);

Parameters

NameType
g1Group
g2Group

Returns

void

Defined in

lib/group.ts:373


check

Static check(g): unknown

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

Parameters

NameType
gGroup

Returns

unknown

Defined in

lib/group.ts:454


equal

Static equal(g1, g2): Bool

Deprecated

Please use the method .equals on the instance instead.

Checks if a Group element is equal to another Group element. Returns a Bool.

Group.equal(g1, g2); // Bool(true)

Parameters

NameType
g1Group
g2Group

Returns

Bool

Defined in

lib/group.ts:387


from

Static from(x, y): Group

Coerces two x and y coordinates into a Group element.

Parameters

NameType
xstring | number | bigint | FieldVar | Field
ystring | number | bigint | FieldVar | Field

Returns

Group

Defined in

lib/group.ts:311


fromFields

Static fromFields(«destructured»): Group

Part of the Provable interface.

Deserializes a Group element from a list of field elements.

Parameters

NameType
«destructured»Field[]

Returns

Group

Defined in

lib/group.ts:414


fromJSON

Static fromJSON(«destructured»): 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

NameType
«destructured»Object
› xstring | number | bigint | FieldVar | Field
› ystring | number | bigint | FieldVar | Field

Returns

Group

Defined in

lib/group.ts:441


neg

Static neg(g): Group

Deprecated

Please use the method .neg on the instance instead

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

let gNeg = Group.neg(g);

Parameters

NameType
gGroup

Returns

Group

Defined in

lib/group.ts:345


scale

Static scale(g, s): Group

Deprecated

Please use the method .scale on the instance instead

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

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

Parameters

NameType
gGroup
sScalar

Returns

Group

Defined in

lib/group.ts:359


sizeInFields

Static sizeInFields(): number

Part of the Provable interface.

Returns 2.

Returns

number

Defined in

lib/group.ts:423


sub

Static sub(g1, g2): Group

Deprecated

Please use the method .sub on the instance instead

Subtracts a Group element from another one.

Parameters

NameType
g1Group
g2Group

Returns

Group

Defined in

lib/group.ts:332


toAuxiliary

Static toAuxiliary(g?): never[]

Part of the Provable interface.

Returns an empty array.

Parameters

NameType
g?Group

Returns

never[]

Defined in

lib/group.ts:405


toFields

Static toFields(g): Field[]

Part of the Provable interface.

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

Parameters

NameType
gGroup

Returns

Field[]

Defined in

lib/group.ts:396


toJSON

Static toJSON(g): Object

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

NameType
gGroup

Returns

Object

NameType
xstring
ystring

Defined in

lib/group.ts:432