A note on the elliptic curve pairing checks in zero-knowledge proofs
As I explained here a while back, checking polynomial identities (some left-hand side is equal to some right-hand side) when polynomials are hidden using polynomial commitment schemes, gets harder and harder with multiplications. This is why we use pairings, and this is why sometimes we “linearize” our identities. If you didn’t get what I just said, great! Because this is exactly what I’ll explain in this post.
Using Schwartz-Zippel with no multiplication
First, let me say that there’s typically two types of “nice” polynomial commitment schemes that people use with elliptic curves: Pedersen commitments and KZG commitments.
Pedersen commitments are basically hidden random linear combinations of the coefficients of a polynomial. That is, if your polynomial is your commitment will look like for some base point and unknown random values . This is both good and bad: since we have access to the coefficients we can try to use them to evaluate a polynomial from its commitment, but since it’s a random linear combination of them things can get ugly.
On the other hand, KZG commitments can be seen as hidden evaluations of your polynomials. For the same polynomial as above, a KZG commitment of would look like for some unknown random point . Not knowing here is much harder than not knowing the values in Pedersen commitments, and this is why KZG usually requires a trusted setup whereas Pedersen doesn’t.
In the rest of this post we’ll use KZG commitments to prove identities.
Let’s use to mean “commitment of the polynomial “, then you can easily check that knowing only the commitments to and by checking that or . This is because of the Schwartz-Zippel (S-Z) lemma which tells us that checking this identity at a random point is convincing with high-enough probability.
When multiplication with scalars is required, then things are fine. As you can do to obtain , checking that is as simple as checking that .
This post is about explaining how pairing helps us when we want to check an identity that involves multiplying and together.
Using elliptic curve pairings for a single multiplication
It turns out that elliptic curve pairings allow us to perform a single multiplication. Meaning that once things get multiplied, they move to a different planet where things can only get added together and compared. No more multiplications.
Pairings give you this function which allows you to move things in the exponent like this: . Where, remember, is the multiplication of the two polynomials evaluated at a random point: .
As such, if you wanted to check something like this for example: with commitments only, you could check the following pairings:
By the way, the left argument and the right argument of a pairing are often in different groups for “reasons”. So we usually write things like this:
And so it is important to have commitments in the right groups if you want to be able to construct your polynomial identity check.
Evaluations can help with more than one multiplication
But what if you want to check something like ? Are we doomed?
We’re not! One insight that plonk brought to me (which potentially came from older papers, I don’t know, I’m not an academic, leave me alone), is that you can reduce the number of multiplication with “this one simple trick”. Let me explain…
A typical scenario includes you wanting to check an identity like this one:
and you have KZG commitments to all three polynomials . (So in other words, hidden evaluations of these polynomials at the same unknown random point )
You can’t compute the commitment of the left-hand side because you can’t perform the multiplication of the three commitments.
The trick is to evaluate (using KZG) the previous identity at a different point, let’s say , and pre-evaluate (using KZG as well) as many polynomials as you can to to reduce the number of multiplications down to 0.
Note: that is, if we want to check that is true, and we want to use S-Z to do that at some point , then we can pre-evaluate (or ) and check the following identity at some point instead.
More precisely, we’ll choose to pre-evaluate and , for example. This means that we’ll have to produce a quotient polynomial and such that:
which means that the verifier will have to perform the following two pairings (after having been sent the evaluation and in the clear):
Then, they’ll be able to check the first identity at and use and in place of the commitments and . The verifier check will look like the following pairing (after receiving a commitment from the prover):
which proves using KZG that (which proves that the identity checks out with high probability thanks to S-Z).
Aggregating all the KZG evaluation proofs
In the previous explanation, we actually perform 3 KZG evaluation proofs instead of one:
- pairings that are KZG evaluation proofs that pre-evaluate different polynomials from the main check at some random point .
- pairing that evaluates the main identity at , after it was linearized to get rid of any multiplication of commitments.
Pairings can be aggregated by simply creating a random linear combinations of the pairings. That is, with some random values we can aggregate the checks where the left-hand side is:
and the right-hand side is: