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:44

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

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:91


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:213


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:229


isZero

isZero(): Bool

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

Returns

Bool

Defined in

lib/group.ts:78


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:177


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:191


sub

sub(g): Group

Subtracts another Group element from this one.

Parameters

NameType
gGroup

Returns

Group

Defined in

lib/group.ts:170


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:256


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:241


add

Static add(g1, g2): Group

Parameters

NameType
g1Group
g2Group

Returns

Group

Deprecated

Please use the method .add on the instance instead

Adds a Group element to another one.

Defined in

lib/group.ts:275


assertEqual

Static assertEqual(g1, g2): void

Parameters

NameType
g1Group
g2Group

Returns

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);

Defined in

lib/group.ts:325


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:406


equal

Static equal(g1, g2): Bool

Parameters

NameType
g1Group
g2Group

Returns

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)

Defined in

lib/group.ts:339


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:263


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:366


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:393


neg

Static neg(g): Group

Parameters

NameType
gGroup

Returns

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);

Defined in

lib/group.ts:297


scale

Static scale(g, s): Group

Parameters

NameType
gGroup
sScalar

Returns

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);

Defined in

lib/group.ts:311


sizeInFields

Static sizeInFields(): number

Part of the Provable interface.

Returns 2.

Returns

number

Defined in

lib/group.ts:375


sub

Static sub(g1, g2): Group

Parameters

NameType
g1Group
g2Group

Returns

Group

Deprecated

Please use the method .sub on the instance instead

Subtracts a Group element from another one.

Defined in

lib/group.ts:284


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:357


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:348


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:384