Variants of KZG: Part I, Univariate
Contents
This is Part I of a five-part series on different variations of the KZG protocol. The original appeared on the ZK Security blog.
A polynomial commitment scheme (PCS) allows a prover to commit to a polynomial and later prove its evaluations at points chosen by the verifier. The verifier can then check that the evaluations are consistent with the committed polynomial. Most practical SNARKs (Succinct Non-interactive Arguments of Knowledge) are constructed using a PCS. It consists of the following three algorithms:
: Given an upper bound on the degree, it outputs public parameters used to commit to polynomials of degree less than .
: Takes public parameters and a polynomial of degree , and outputs a commitment to the polynomial.
: An interactive protocol where the prover convinces the verifier that . The verifier outputs 1 (accept) or 0 (reject).
Informally, two key properties of a PCS are:
Binding: The prover cannot lie about the evaluations of the polynomial they committed to.
Hiding: A computationally bounded adversary should learn nothing about the polynomial from the commitment.
One of the most widely used PCS is KZG10, due to its constant proof size and verification time. It is used to construct various SNARKs such as Sonic and Plonk. In this post, we explore KZG variants for univariate polynomials. But first, let’s introduce some notation and preliminaries.
Notation and Preliminaries#
We denote as the set of univariate polynomials in the variable of degree less than , with coefficients in the prime field . For brevity, we sometimes omit the variable and write instead of . We use to denote the set of integers .
We assume the existence of groups of appropriate security parameter , along with their generators . We use additive notation for and , and multiplicative notation for . For scalar multiplication, we define and . These groups support a bilinear pairing operation:
An essential property of pairings is bilinearity, meaning that for scalars we have:
This is important because it allows us to multiply scalars in the exponent. This property is used in many constructions to enable the verifier to perform consistency checks on the messages sent by the prover .
Polynomial Identities#
In this section, we introduce some foundational facts about polynomials that will be helpful in understanding the various constructions covered later.
For a polynomial , the condition that evaluates to at point (i.e. ) is equivalent to the statement that the polynomial has a root at (i.e. ). Thus, by factor theorem, is a factor of i.e. the polynomial is divisible by . In other words, there exists a quotient polynomial such that:
More generally, evaluating on a set (i.e., evaluating for all ) is equivalent to being divisible by . That is, there exists a quotient polynomial such that:
where such that for all , and .
Example
Let us understand the above with an example.
Suppose and .
Then and .
Now, is the polynomial such that and .
We can interpolate using these points, and find that:
Also, the vanishing polynomial is:
Now, should be divisible by .
Using polynomial long division, we find the quotient polynomial to be:
With the notation and preliminaries in place, we can now look at the first construction.
Plain KZG#
This is the most basic construction, as described in Section 3.2 of KZG10. The key idea is that after receiving a commitment to polynomial , needs to check whether . As discussed earlier, checking is equivalent to checking that equation is valid.
If equation is valid at a random point then with high probability it is valid at all points (by the Schwartz-Zippel Lemma). In this setting, the random point is the secret value . Although does not know , it can still verify the validity of equation at using the commitments sent by and the pairing operation.
The algorithms for the construction are defined as follows:
- Sample a random
- Discard
where, are coefficients of .
- computes and sends it to
- samples an element and requests an opening of at
- computes the quotient polynomial using equation and sends its commitment to along with the evaluation
Note
Now, checking equation is same as checking the validity of the following equation:
The verifier will check this equation at the secret value using pairings.
- verifies the opening proof and outputs 1 if the following equation holds; otherwise, it outputs 0.
This scheme is homomorphic i.e. given commitments and to polynomials and respectively, we can compute a commitment to the polynomial as . We will use this property to batch multiple openings and to make the commitment unconditionally hiding using some randomness.
We have seen how to open a single polynomial at a single point. Now, let’s extend this to opening multiple polynomials at multiple points.
One straightforward approach is to open each polynomial individually and verify each opening proof. However, this would make the number of opening proofs sent by the prover and the number of pairing checks performed by the verifier proportional to the number of polynomials.
Can we open multiple polynomials at multiple points more efficiently? We can use batching.
Batched Variants#
In this section we will look at schemes that enable efficient opening of multiple evaluation points across multiple polynomials. Instead of opening each evaluation separately, we batch all required openings together. This approach leverages the homomorphic property of KZG commitments.
A batch opening protocol for a single polynomial at multiple evaluation points is described in Section 3.4 of KZG10. A variant for opening multiple polynomials at two evaluation points is presented in Section 3 of Plonk. In this section, we focus on more general variants that allow opening multiple polynomials at multiple points, as described in BDFG20.
In this setting, the prover is given polynomials and must convince the verifier of the correct evaluations of each over a corresponding set , where for all .
The prover could individually prove the validity of the following equation for all , this is same as equation .
However, as noted earlier, it would not be efficient. The key idea is that if the above equation is valid for all , then a random linear combination of these equations will also be valid with a high probability. The prover receives a random value from the verifier and computes the random linear combination as follows:
Thus, the verifier only needs to verify the validity of this single random linear combination, rather than verifying equation individually for each .
We focus on the protocol, as the and algorithms remain similar.
- sends to , as commitments to polynomials , respectively
- samples sets and asks to open at for all
- sends random (used to combine all the openings)
- does the following:
- Compute using equation
- Send commitment to i.e. to along with the claimed evaluations of over for all
Note that verifying the validity of equation is equivalent to verifying the following equation:
where denotes the set difference between and . This can be done using two different methods.
Method I#
The verifier can directly check the validity of equation at (the secret value) using pairings. outputs 1 if the following equation holds; otherwise, it outputs 0.
Note that in the above check, the verifier can compute , , and for each on its own. Since needs to compute the commitments and in the group , the public parameters must include additional powers of the secret in , i.e., , where is the degree of .
The opening proof in this method consists of a single group element, namely . However, it requires to compute multiple pairings and perform product operations in the target group . In the next method, we reduce the verifier’s workload.
Method II#
In this approach, an additional random point is sampled, and the validity of equation is checked at that point. By the Schwartz-Zippel Lemma, if equation holds at a randomly chosen point, then with high probability, it holds for all points.
samples a random challenge and sends it to
Note
will have to prove that equation is valid at i.e.
computes the polynomial such that
Then, shows that . Note that the values , , and can all be computed by the verifier .
sends an opening proof that evaluates to 0 at , i.e., the commitment to the polynomial , where:
Note
Now, verifying the validity of equation is reduced to checking whether the following equation holds.
We apply the same idea as before: if the above equation is valid at a randomly chosen point, then with high probability, it is valid at all points (by the Schwartz-Zippel Lemma). Therefore, the verifier checks the validity of this equation at the secret value using pairings.
computes , the commitment to , using the homomorphic property of KZG:
Then, outputs 1 if the following equation holds; otherwise, it outputs 0:
In this case, the opening proof is two group elements i.e. and . However, the verifier only needs to compute two pairings and performs no operations in the target group . Moreover, since does not need to compute the commitments and in the group , the public parameters do not require additional powers of the secret in group (as is the case in Method I). Instead, they only need to include the elements elements from .
Unconditionally Hiding#
In all the schemes we have seen so far, the commit algorithm is deterministic i.e. it does not sample a random value. This leaks some information, for example if two commitments are equal then the underlying polynomial must be the same. We will now look at schemes which use some randomness to achieve the unconditionally hiding property.
Informally, unconditionally hiding means that even a computationally unbounded adversary learns no information about the underlying polynomial from the commitment. This is achieved by adding randomness to the commitment so that it becomes uniformly distributed over the entire group. As a result, after seeing the commitment, the best an adversary can do is make a random guess about the polynomial.
An unconditionally hiding PCS is crucial in settings where privacy is important, as it enables the construction of zkSNARKs, that is, SNARKs with the zero-knowledge property. The methods to achieve an unconditionally hiding PCS are as follows.
Method I: Using a random polynomial#
This method is described in Section 3.3 of KZG10. It leverages the homomorphic property to achieve unconditionally hiding by combining two commitments: one to the polynomial , and another to a random polynomial . The key idea is to add the random commitment to the original commitment , so that the resulting commitment is uniformly distributed across the group. The algorithms are described as follows:
- Sample random elements . The value will be used to combine the commitments to and .
- Discard
Sample a random polynomial
where are coefficients of and are coefficients of .
Note
The commitment can also be viewed as a commitment to the polynomial , where .
computes and sends it to
samples an element and asks to open at
computes the quotient polynomials , and sends the commitment to along with the evaluations and
Note
This reduces the check to checking that i.e. checking the following equation is valid:
Using the same idea as before, will check the above equation at using the evaluations and commitments sent by .
outputs 1 if the following holds, otherwise 0:
In this method, we blind the polynomial using a random polynomial to achieve unconditionally hiding. However, the same property can also be achieved using just a single random group element, as shown in the following method.
Method II: Using a random group element#
This method achieves unconditionally hiding using a single random group element. It is described in Section 3.5.3 of Zeromorph. The main idea is to add a random group element to the original commitment, ensuring that the resulting commitment is uniformly distributed across the group. The algorithms are as follows:
- Sample random elements
- Discard
choose a random element (used to randomize the commitment to polynomial )
where are coefficients of .Note
The commitment can be viewed as a commitment to polynomial .
computes and sends it to
samples an element and asks to open at
samples a random (used to randomize the commitment to quotient polynomial ) and computes the commitment , and sends it to along with the evaluation . Additionally, also sends , which is the corrective term to account for the randomness in and .
Note
The commitment can be viewed as a commitment to the polynomial . From our previous discussion, we know that checking the evaluation is equivalent to checking that the following equation is valid.
However, the verifier cannot check the above equation directly at (the secret value), because they do not have commitments to and . Instead, they possess the randomized commitments and .
Let us incorporate the corresponding randomness and rearrange the terms to derive an equation that can verify using the commitments , , and a pairing check. This process will also provide insight into the corrective term . We begin by adding the randomness of , i.e., , to both sides:
Add the randomness of i.e. on both sides:
Note that in the above equation the term corresponds to , the term corresponds to and the term corresponds to . Thus, can verify the above equation at the secret value using pairings.
outputs 1 if the following holds; otherwise, it outputs 0:
In this method, we achieve the unconditionally hiding property using a single random group element. However, the opening proof consists of two group elements, namely and , compared to a single group element in Method I.
Conclusion#
In this post, we explored various univariate variants of the KZG polynomial commitment scheme, including techniques for batching multiple openings and achieving the unconditionally hiding property. In the next part of this series, we will delve into the multivariate setting.