This is Part V of a five-part series on different variations of the KZG protocol. The original appeared on the ZK Security blog.
In Part IV, we studied Gemini, which recursively restricts a multilinear polynomial one variable at a time. The prover commits to each intermediate partial evaluation, resulting in an opening proof whose size grows with the number of variables. In this final part of the series, we study Mercury, which improves on this approach by folding half of the variables at once.
Notation. We continue to use the notation from Part IV. Univariate polynomials are denoted with a hat, while multilinear polynomials are denoted without a hat. We write Um for the univariatization map on m-variate multilinear polynomials.
To understand how Mercury performs this large fold, we will first look at how to organize the evaluations of a multilinear polynomial into blocks.
For simplicity, assume that n=2t, define N=2n and T=2t=N. We split the evaluation point into two halves:
u=(uL,uR),uL=(u0,…,ut−1),uR=(ut,…,un−1).
We represent the multilinear polynomial f by its N evaluations over the Boolean hypercube and index this evaluation vector using two indices i,j∈{0,…,T−1} as follows:
fi,j=f(i,j),
where i,j∈{0,1}t denote the t-bit binary representations of i and j, respectively. The first index represents the assignment to XL=(X0,…,Xt−1), while the second represents the assignment to XR=(Xt,…,Xn−1).
We treat the first index as the least significant index. Thus, the evaluation vector is ordered as
There are two parts because X0 can be set to either 0 or 1. Mercury instead groups the first t variables and splits the polynomial over all T=2t Boolean assignments to these variables. The corresponding T-way decomposition is
f(XL,XR)=b∈{0,1}t∑eq(b,XL)⋅f(b,XR)
where, for a,b∈Ft, eq(a,b)=∏k=0t−1(akbk+(1−ak)(1−bk)). Here, XL=(X0,…,Xt−1) denotes the first t variables, while XR=(Xt,…,Xn−1) denotes the remaining variables. This is the multilinear interpolation expression over the first t variables. When t=1, the two equality weights are 1−X0 and X0, so this expression reduces to the two-way Gemini decomposition.
Mercury folds the first t variables by computing the partial evaluation
h(XR)=f(uL,XR)=b∈{0,1}t∑eq(b,uL)⋅f(b,XR)
The verifier must check that the partial evaluation h is consistent with f using the above identity. But the above identity is over multilinear polynomials, whereas we want to use univariate KZG. Therefore, we reduce the consistency check of the above multilinear identity to that of its corresponding univariate identity by applying the univariatization map. Since Ut is linear,
Now index each b∈{0,1}t by i∈{0,…,T−1}, where b=i. By the definition of the block polynomial f^i from the previous section, we have the following:
Ut(f(i,XR))(X)=j=0∑T−1f(i,j)⋅Xj=f^i(X)
Substituting the above expression in equation (2) gives the following univariate identity:
h^(X)=i=0∑T−1eq(i,uL)⋅f^i(X)
Ideally, the verifier would check the above identity at a random point α∈F. If the identity is invalid, then by the Schwartz-Zippel lemma, it agrees at a random α only with small probability.
h^(α)=?i=0∑T−1eq(i,uL)⋅f^i(α)(3)
However, the verifier only has the commitment to f^ (the univariatization of multilinear f) and does not have commitments to the block polynomials f^i. Therefore, the verifier cannot check the above identity. A naive approach would require the prover to send the T commitments to f^i and their claimed evaluations at α, making the proof size depend on T.
Can we pack all the values f^i(α) into a single polynomial that is directly related to f^(X)?
The block decomposition of f^, from equation (1) of the previous section, suggests how to do this:
f^(X)=i=0∑T−1Xi⋅f^i(XT)
Working modulo XT−α is equivalent to replacing every occurrence of XT by α. Therefore,
f^(X)≡i=0∑T−1Xi⋅f^i(α)mod(XT−α)
Thus, the remainder of this division is a polynomial g^(X) of degree less than T:
g^(X)=f^(X)mod(XT−α)=i=0∑T−1f^i(α)⋅Xi
whose coefficients are exactly f^i(α). Accordingly, the prover divides f^(X) by (XT−α) and obtains the quotient q^ and the remainder g^ such that,
f^(X)=(XT−α)⋅q^(X)+g^(X),deg(g^)<T.
Now the t-variate multilinear polynomial g whose univariate encoding is g^ will be as follows:
g(X)=i=0∑T−1eq(i,X)⋅f^i(α)
The evaluation of g at uL is exactly h^(α), i.e.,
g(uL)=i=0∑T−1eq(i,uL)f^i(α)=h^(α)
Thus, we have reduced the check from expression (3) to the following two checks:
However, the above checks alone are not enough. The verifier must also check deg(g^)<T, because without this degree check the quotient q^ and remainder g^ are not unique. The check deg(g^)<T makes g^ the unique remainder of division by XT−α and ensures that its T coefficients encode a t-variate multilinear polynomial g.
Up to this point, we have only checked the consistency of the partial evaluation h with respect to the multilinear polynomial f. Our goal, however, is to check the full evaluation f(uL,uR)=v. Using the partial evaluation expression h(XR)=f(uL,XR) and setting XR=uR, we get
h(uR)=f(uL,uR)=v
Therefore, the verifier must also check that the partial evaluation h evaluates to the original claimed value v, i.e.,
h(uR)=?v
To summarize the sequence of reductions, the original claim f(u)=?v has been reduced to the following checks:
Two multilinear evaluation checks, which are batched together and proved using an inner product protocol.
- g(uL)=?h^(α) connects the partial evaluation h to the remainder g.
- h(uR)=?v checks that the partial evaluation h is consistent with the claimed value v.
deg(g^)<T ensures that g^ is a valid remainder modulo (XT−α).
f^(X)=?(XT−α)⋅q^(X)+g^(X) checks consistency between g^ and f^. The prover first commits to q^ and g^. The verifier then samples a random point z and the prover uses a KZG opening to prove the following.
f^(z)=?(zT−α)⋅q^(z)+g^(z)
Now there are only two missing pieces: the inner product protocol to prove multilinear evaluations and the degree check protocol. Next we will look into each of them.
Consider a multilinear polynomial g in t variables. We can express g using the equality function as follows:
g(X)=b∈{0,1}t∑eq(b,X)⋅g(b)
For u∈Ft, the goal is to prove that g(u)=v. Mercury reduces this multilinear evaluation claim to an inner product between coefficients of univariate polynomials.
We have the following univariatization of g, where the T=2t evaluations of g over the Boolean hypercube are the coefficients of the univariate polynomial g^.
g^(X)=i=0∑T−1g(i)⋅Xi
We can also encode the evaluations of the equality function as coefficients of a polynomial:
The product form allows the verifier to evaluate P^u using O(t)=O(n) field operations.
Then, we can reduce the evaluation claim g(u)=v to the inner product of coefficients of the univariate polynomials P^u and g^ as follows:
⟨P^u,g^⟩=i=0∑T−1eq(i,u)⋅g(i)=g(u)=v
Mercury has an elegant technique of proving such inner products. Observe that ⟨P^u,g^⟩ is the constant coefficient of the following function.
P^u(X)⋅g^(1/X)
Therefore, the claim ⟨P^u,g^⟩=v is equivalent to the existence of polynomials S^1 and S^2 such that
P^u(X)⋅g^(1/X)=1/X⋅S^1(1/X)+v+X⋅S^2(X).
Here, S^1 contains the negative-degree terms, while S^2 contains the positive-degree terms. Checking this identity directly would require commitments to both S^1 and S^2. Mercury instead symmetrizes the expression:
We have reduced the two multilinear evaluation claims to checking the above identity. Finally, the verifier checks the above identity at a random non-zero point z∈F∗.
The last remaining piece is the degree check protocol, which ensures deg(g^)<T. We examine it next.
The degree check protocol used in Mercury is different from the degree check protocol that we studied for Zeromorph in Part III.
The goal is to prove deg(g^)<T. The prover defines
D^(X)=XT−1⋅g^(1/X).
To see why this enforces the degree bound, write g^(X)=∑i=0dgiXi. Then,
D^(X)=XT−1g^(1/X)=i=0∑dgiXT−1−i.
If d<T, every exponent is nonnegative, so D^ is a polynomial. If d≥T, the term gdXT−1−d has a negative exponent, so D^ is not a polynomial. A dishonest prover could still commit to an unrelated polynomial D^, so the verifier must bind the committed D^ to XT−1g^(1/X) using the following identity at a random nonzero point z∈F∗.
D^(z)=?zT−1⋅g^(1/z)
We have all the pieces required to describe the complete end-to-end protocol.
The public inputs are the original univariate KZG commitment C=[f^(τ)]1, the evaluation point u=(uL,uR) and the claimed evaluation v. The prover’s witness is the multilinear polynomial f.
Commit to the large fold. The prover computes
h^(X)=i=0∑T−1eq(i,uL)⋅f^i(X)
and sends its univariate KZG commitment Ch=[h^(τ)]1 to the verifier.
Commit to the quotient and remainder. The verifier samples α$F and sends it to the prover. The prover computes
f^(X)=(XT−α)⋅q^(X)+g^(X),deg(g^)<T
and sends
Cq=[q^(τ)]1andCg=[g^(τ)]1.
Commit to the batched inner product proof and degree check. The verifier samples a random batching challenge γ$F. The prover computes S^ such that
For an n-variate multilinear polynomial with N=2n coefficients and T=2n/2=N, the major costs are as follows:
Proof Size: The prover sends a constant number of commitments, evaluations and KZG opening proofs, independent of the number of variables n. Assuming that a group element is encoded using two field elements, the proof size is O(1) field elements.
Prover Cost: Major prover costs involve:
- Computing the quotient q^ and remainder g^ requires O(N)=O(2n) field operations.
- Computing the commitment to the polynomial H^z, which has at most N coefficients. So computing the commitment πz requires at most N=2n group scalar multiplications.
Verifier Cost: The verifier evaluates P^uL and P^uR and computes the required powers of z using O(n) field operations. Since the number of commitments is constant, it performs O(1) group scalar multiplications and two pairing terms.
The opening costs can be summarized as follows:
Component
Cost
Proof size
O(1) field elements
Prover work
O(2n) field operations, O(2n) group scalar mults
Verifier work
O(n) field operations, O(1) group scalar mults, two pairing terms
This final post concludes the five-part series. We studied how KZG commitments extend from univariate polynomials to multilinear polynomials through quotient-based and folding-based methods.
Part I introduces univariate KZG commitments, including their batched and hiding variants.
Part II extends KZG to multilinear polynomials through PST, which checks the multilinear quotient identity using a specialized multivariate setup.
Part III studies Zeromorph, which encodes the multilinear quotient identity as a univariate identity and batches the required degree checks.
Part IV introduces Gemini, which recursively folds one variable at a time and verifies the folds using univariate KZG openings.
Part V studies Mercury, which replaces Gemini’s sequence of single-variable folds with one large fold and reduces the opening proof to constant size.
Together, these constructions illustrate two broad approaches to multilinear KZG commitments and the different trade-offs they make in setup, proof size, prover work and verifier work.