Zk
pairing-check
Use pairing-check
to perform pairing and final exponentiation on points in points-g1
and points-g2
in the Barreto-Naehrig (BN254) elliptic curve, and check if the result is 1.
Basic syntax
To perform pairing and final exponentiation on points in points-g1
and points-g2
, and check if the result is 1, use the following syntax:
(pairing-check points-g1 points-g2)
(pairing-check points-g1 points-g2)
Arguments
Use the following arguments to specify the lists of points in G1 and G2 for which you want to perform the pairing check using the pairing-check
Pact function.
Argument | Type | Description |
---|---|---|
points-g1 | [any] | Specifies the list of points in G1. |
points-g2 | [any] | Specifies the list of points in G2. |
Return value
The pairing-check
function returns a boolean value indicating whether the result of the pairing and final exponentiation is 1.
Examples
The following example demonstrates how to use the pairing-check
function in the Pact REPL:
pact> (pairing-check [point1_g1 point2_g1] [point1_g2 point2_g2])
pact> (pairing-check [point1_g1 point2_g1] [point1_g2 point2_g2])
point-add
Use point-add
to add two points together that lie on the in the Barreto-Naehrig (BN254) elliptic curve.
The BN254 curve is a pairing-friendly curve tht can be used for verifying on-chain zero knowledge proof schemes such as Groth16 and PlonK.
You can use this function to add point either in Fq or in Fq2.
Basic syntax
To add two points together that lie on the Barreto-Naehrig (BN254) elliptic curve, use the following syntax:
(point-add type point1 point2)
(point-add type point1 point2)
Arguments
Use the following arguments to specify the type of addition and the points to be added using the point-add
Pact function.
Argument | Type | Description |
---|---|---|
type | string | Specifies the type of point addition to perform. The valid values are "g1" and "g2". |
point1 | any | Specifies the first point to be added. |
point2 | any | Specifies the second point to be added. |
Return value
The point-add
function returns the result of adding the specified points together.
Examples
The following example demonstrates how to use the point-add
function to add the two specified points together on the BN256 curve in the Pact REPL:
pact> (point-add 'g1 {'x': 1, 'y': 2} {'x': 1, 'y': 2}){"x": 1368015179489954701390400359078579693043519447331113978918064868415326638035,"y": 9918110051302171585080402603319702774565515993150576347155970296011118125764}
pact> (point-add 'g1 {'x': 1, 'y': 2} {'x': 1, 'y': 2}){"x": 1368015179489954701390400359078579693043519447331113978918064868415326638035,"y": 9918110051302171585080402603319702774565515993150576347155970296011118125764}
In this example, the type
of addition is g1
and the points are provided as objects with x
and y
coordinates.
scalar-mult
Use scalar-mult
to multiply a point that lies on the BN254 by a specified scalar
integer value.
Basic syntax
To multiply a point by a specified scalar
integer value, use the following syntax:
(scalar-mult type point1 scalar)
(scalar-mult type point1 scalar)
Arguments
Use the following arguments to specify the type
, point
, and scalar
value for multiplication using the scalar-mult
Pact function.
Argument | Type | Description |
---|---|---|
type | string | Specifies the type of point to multiply. The valid values are "g1" and "g2". |
point1 | point | Specifies the point on the BN254 curve to be multiplied. |
scalar | integer | Specifies the integer value to multiply the point by. |
Return value
The scalar-mult
function returns the result of multiplying the specified point by the scalar
value.
Examples
The following example demonstrates how to use the scalar-mult
function to multiply the point { 'x: 1, 'y: 2 }
on curve 'g1
by the scalar value 3
:
pact> (scalar-mult 'g1 {'x: 1, 'y: 2} 3){"x": 3353031288059533942658390886683067124040920775575537747144343083137631628272,"y": 19321533766552368860946552437480515441416830039777911637913418824951667761761}
pact> (scalar-mult 'g1 {'x: 1, 'y: 2} 3){"x": 3353031288059533942658390886683067124040920775575537747144343083137631628272,"y": 19321533766552368860946552437480515441416830039777911637913418824951667761761}