Variants of KZG: Part I, Univariate
Written by Varun Thakore on

KZG-I Header

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:

  • setup(d)pp: Given an upper bound d on the degree, it outputs public parameters pp used to commit to polynomials of degree less than d.

  • commit(pp,f)comf: Takes public parameters pp and a polynomial f of degree <d, and outputs a commitment comf to the polynomial.

  • open(P,V)0/1: An interactive protocol where the prover P convinces the verifier V that f(u)=v. The verifier outputs 1 (accept) or 0 (reject).

Informally, two key properties of a PCS are:

  • Binding: The prover P 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 Fp(<d)[X] as the set of univariate polynomials in the variable X of degree less than d, with coefficients in the prime field Fp. For brevity, we sometimes omit the variable and write f instead of f(X). We use [k] to denote the set of integers {1,,k}.

We assume the existence of groups (G1,G2,GT) of appropriate security parameter λ, along with their generators (G1,G2,GT). We use additive notation for G1 and G2, and multiplicative notation for GT. For scalar multiplication, we define [x]1:=xG1 and [x]2:=xG2. These groups support a bilinear pairing operation:

e:G1×G2Gt

An essential property of pairings is bilinearity, meaning that for scalars a,b we have: e(aG1,bG2)=e(G1,G2)ab This is important because it allows us to multiply scalars in the exponent. This property is used in many constructions to enable the verifier V to perform consistency checks on the messages sent by the prover P.

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 fFp(<d)[X], the condition that f evaluates to v at point u (i.e. f(u)=v) is equivalent to the statement that the polynomial f(X)v has a root at u (i.e. f(u)v=0). Thus, by factor theorem, (Xu) is a factor of f(X)v i.e. the polynomial f(X)v is divisible by (Xu). In other words, there exists a quotient polynomial q(X) such that:

(1)q(X)=f(X)vXu

More generally, evaluating f on a set S (i.e., evaluating f(u) for all uS) is equivalent to f(X)r(X) being divisible by ZS(X). That is, there exists a quotient polynomial q(X) such that:

(2)q(X)=f(X)r(X)ZS(X)

where rFp(<|S|)[X] such that r(u)=f(u) for all uS, and ZS(X)=uS(Xu).

Let us understand the above with an example.

Suppose f(X)=X3+2X+1 and S={1,2}.

Then f(1)=4 and f(2)=13.

Now, r(X) is the polynomial such that r(1)=f(1)=4 and r(2)=f(2)=13.

We can interpolate r(X) using these points, and find that:

r(X)=9X5

Also, the vanishing polynomial is:

ZS(X)=(X1)(X2)=X23X+2

Now, f(X)r(X) should be divisible by ZS(X).

Using polynomial long division, we find the quotient polynomial to be:

q(X)=f(X)r(X)ZS(X)=X37X+6X23X+2=X+3

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 comf to polynomial f, V needs to check whether f(u)=?v. As discussed earlier, checking f(u)=?v is equivalent to checking that equation (1) is valid.

If equation (1) 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 V does not know α, it can still verify the validity of equation (1) at α using the commitments sent by P and the pairing operation.

The algorithms for the construction are defined as follows:

  • setup(d)pp

    • Sample a random αFp
    • pp=([1]1,[α]1,,[αd1]1,[1]2,[α]2)
    • Discard α
  • commit(pp,f)comf

    • comf=[f(α)]1=f0[1]1+f1[α]1+f2[α2]1++fd1[αd1]1

      where f0,f1,f2,,fd1 are coefficients of f

  • open(P,V)0/1

    • P computes comf and sends it to V
    • V samples an element uFp and requests an opening of f at u
    • P computes the quotient polynomial q using equation (1) and sends its commitment comq to V along with the evaluation v=f(u)

      Note that checking equation (1) is same as checking the validity of the following equation: q(X)(Xu)=f(X)v The verifier V will check this equation at the secret value α using pairings.

    • V verifies the opening proof comq and outputs 1 if the following equation holds; otherwise, it outputs 0. e(comq,[α]2u[1]2)=?e(comfv[1]1,[1]2)

This scheme is homomorphic i.e. given commitments comf and comg to polynomials f(X) and g(X) respectively, we can compute a commitment to the polynomial h(X)=f(X)+g(X) as comh=comf+comg. 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 P is given polynomials f1,,fkFp(<d)[X] and must convince the verifier V of the correct evaluations of each fi over a corresponding set Si, where SiT={u1,u2,,ut} for all i[k].

The prover P could individually prove the validity of the following equation for all i[k], this is same as equation (2). (3)qi(X)=fi(X)ri(X)ZSi(X) However, as noted earlier, it would not be efficient. The key idea is that if the above equation is valid for all i[k], then a random linear combination of these k equations will also be valid with a high probability. The prover P receives a random value γ from the verifier V and computes the random linear combination as follows: (4)q(X)=i[k]γi1qi(X)=i[k]γi1fi(X)ri(X)ZSi(X) Thus, the verifier V only needs to verify the validity of this single random linear combination, rather than verifying equation (3) individually for each i[k].

We focus on the open protocol, as the setup and commit algorithms remain similar.

open(P,V)0/1

  • P sends com1,com2,,comk to V, as commitments to polynomials f1,f2,fk, respectively
  • V samples sets S1,S2,,Sk and asks P to open fi at Si for all i[k]
  • V sends random γ (used to combine all the openings)
  • P does the following:
    • Compute q(X) using equation (4)
    • Send commitment to q(X) i.e. comq to V along with the claimed evaluations of fi over Si for all i[k]

Note that verifying the validity of equation (4) is equivalent to verifying the following equation: (5)q(X)ZT(X)=i[k]γi1ZTSi(X)(fi(X)ri(X)) where TSi denotes the set difference between T and Si. This can be done using two different methods.

Method I

The verifier V can directly check the validity of equation (5) at α (the secret value) using pairings. V outputs 1 if the following equation holds; otherwise, it outputs 0.

e(comq,[ZT(α)]2)=?i[k]e(γi1(comi[ri(α)]1),[ZTSi(α)]2)

Note that in the above check, the verifier V can compute [ZT(α)]2, [ZTSi(α)]2, and [ri(α)]1 for each i[k] on its own. Since V needs to compute the commitments [ZT(α)]2 and [ZTSi(α)]2 in the group G2, the public parameters pp must include additional powers of the secret α in G2, i.e., ([1]2,[α]2,,[αt]2), where t is the degree of ZT(X).

The opening proof in this method consists of a single group element, namely comq. However, it requires V to compute multiple pairings and perform product operations in the target group GT. 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 (5) is checked at that point. By the Schwartz-Zippel Lemma, if equation (5) holds at a randomly chosen point, then with high probability, it holds for all points.

  • V samples a random challenge z and sends it to P

    P will have to prove that equation (5) is valid at z i.e. (6)q(z)ZT(z)=?i[k]γi1ZTSi(z)(fi(z)ri(z)) P computes the polynomial l(X) such that l(X)=i[k]γi1ZTSi(z)(fi(X)ri(z))q(X)ZT(z) Then, P shows that l(z)=0. Note that the values ZT(z), ZTSi(z), and ri(z) can all be computed by the verifier V.

  • P sends an opening proof that l(X) evaluates to 0 at z, i.e., the commitment coml to the polynomial l(X), where: l(X)=l(X)Xz

    Now, verifying the validity of equation (6) is reduced to checking whether the following equation holds.
    l(X)(Xz)=l(X) 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 V checks the validity of this equation at the secret value α using pairings.

  • V computes coml, the commitment to l(X), using the homomorphic property of KZG: coml:=i[k]γi1ZTSi(z)(comiri(z)[1]1)ZT(z)comq

    Then, V outputs 1 if the following equation holds; otherwise, it outputs 0: e(coml,[1]2)=?e(coml,[α]2z[1]2)

In this case, the opening proof is two group elements i.e. comq and coml. However, the verifier V only needs to compute two pairings and performs no operations in the target group Gt. Moreover, since V does not need to compute the commitments [ZT(α)]2 and [ZTSi(α)]2 in the group G2, the public parameters pp do not require additional powers of the secret α in group G2 (as is the case in Method I). Instead, they only need to include the elements ([1]2,[α]2) elements from G2.

Unconditionally Hiding

In all the schemes we have seen so far, the commit algorithm commit 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 f, and another to a random polynomial f~. The key idea is to add the random commitment comf~ to the original commitment comf, so that the resulting commitment is uniformly distributed across the group. The algorithms are described as follows:

  • setup(d)pp

    • Sample random elements α,βFp. The value β will be used to combine the commitments to f and f~.
    • pp=([1]1,[α]1,,[αd1]1,[β]1,[βα]1,,[βαd1]1,[1]2,[α]2)
    • Discard α,β
  • commit(pp,f)comf^

    • Sample a random polynomial f~Fp(<d)[X]

    • comf^=[f(α)]1+[βf~(α)]1 =f0[1]1+f1[α]1+f2[α2]1++fd1[αd1]1+ f~0[β]1+f~1[βα]1+f~2[βα2]1++f~d1[βαd1]1

      where f0,f1,,fd1 are coefficients of f and f~0,f~1,,f~d1 are coefficients of f~.

      The commitment comf^ can also be viewed as a commitment to the polynomial f^(X), where f^(X)=f(X)+βf~(X).

  • open(P,V)0/1

    • P computes comf^ and sends it to V
    • V samples an element uFp and asks P to open f at u
    • P computes the quotient polynomials q, q~ and sends the commitment comq^ to V along with the evaluations f(u) and f~(u) q(X)=f(X)f(u)Xu q~(X)=f~(X)f~(u)Xu comq^=[q(α)]1+[βq~(α)]1

      This reduces the check f(u)=?v to checking that q^=q+βq~ i.e. checking the following equation is valid: q^(X)=f(X)f(u)Xu+βf~(X)f~(u)Xu f(X)+βf~(X)=q^(X)(Xu)+(f(u)+βf~(u)) f^(X)=q^(X)(Xu)+(f(u)+βf~(u)) Using the same idea as before, V will check the above equation at α using the evaluations f(u),f~(u) and commitments comf^,comq^ sent by P

    • V outputs 1 if the following holds, otherwise 0:
      e(comf^,[1]2)=?e(comq^,[α]2u[1]2)e(f(u)[1]1+f~(u)[β]1,[1]2)

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:

  • setup(d)pp

    • Sample random elements α,βFp
    • pp=([1]1,[α]1,,[αd1]1,[β]1,[1]2,[α]2,[β]2)
    • Discard α,β
  • commit(pp,f)comf^

    • choose a random element rFp (used to randomize the commitment to polynomial f)
    • comf^=[f(α)]1+r[β]1=f0[1]1+f1[α]1+f2[α2]1++fd1[αd1]1+r[β]1
      where f0,f1,,fd1 are coefficients of f.

      The commitment comf^ can be viewed as a commitment to polynomial f^(X)=f(X)+rβ.

  • open(P,V)0/1

    • P computes comf^ and sends it to V

    • V samples an element uFp and asks P to open f at u

    • P samples a random sFp (used to randomize the commitment to quotient polynomial q) and computes the commitment comq^, and sends it to V along with the evaluation f(u). Additionally, P also sends δ, which is the corrective term to account for the randomness in comf^ and comq^.

      q(X)=f(X)f(u)Xu

      comq^=[q(α)]1+s[β]1

      δ=r[1]1s[α]1+(su)[1]1=[rs(αu)]1

      The commitment comq^ can be viewed as commitment to the polynomial q^(X)=q(X)+sβ. From our previous discussion, we know that checking the evaluation f(u) is equivalent to checking that the following equation is valid. q(X)=f(X)f(u)Xu However, the verifier V cannot check the above equation directly at α (the secret value), because they do not have commitments to q(X) and f(X). Instead, they possess the randomized commitments comq^ and comf^.
      Let us incorporate the corresponding randomness and rearrange the terms to derive an equation that V can verify using the commitments comq^, comf^, and a pairing check. This process will also provide insight into the corrective term δ. We begin by adding the randomness of comq^, i.e., sβ, to both sides: q(X)+sβ=f(X)f(u)Xu+sβ (q(X)+sβ)(Xu)=f(X)f(u)+sβ(Xu) Add the randomness of comf^ i.e. rβ on both sides: (q(X)+sβ)(Xu)+rβ=f(X)f(u)+sβ(Xu)+rβ (q(X)+sβ)(Xu)+rβsβ(Xu)=(f(X)+rβ)f(u) (q(X)+sβ)(Xu)+(rs(Xu))β=(f(X)+rβ)f(u) Note that in the above equation the term (q(X)+sβ) corresponds to comq^, the term (f(X)+rβ) corresponds to comf^ and the term (rs(Xu)) corresponds to δ. Thus, V can verify the above equation at the secret value α using pairings.

    • V outputs 1 if the following holds; otherwise, it outputs 0: e(comf^v[1]1,[1]2)=?e(comq^,[α]2u[1]2)e(δ,[β]2)

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 comq^ 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.