This is an operation that allows to transform
Then, the three encrypted values can be sent to a verifier. He will be able to verify that
In the following explanations:
- Capital letters
$\rightarrow$ EC points - Lower case letters
$\rightarrow$ elements of finite field
A curve point is produced by multiplying a scalar by another point of the elliptic curve:
Let's assume that
If $pq=r$, we want a function such that $f(P,Q)=R$. When $pq \neq r$, we want this function to be
Typically, this
In practice, the feature of bilinear pairing that we care about is:
### Maths notation
In the literature, the function we previously called
Respecting the literature, notation is
In practice, it turns out to be easier to create bilinear pairings with different groups for the arguments. We say
*Note:
In symmetric pairing, the same group is used for both arguments of the function.
The generator
A symmetric pairing function:
In asymmetric pairing, the arguments of the function use different groups. The generator and the EC group can be different. The pairing function can still satisfy the property we are looking for.
An asymmetric pairing function:
## Field extensions In Ethereum's bilinear pairing uses elliptic curves with field extensions.
With field extensions, EC points consist of several
But those points still have the properties of cyclic groups. They do all the same stuffs than classic EC points.
In the next sections, we are going to use 3 groups:
The code can be found in pairing.py file. In this code, py_ecc library is used. It implements the bn128 pairing that is used by the precompile at address 0x08 on Ethereum.
The bn197 pairing is standardized on Ethereum in EIP-197. The specification of the 0x08 precompile takes in a list of
A₁ = a₁G1
B₁ = b₁G2
A₂ = a₂G1
B₂ = b₂G2
...
Aₙ = aₙG1
Bₙ = bₙG2
A call to the 0x08 precompile returns 1
if the following is true: 0
.
$\mathbb{G}_{12} points are huge, so they are not returned as it would take a lot of gas to store them in memory.
Moreover, the value of the output is generally not checked. Only the fact that it is equal to another pairing is generally done.
In Groth16, the final step looks like
Note: We talked about Groth16, but most ZK algorithm have verification formula that are pretty similar.*
Let's prove that:
a = 4
b = 3
c = 6
d = 2
-ab + cd = 0
By using pairing, we need to prove:
The pythonComputation.py file contains the code to compute the field elements.
The SolZKVerifier contract allow to verify that the pairings match.