Varun Thakore

Variants of KZG: Part V, Multilinear Commitments with Mercury

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\mathcal U_m for the univariatization map on mm-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.

Organizing Evaluations into Blocks#

For simplicity, assume that n=2tn=2t, define N=2nN=2^n and T=2t=NT=2^t=\sqrt N. We split the evaluation point into two halves:

u⃗=(u⃗L,u⃗R),u⃗L=(u0,…,ut−1),u⃗R=(ut,…,un−1). \vec u=(\vec u_L,\vec u_R), \qquad \vec u_L=(u_0,\ldots,u_{t-1}), \qquad \vec u_R=(u_t,\ldots,u_{n-1}).

We represent the multilinear polynomial ff by its NN evaluations over the Boolean hypercube and index this evaluation vector using two indices i,j∈{0,…,T−1}i,j\in\{0,\ldots,T-1\} as follows:

fi,j=f(i⃗,j⃗), f_{i,j} = f\left(\vec{i},\vec{j}\right),

where i⃗,j⃗∈{0,1}t\vec{i},\vec{j}\in\{0,1\}^t denote the tt-bit binary representations of ii and jj, respectively. The first index represents the assignment to X⃗L=(X0,…,Xt−1)\vec X_L=(X_0,\ldots,X_{t-1}), while the second represents the assignment to X⃗R=(Xt,…,Xn−1)\vec X_R=(X_t,\ldots,X_{n-1}).

We treat the first index as the least significant index. Thus, the evaluation vector is ordered as

(f0,0,f1,0,…,fT−1,0,f0,1,…,fT−1,1,…,f0,T−1,…,fT−1,T−1). \left( f_{0,0},f_{1,0},\ldots,f_{T-1,0}, f_{0,1},\ldots,f_{T-1,1}, \ldots, f_{0,T-1},\ldots,f_{T-1,T-1} \right).

For each fixed ii, define the vector f⃗i=(fi,0,…,fi,T−1)\vec f_i=(f_{i,0},\ldots,f_{i,T-1}) and its corresponding univariate block polynomial f^i\hat f_i as follows.

f^i(X)=∑j=0T−1fi,j⋅Xj \hat f_i(X)=\sum_{j=0}^{T-1}f_{i,j} \cdot X^j

Since the first index is the least significant, the evaluation fi,jf_{i,j} becomes the coefficient of Xi+jTX^{i+jT} after univariatization. Therefore,

f^(X)=Un(f)(X)=∑i=0T−1∑j=0T−1fi,j⋅Xi+jT=∑i=0T−1Xi⋅f^i(XT)(1) \hat f(X) =\mathcal U_n(f)(X) =\sum_{i=0}^{T-1}\sum_{j=0}^{T-1}f_{i,j} \cdot X^{i+jT} =\sum_{i=0}^{T-1}X^i \cdot \hat f_i(X^T) \tag{1}

With this block representation in place, we can now see how Mercury extends Gemini’s single-variable fold to several variables at once.

From Gemini to Mercury#

Now recall that Gemini (Part IV) splits a multilinear polynomial with respect to the first variable X0X_0 as follows:

f(X0,X1,…,Xn−1)=(1−X0)⋅f(0,X1,…,Xn−1)+X0⋅f(1,X1,…,Xn−1) \begin{aligned} f(X_0,X_1,\ldots,X_{n-1}) ={}&(1-X_0) \cdot f(0,X_1,\ldots,X_{n-1})\\ &+X_0 \cdot f(1,X_1,\ldots,X_{n-1}) \end{aligned}

There are two parts because X0X_0 can be set to either 00 or 11. Mercury instead groups the first tt variables and splits the polynomial over all T=2tT=2^t Boolean assignments to these variables. The corresponding TT-way decomposition is

f(X⃗L,X⃗R)=∑b⃗∈{0,1}teq⁡(b⃗,X⃗L)⋅f(b⃗,X⃗R) f(\vec X_L,\vec X_R) = \sum_{\vec b\in\{0,1\}^t} \operatorname{eq}(\vec b,\vec X_L) \cdot f(\vec b,\vec X_R)

where, for a⃗,b⃗∈Ft\vec a,\vec b\in\mathbb F^t, eq⁡(a⃗,b⃗)=∏k=0t−1(akbk+(1−ak)(1−bk))\operatorname{eq}(\vec a,\vec b) = \prod_{k=0}^{t-1} \left(a_kb_k+(1-a_k)(1-b_k)\right). Here, X⃗L=(X0,…,Xt−1)\vec X_L=(X_0,\ldots,X_{t-1}) denotes the first tt variables, while X⃗R=(Xt,…,Xn−1)\vec X_R=(X_t,\ldots,X_{n-1}) denotes the remaining variables. This is the multilinear interpolation expression over the first tt variables. When t=1t=1, the two equality weights are 1−X01-X_0 and X0X_0, so this expression reduces to the two-way Gemini decomposition.

Mercury folds the first tt variables by computing the partial evaluation

h(X⃗R)=f(u⃗L,X⃗R)=∑b⃗∈{0,1}teq⁡(b⃗,u⃗L)⋅f(b⃗,X⃗R) h(\vec X_R)=f(\vec u_L,\vec X_R) = \sum_{\vec b\in\{0,1\}^t} \operatorname{eq}(\vec b,\vec u_L) \cdot f(\vec b,\vec X_R)

The verifier must check that the partial evaluation hh is consistent with ff 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\mathcal U_t is linear,

h^(X)=Ut(h)(X)=∑b⃗∈{0,1}teq⁡(b⃗,u⃗L)⋅Ut(f(b⃗,X⃗R))(X)(2) \hat h(X) = \mathcal U_t(h)(X) = \sum_{\vec b\in\{0,1\}^t} \operatorname{eq}(\vec b,\vec u_L) \cdot \mathcal U_t\left(f(\vec b,\vec X_R)\right)(X) \tag{2}

Now index each b⃗∈{0,1}t\vec b\in\{0,1\}^t by i∈{0,…,T−1}i\in\{0,\ldots,T-1\}, where b⃗=i⃗\vec b=\vec{i}. By the definition of the block polynomial f^i\hat f_i from the previous section, we have the following:

Ut(f(i⃗,X⃗R))(X)=∑j=0T−1f(i⃗,j⃗)⋅Xj=f^i(X) \begin{aligned} \mathcal U_t\left( f(\vec{i},\vec X_R) \right)(X) = \sum_{j=0}^{T-1} f\left(\vec{i},\vec{j}\right) \cdot X^j = \hat f_i(X) \end{aligned}

Substituting the above expression in equation (2)(2) gives the following univariate identity:

h^(X)=∑i=0T−1eq⁡(i⃗,u⃗L)⋅f^i(X) \hat h(X) = \sum_{i=0}^{T-1} \operatorname{eq}(\vec{i},\vec u_L) \cdot \hat f_i(X)

Ideally, the verifier would check the above identity at a random point α∈F\alpha\in\mathbb F. If the identity is invalid, then by the Schwartz-Zippel lemma, it agrees at a random α\alpha only with small probability.

h^(α)=?∑i=0T−1eq⁡(i⃗,u⃗L)⋅f^i(α)(3) \hat h(\alpha) \stackrel{?}{=} \sum_{i=0}^{T-1} \operatorname{eq}(\vec{i},\vec u_L) \cdot \hat f_i(\alpha) \tag{3}

However, the verifier only has the commitment to f^\hat f (the univariatization of multilinear ff) and does not have commitments to the block polynomials f^i\hat f_i. Therefore, the verifier cannot check the above identity. A naive approach would require the prover to send the TT commitments to f^i\hat f_i and their claimed evaluations at α\alpha, making the proof size depend on TT.

Can we pack all the values f^i(α)\hat f_i(\alpha) into a single polynomial that is directly related to f^(X)\hat f(X)?

The block decomposition of f^\hat f, from equation (1)(1) of the previous section, suggests how to do this:

f^(X)=∑i=0T−1Xi⋅f^i(XT) \hat f(X) = \sum_{i=0}^{T-1}X^i \cdot \hat f_i(X^T)

Working modulo XT−αX^T-\alpha is equivalent to replacing every occurrence of XTX^T by α\alpha. Therefore,

f^(X)≡∑i=0T−1Xi⋅f^i(α)mod  (XT−α) \hat f(X) \equiv \sum_{i=0}^{T-1}X^i \cdot \hat f_i(\alpha) \mod{(X^T-\alpha)}

Thus, the remainder of this division is a polynomial g^(X)\hat g(X) of degree less than TT:

g^(X)=f^(X)mod  (XT−α)=∑i=0T−1f^i(α)⋅Xi \hat g(X) = \hat f(X) \mod{(X^T-\alpha)} = \sum_{i=0}^{T-1}\hat f_i(\alpha) \cdot X^i

whose coefficients are exactly f^i(α)\hat f_i(\alpha). Accordingly, the prover divides f^(X)\hat f(X) by (XT−α)(X^T-\alpha) and obtains the quotient q^\hat q and the remainder g^\hat g such that,

f^(X)=(XT−α)⋅q^(X)+g^(X),deg⁡(g^)<T. \hat f(X) = (X^T-\alpha) \cdot \hat q(X)+\hat g(X), \qquad \deg(\hat g) < T.

Now the tt-variate multilinear polynomial gg whose univariate encoding is g^\hat g will be as follows:

g(X⃗)=∑i=0T−1eq⁡(i⃗,X⃗)⋅f^i(α) g(\vec X) = \sum_{i=0}^{T-1} \operatorname{eq}(\vec{i},\vec X) \cdot \hat f_i(\alpha)

The evaluation of gg at u⃗L\vec u_L is exactly h^(α)\hat h(\alpha), i.e.,

g(u⃗L)=∑i=0T−1eq⁡(i⃗,u⃗L)f^i(α)=h^(α) \begin{aligned} g(\vec u_L) &= \sum_{i=0}^{T-1} \operatorname{eq}(\vec{i},\vec u_L)\hat f_i(\alpha)\\ &=\hat h(\alpha) \end{aligned}

Thus, we have reduced the check from expression (3)(3) to the following two checks:

h^(α)=?∑i=0T−1eq⁡(i⃗,u⃗L)⋅f^i(α)⟹{g(u⃗L)=?h^(α)f^(X)=?(XT−α)⋅q^(X)+g^(X) \hat h(\alpha) \stackrel{?}{=} \sum_{i=0}^{T-1} \operatorname{eq}(\vec{i},\vec u_L) \cdot \hat f_i(\alpha) \quad \Longrightarrow \quad \begin{cases} g(\vec u_L) \stackrel{?}{=} \hat h(\alpha)\\ \hat f(X) \stackrel{?}{=} (X^T-\alpha) \cdot \hat q(X)+\hat g(X) \end{cases}

However, the above checks alone are not enough. The verifier must also check deg⁡(g^)<T\deg(\hat g) < T, because without this degree check the quotient q^\hat q and remainder g^\hat g are not unique. The check deg⁡(g^)<T\deg(\hat g) < T makes g^\hat g the unique remainder of division by XT−αX^T-\alpha and ensures that its TT coefficients encode a tt-variate multilinear polynomial gg.

Up to this point, we have only checked the consistency of the partial evaluation hh with respect to the multilinear polynomial ff. Our goal, however, is to check the full evaluation f(u⃗L,u⃗R)=vf(\vec u_L,\vec u_R)=v. Using the partial evaluation expression h(X⃗R)=f(u⃗L,X⃗R)h(\vec X_R)=f(\vec u_L,\vec X_R) and setting X⃗R=u⃗R\vec X_R=\vec u_R, we get

h(u⃗R)=f(u⃗L,u⃗R)=v h(\vec u_R)=f(\vec u_L,\vec u_R) = v

Therefore, the verifier must also check that the partial evaluation hh evaluates to the original claimed value vv, i.e.,

h(u⃗R)=?v h(\vec u_R)\stackrel{?}{=}v

To summarize the sequence of reductions, the original claim f(u⃗)=?vf(\vec u)\stackrel{?}{=}v has been reduced to the following checks:

f(u⃗)=?v⟹{g(u⃗L)=?h^(α)andh(u⃗R)=?vdeg⁡(g^)<Tf^(X)=?(XT−α)⋅q^(X)+g^(X) f(\vec u)\stackrel{?}{=}v \Longrightarrow \begin{cases} g(\vec u_L)\stackrel{?}{=}\hat h(\alpha) \quad \text{and} \quad h(\vec u_R)\stackrel{?}{=}v\\ \deg(\hat g) < T\\ \hat f(X)\stackrel{?}{=}(X^T-\alpha) \cdot \hat q(X)+\hat g(X) \end{cases}
  • Two multilinear evaluation checks, which are batched together and proved using an inner product protocol. - g(u⃗L)=?h^(α)g(\vec u_L)\stackrel{?}{=}\hat h(\alpha) connects the partial evaluation hh to the remainder gg. - h(u⃗R)=?vh(\vec u_R)\stackrel{?}{=}v checks that the partial evaluation hh is consistent with the claimed value vv.
  • deg⁡(g^)<T\deg(\hat g) < T ensures that g^\hat g is a valid remainder modulo (XT−α)(X^T-\alpha).
  • f^(X)=?(XT−α)⋅q^(X)+g^(X)\hat f(X) \stackrel{?}{=} (X^T-\alpha) \cdot \hat q(X)+\hat g(X) checks consistency between g^\hat g and f^\hat f. The prover first commits to q^\hat q and g^\hat g. The verifier then samples a random point zz and the prover uses a KZG opening to prove the following. f^(z)=?(zT−α)⋅q^(z)+g^(z) \hat f(z) \stackrel{?}{=} (z^T-\alpha) \cdot \hat q(z)+\hat 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.

Multilinear Evaluation as an Inner Product#

Consider a multilinear polynomial gg in tt variables. We can express gg using the equality function as follows:

g(X⃗)=∑b⃗∈{0,1}teq⁡(b⃗,X⃗)⋅g(b⃗) g(\vec X) = \sum_{\vec b \in \{0,1\}^t} \operatorname{eq}(\vec b,\vec X) \cdot g(\vec b)

For u⃗∈Ft\vec u \in \mathbb{F}^t, the goal is to prove that g(u⃗)=vg(\vec u) = v. Mercury reduces this multilinear evaluation claim to an inner product between coefficients of univariate polynomials.

We have the following univariatization of gg, where the T=2tT=2^t evaluations of gg over the Boolean hypercube are the coefficients of the univariate polynomial g^\hat g.

g^(X)=∑i=0T−1g(i⃗)⋅Xi \hat g(X) = \sum_{i=0}^{T-1} g(\vec i) \cdot X^i

We can also encode the evaluations of the equality function as coefficients of a polynomial:

P^u⃗(X)=∑i=0T−1eq⁡(i⃗,u⃗)⋅Xi=∏k=0t−1((1−uk)+ukX2k) \hat P_{\vec u}(X) = \sum_{i=0}^{T-1} \operatorname{eq}(\vec{i},\vec u) \cdot X^i = \prod_{k=0}^{t-1} \left((1-u_k)+u_kX^{2^k}\right)

The product form allows the verifier to evaluate P^u⃗\hat P_{\vec u} using O(t)=O(n)O(t)=O(n) field operations.

Then, we can reduce the evaluation claim g(u⃗)=vg(\vec u) = v to the inner product of coefficients of the univariate polynomials P^u⃗\hat P_{\vec u} and g^\hat g as follows:

⟨P^u⃗,g^⟩=∑i=0T−1eq⁡(i⃗,u⃗)⋅g(i⃗)=g(u⃗)=v \langle \hat P_{\vec u}, \hat g \rangle = \sum_{i=0}^{T-1} \operatorname{eq}(\vec{i},\vec u) \cdot g(\vec i) = g(\vec u) = v

Mercury has an elegant technique of proving such inner products. Observe that ⟨P^u⃗,g^⟩\langle \hat P_{\vec u},\hat g\rangle is the constant coefficient of the following function.

P^u⃗(X)⋅g^(1/X) \hat P_{\vec u}(X) \cdot \hat g(1/X)

Therefore, the claim ⟨P^u⃗,g^⟩=v\langle \hat P_{\vec u},\hat g\rangle=v is equivalent to the existence of polynomials S^1\hat S_1 and S^2\hat S_2 such that

P^u⃗(X)⋅g^(1/X)=1/X⋅S^1(1/X)+v+X⋅S^2(X). \hat P_{\vec u}(X) \cdot \hat g(1/X) = 1/X \cdot \hat S_1(1/X) + v + X \cdot \hat S_2(X).

Here, S^1\hat S_1 contains the negative-degree terms, while S^2\hat S_2 contains the positive-degree terms. Checking this identity directly would require commitments to both S^1\hat S_1 and S^2\hat S_2. Mercury instead symmetrizes the expression:

P^u⃗(X)⋅g^(1/X)+P^u⃗(1/X)⋅g^(X)=2v+X⋅S^(X)+1/X⋅S^(1/X) \hat P_{\vec u}(X) \cdot \hat g(1/X) + \hat P_{\vec u}(1/X) \cdot \hat g(X) = 2v+X \cdot \hat S(X)+1/X \cdot \hat S(1/X)

Thus, the prover only needs to commit to one polynomial S^\hat S and the inner product claim reduces to checking the above identity at a random point.

We now apply this observation to the following two multilinear evaluation claims from the previous section.

g(u⃗L)=?h^(α)andh(u⃗R)=?v g(\vec u_L)\stackrel{?}{=}\hat h(\alpha) \quad \text{and} \quad h(\vec u_R)\stackrel{?}{=}v

We first reduce these multilinear evaluation claims to the following inner product claims.

⟨g^,P^u⃗L⟩=?h^(α)and⟨h^,P^u⃗R⟩=?v \left\langle \hat g,\hat P_{\vec u_L}\right\rangle \stackrel{?}{=} \hat h(\alpha) \quad\text{and}\quad \left\langle \hat h,\hat P_{\vec u_R}\right\rangle \stackrel{?}{=} v

Mercury batches the two inner product claims using a random challenge γ∈F\gamma\in\mathbb F. The prover constructs a polynomial S^\hat S satisfying

g^(X)⋅P^u⃗L(1/X)+g^(1/X)⋅P^u⃗L(X)+γ⋅(h^(X)⋅P^u⃗R(1/X)+h^(1/X)⋅P^u⃗R(X))=2(h^(α)+γ⋅v)+X⋅S^(X)+1/X⋅S^(1/X) \begin{aligned} \hat g(X) \cdot \hat P_{\vec u_L}(1/X) &+\hat g(1/X) \cdot \hat P_{\vec u_L}(X) + \gamma \cdot \left( \hat h(X) \cdot \hat P_{\vec u_R}(1/X) +\hat h(1/X) \cdot \hat P_{\vec u_R}(X) \right)\\ &= 2\left(\hat h(\alpha)+\gamma \cdot v\right) +X \cdot \hat S(X)+1/X \cdot \hat S(1/X) \end{aligned}

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∗z \in \mathbb{F}^*.

The last remaining piece is the degree check protocol, which ensures deg⁡(g^)<T\deg(\hat g) < T. We examine it next.

Degree Check Protocol#

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\deg(\hat g) < T. The prover defines

D^(X)=XT−1⋅g^(1/X). \hat D(X)=X^{T-1} \cdot \hat g(1/X).

To see why this enforces the degree bound, write g^(X)=∑i=0dgiXi\hat g(X)=\sum_{i=0}^{d}g_iX^i. Then,

D^(X)=XT−1g^(1/X)=∑i=0dgiXT−1−i. \hat D(X) =X^{T-1}\hat g(1/X) =\sum_{i=0}^{d}g_iX^{T-1-i}.

If d<Td < T, every exponent is nonnegative, so D^\hat D is a polynomial. If d≥Td\geq T, the term gdXT−1−dg_dX^{T-1-d} has a negative exponent, so D^\hat D is not a polynomial. A dishonest prover could still commit to an unrelated polynomial D^\hat D, so the verifier must bind the committed D^\hat D to XT−1g^(1/X)X^{T-1}\hat g(1/X) using the following identity at a random nonzero point z∈F∗z\in\mathbb F^*.

D^(z)=?zT−1⋅g^(1/z) \hat D(z)\stackrel{?}{=}z^{T-1} \cdot \hat g(1/z)

We have all the pieces required to describe the complete end-to-end protocol.

End-To-End Protocol#

The public inputs are the original univariate KZG commitment C=[f^(τ)]1C=\left[\hat f(\tau)\right]_1, the evaluation point u⃗=(u⃗L,u⃗R)\vec u=(\vec u_L,\vec u_R) and the claimed evaluation vv. The prover’s witness is the multilinear polynomial ff.

  1. Commit to the large fold. The prover computes

    h^(X)=∑i=0T−1eq⁡(i⃗,u⃗L)⋅f^i(X) \hat h(X) = \sum_{i=0}^{T-1} \operatorname{eq}(\vec{i},\vec u_L) \cdot \hat f_i(X)

    and sends its univariate KZG commitment Ch=[h^(τ)]1C_h=\left[\hat h(\tau)\right]_1 to the verifier.

  2. Commit to the quotient and remainder. The verifier samples α←$F\alpha\xleftarrow{\raisebox{0pt}{\textdollar}}\mathbb F and sends it to the prover. The prover computes

    f^(X)=(XT−α)⋅q^(X)+g^(X),deg⁡(g^)<T \hat f(X) = (X^T-\alpha) \cdot \hat q(X)+\hat g(X), \qquad \deg(\hat g) < T

    and sends

    Cq=[q^(τ)]1andCg=[g^(τ)]1. C_q=\left[\hat q(\tau)\right]_1 \qquad\text{and}\qquad C_g=\left[\hat g(\tau)\right]_1.
  3. Commit to the batched inner product proof and degree check. The verifier samples a random batching challenge γ←$F\gamma\xleftarrow{\raisebox{0pt}{\textdollar}}\mathbb F. The prover computes S^\hat S such that

    g^(X)⋅P^u⃗L(1/X)+g^(1/X)⋅P^u⃗L(X)+γ⋅(h^(X)⋅P^u⃗R(1/X)+h^(1/X)⋅P^u⃗R(X))=2(h^(α)+γ⋅v)+X⋅S^(X)+1/X⋅S^(1/X) \begin{aligned} \hat g(X) \cdot \hat P_{\vec u_L}(1/X) &+\hat g(1/X) \cdot \hat P_{\vec u_L}(X) + \gamma \cdot \left( \hat h(X) \cdot \hat P_{\vec u_R}(1/X) +\hat h(1/X) \cdot \hat P_{\vec u_R}(X) \right)\\ &= 2\left(\hat h(\alpha)+\gamma \cdot v\right) +X \cdot \hat S(X)+1/X \cdot \hat S(1/X) \end{aligned}

    and D^\hat D such that

    D^(X)=XT−1g^(1/X). \hat D(X)=X^{T-1}\hat g(1/X).

    It sends the commitments

    CS=[S^(τ)]1andCD=[D^(τ)]1. C_S=\left[\hat S(\tau)\right]_1 \qquad\text{and}\qquad C_D=\left[\hat D(\tau)\right]_1.
  4. Open the committed polynomials. The verifier samples a random nonzero challenge z←$F∗z\xleftarrow{\raisebox{0pt}{\textdollar}}\mathbb F^*. The prover sends

    gz=g^(z),gˉz=g^(1/z),hz=h^(z),hˉz=h^(1/z),Sz=S^(z),Sˉz=S^(1/z). \begin{aligned} g_z&=\hat g(z), & \bar g_z&=\hat g(1/z),\\ h_z&=\hat h(z), &\bar h_z&=\hat h(1/z),\\ S_z&=\hat S(z), & \bar S_z&=\hat S(1/z). \end{aligned}

    From these values, the verifier computes the expected evaluation of D^\hat D at zz as

    Dz=zT−1gˉz, D_z=z^{T-1}\bar g_z,

    and recovers the expected evaluation of h^\hat h at α\alpha from the batched inner product identity:

    hα=12(gzP^u⃗L(1/z)+gˉzP^u⃗L(z)+γ(hzP^u⃗R(1/z)+hˉzP^u⃗R(z)−2v)−zSz−(1/z)Sˉz) \begin{aligned} h_\alpha =\frac{1}{2}\Big(& g_z\hat P_{\vec u_L}(1/z) +\bar g_z\hat P_{\vec u_L}(z)\\ &+\gamma\big( h_z\hat P_{\vec u_R}(1/z) +\bar h_z\hat P_{\vec u_R}(z)-2v \big)\\ &-zS_z-(1/z)\bar S_z \Big) \end{aligned}
  5. Prove the division identity. The prover computes

    H^z(X)=f^(X)−(zT−α)q^(X)−gzX−z \hat H_z(X) = \frac{ \hat f(X)-(z^T-\alpha)\hat q(X)-g_z }{X-z}

    and sends the KZG opening proof

    πz=[H^z(τ)]1. \pi_z=\left[\hat H_z(\tau)\right]_1.

    The verifier checks

    e(C−(zT−α)Cq−gz[1]1,[1]2)=?e(πz,[τ]2−z[1]2). e\left( C-(z^T-\alpha)C_q-g_z[1]_1, [1]_2 \right) \stackrel{?}{=} e\left( \pi_z, [\tau]_2-z[1]_2 \right).

    This checks the division identity at the random point zz.

  6. Prove the remaining evaluations. The prover sends a batched univariate KZG proof πbatch\pi_{\mathrm{batch}} for

    g^(z)=gz,g^(1/z)=gˉz,h^(z)=hz,h^(1/z)=hˉz,S^(z)=Sz,S^(1/z)=Sˉz,D^(z)=Dz,h^(α)=hα. \begin{aligned} \hat g(z)&=g_z, &\hat g(1/z)&=\bar g_z,\\ \hat h(z)&=h_z, &\hat h(1/z)&=\bar h_z,\\ \hat S(z)&=S_z, &\hat S(1/z)&=\bar S_z,\\ \hat D(z)&=D_z, &\hat h(\alpha)&=h_\alpha. \end{aligned}

    These claims can be combined using the batched univariate KZG opening protocol from Part I. The verifier accepts if the division check and the batched opening proof are both valid.

Complexity of the Protocol#

For an nn-variate multilinear polynomial with N=2nN=2^n coefficients and T=2n/2=NT=2^{n/2}=\sqrt 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 nn. Assuming that a group element is encoded using two field elements, the proof size is O(1)O(1) field elements.

  • Prover Cost: Major prover costs involve: - Computing the quotient q^\hat q and remainder g^\hat g requires O(N)=O(2n)O(N)=O(2^n) field operations. - Computing the commitment to the polynomial H^z\hat H_z, which has at most NN coefficients. So computing the commitment πz\pi_z requires at most N=2nN=2^n group scalar multiplications.

  • Verifier Cost: The verifier evaluates P^u⃗L\hat P_{\vec u_L} and P^u⃗R\hat P_{\vec u_R} and computes the required powers of zz using O(n)O(n) field operations. Since the number of commitments is constant, it performs O(1)O(1) group scalar multiplications and two pairing terms.

The opening costs can be summarized as follows:

ComponentCost
Proof sizeO(1)O(1) field elements
Prover workO(2n)O(2^n) field operations, O(2n)O(2^n) group scalar mults
Verifier workO(n)O(n) field operations, O(1)O(1) group scalar mults, two pairing terms

Conclusion#

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.

Overview of the Variants of KZG series
  • 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.