Group
Class: Group
An element of a Group.
Table of contents
Constructors
Properties
Accessors
Methods
- #isConstant
- #toProjective
- #toTuple
- add
- assertEquals
- equals
- neg
- scale
- sub
- toFields
- toJSON
- #fromAffine
- #fromProjective
- 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
Methods
#isConstant
▸ Private
#isConstant(): boolean
Returns
boolean
Defined in
#toProjective
▸ Private
#toProjective(): Object
Returns
Object
Name | Type |
---|---|
x | bigint |
y | bigint |
z | bigint |
Defined in
#toTuple
▸ Private
#toTuple(): [0
, FieldVar
, FieldVar
]
Returns
Defined in
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
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(y
): Group
Subtracts another Group element from this one.
Parameters
Name | Type |
---|---|
y | 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
#fromAffine
▸ Static
Private
#fromAffine(«destructured»
): Group
Parameters
Name | Type |
---|---|
«destructured» | Object |
› infinity | boolean |
› x | bigint |
› y | bigint |
Returns
Defined in
#fromProjective
▸ Static
Private
#fromProjective(«destructured»
): Group
Parameters
Name | Type |
---|---|
«destructured» | Object |
› x | bigint |
› y | bigint |
› z | bigint |
Returns
Defined in
add
▸ Static
add(g1
, g2
): Group
Deprecated
Please use the method .add
on the instance instead
Adds a Group element to another one.
Parameters
Name | Type |
---|---|
g1 | Group |
g2 | Group |
Returns
Defined in
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
Name | Type |
---|---|
g1 | Group |
g2 | Group |
Returns
void
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
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
Name | Type |
---|---|
g1 | Group |
g2 | Group |
Returns
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
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
Name | Type |
---|---|
g | Group |
Returns
Defined in
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
Name | Type |
---|---|
g | Group |
s | Scalar |
Returns
Defined in
sizeInFields
▸ Static
sizeInFields(): number
Part of the Provable interface.
Returns 2.
Returns
number
Defined in
sub
▸ Static
sub(g1
, g2
): Group
Deprecated
Please use the method .sub
on the instance instead
Subtracts a Group element from another one.
Parameters
Name | Type |
---|---|
g1 | Group |
g2 | Group |
Returns
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 |