Group
Class: Group
An element of a Group.
Table of contents
Constructors
Properties
Accessors
Methods
- add
- assertEquals
- equals
- isZero
- neg
- scale
- sub
- toFields
- toJSON
- add
- assertEqual
- check
- equal
- from
- fromFields
- fromJSON
- neg
- scale
- sizeInFields
- sub
- toAuxiliary
- toFields
- toJSON
Constructors
constructor
• new Group(«destructured»
)
Coerces anything group-like to a Group.
Parameters
Name | Type |
---|---|
«destructured» | Object |
› x | string | number | bigint | FieldVar | Field |
› y | string | number | bigint | FieldVar | Field |
Defined in
Properties
x
• x: Field
Defined in
y
• y: Field
Defined in
Accessors
generator
• Static
get
generator(): Group
The generator g
of the Group.
Returns
Defined in
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
Defined in
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
Name | Type |
---|---|
g | Group |
Returns
Defined in
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
Name | Type |
---|---|
g | Group |
message? | string |
Returns
void
Defined in
equals
▸ equals(g
): Bool
Check if this Group element equals another Group element. Returns a Bool.
g1.equals(g1); // Bool(true)
Parameters
Name | Type |
---|---|
g | Group |
Returns
Defined in
isZero
▸ isZero(): Bool
Checks if this element is the zero
element {x: 0, y: 0}
.
Returns
Defined in
neg
▸ neg(): Group
Negates this Group. Under the hood, it simply negates the y
coordinate and leaves the x
coordinate as is.
Returns
Defined in
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
Name | Type |
---|---|
s | number | bigint | Scalar |
Returns
Defined in
sub
▸ sub(g
): Group
Subtracts another Group element from this one.
Parameters
Name | Type |
---|---|
g | Group |
Returns
Defined in
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
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
Name | Type |
---|---|
x | string |
y | string |
Defined in
add
▸ Static
add(g1
, g2
): Group
Parameters
Name | Type |
---|---|
g1 | Group |
g2 | Group |
Returns
Deprecated
Please use the method .add
on the instance instead
Adds a Group element to another one.
Defined in
assertEqual
▸ Static
assertEqual(g1
, g2
): void
Parameters
Name | Type |
---|---|
g1 | Group |
g2 | Group |
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
check
▸ Static
check(g
): unknown
Checks that a Group element is constraint properly by checking that the element is on the curve.
Parameters
Name | Type |
---|---|
g | Group |
Returns
unknown
Defined in
equal
▸ Static
equal(g1
, g2
): Bool
Parameters
Name | Type |
---|---|
g1 | Group |
g2 | Group |
Returns
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
from
▸ Static
from(x
, y
): Group
Coerces two x and y coordinates into a Group element.
Parameters
Name | Type |
---|---|
x | string | number | bigint | FieldVar | Field |
y | string | number | bigint | FieldVar | Field |
Returns
Defined in
fromFields
▸ Static
fromFields(«destructured»
): Group
Part of the Provable interface.
Deserializes a Group element from a list of field elements.
Parameters
Name | Type |
---|---|
«destructured» | Field [] |
Returns
Defined in
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
Name | Type |
---|---|
«destructured» | Object |
› x | string | number | bigint | FieldVar | Field |
› y | string | number | bigint | FieldVar | Field |
Returns
Defined in
neg
▸ Static
neg(g
): Group
Parameters
Name | Type |
---|---|
g | Group |
Returns
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
scale
▸ Static
scale(g
, s
): Group
Parameters
Name | Type |
---|---|
g | Group |
s | Scalar |
Returns
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
sizeInFields
▸ Static
sizeInFields(): number
Part of the Provable interface.
Returns 2.
Returns
number
Defined in
sub
▸ Static
sub(g1
, g2
): Group
Parameters
Name | Type |
---|---|
g1 | Group |
g2 | Group |
Returns
Deprecated
Please use the method .sub
on the instance instead
Subtracts a Group element from another one.
Defined in
toAuxiliary
▸ Static
toAuxiliary(g?
): never
[]
Part of the Provable interface.
Returns an empty array.
Parameters
Name | Type |
---|---|
g? | Group |
Returns
never
[]
Defined in
toFields
▸ Static
toFields(g
): Field
[]
Part of the Provable interface.
Returns an array containing a Group element as an array of Field elements.
Parameters
Name | Type |
---|---|
g | Group |
Returns
Field
[]
Defined in
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
Name | Type |
---|---|
g | Group |
Returns
Object
Name | Type |
---|---|
x | string |
y | string |