Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

GKR protocol

Introduction

Building on our exploration of the sum-check protocol, multilinear extensions, and arithmetic circuits, we are now ready to present the GKR protocol in full. Originally introduced by Goldwasser, Kalai, and Rothblum 12, and refined by many authors since, GKR is a cornerstone of modern interactive proofs for verifying circuit computations. This notebook assembles the objects and identities from the previous notebooks and shows how they combine into the protocol itself. We follow Thaler’s presentation 3.

Worked Example

We proceed via a complete worked example. It serves two purposes: (i) to summarize the key objects (multilinear extensions, wiring predicates, Thaler’s identity), and (ii) to illustrate the recurring GKR pattern: run sum-check on Thaler’s identity, then apply a folding step that converts a claim about two values into a single claim at a fresh random point.

No example small enough to compute fully by hand can showcase GKR’s asymptotic savings: our toy computation is trivial, while the protocol machinery is comparatively elaborate. The value of the example is conceptual. Later we will discuss complexity and explain why, for large circuits, the verifier’s work in GKR is asymptotically far smaller than re-evaluating the circuit.

Example 1 [setup and arithmetic circuit]. Work over the field F=Z/pZ\mathbb{F} = \mathbb{Z}/p\mathbb{Z}, where p=2311p = 2^{31} - 1 is the eighth Mersenne prime. Consider the 4-variate polynomial

PF[X0,X1,X2,X3],P(X0,X1,X2,X3):=X0X1+X2+X3.P \in \mathbb{F}[X_0,X_1,X_2,X_3], \quad P(X_0,X_1,X_2,X_3) := X_0X_1 + X_2 + X_3.

For instance,

P(3,2,4,1)(32)+(4+1)11modp.P(3,2,4,1) \equiv (3\cdot 2) + (4 + 1) \equiv 11 \bmod p.

We represent this computation by a constant-input, binary, strictly layered arithmetic circuit CC of size 7 and depth d=2d = 2:

In this example, Layer i has size Si=2iS_i = 2^i, hence bit-length si=log2Si=is_i = \lceil \log_2 S_i\rceil = i for i{0,1,2}i \in \{0,1,2\}. (For general circuits, sis_i need not equal ii.)

We label the gates in Layer i using bitstrings of length sis_i as follows:

from gkr.ac import ArithmeticCircuit

expression_01 = '(3*2) + (4 + 1)'
gkr_01 = ArithmeticCircuit(expression_01, prime=2**31 - 1)
display(gkr_01.graphviz_circuit_bitstring)
Loading...

Gate-value functions. For each layer i{0,,d}i \in \{0,\ldots,d\}, the gate-value function

Wi:{0,1}siFW_i : \{0,1\}^{s_i} \to \mathbb{F}

records the value at each gate. By multilinear interpolation on the Boolean hypercube, each WiW_i has a unique multilinear extension

W~i:FsiF.\widetilde{W}_i : \mathbb{F}^{s_i} \to \mathbb{F}.

Example 1 [gate-value functions]. In our example,

W2(0,0)=3,W2(0,1)=2,W2(1,0)=4,W2(1,1)=1,W1(0)=6,W1(1)=5,W0()=11.\begin{align} W_2(0,0) &= 3, & W_2(0,1) &= 2, & W_2(1,0) &= 4, & W_2(1,1) &= 1,\\ W_1(0) &= 6, & W_1(1) &= 5,\\ W_0(\emptyset) &= 11. \end{align}

These admit the multilinear extensions (computed explicitly below)

W~2(v0,v1)=2v0v1+v0v1+3,W~1(v)=6v,W~0()=11.\widetilde{W}_2(v_0,v_1) = -2v_0v_1 + v_0 - v_1 + 3,\qquad \widetilde{W}_1(v) = 6 - v,\qquad \widetilde{W}_0(\emptyset) = 11.

For instance,

W~2(1,1)=2(11)+11+31modp,\widetilde{W}_2(1,1) = -2(1\cdot 1) + 1 - 1 + 3 \equiv 1 \bmod p,

matching W2(1,1)W_2(1,1).

Wiring predicates. For i{0,,d1}i \in \{0,\ldots,d-1\}, define wiring predicates

addi,multi:{0,1}si×{0,1}si+1×{0,1}si+1{0,1},\mathrm{add}_i,\,\mathrm{mult}_i : \{0,1\}^{s_i} \times \{0,1\}^{s_{i+1}} \times \{0,1\}^{s_{i+1}} \to \{0,1\},

encoding the circuit topology. Concretely, addi(c,a,b)=1\mathrm{add}_i(\mathbf{c},\mathbf{a},\mathbf{b}) = 1 iff c\mathbf{c} is an addition gate whose two children are a\mathbf{a} and b\mathbf{b}, and ab\mathbf{a} \le \mathbf{b} (lexicographic order). Similarly for multi\mathrm{mult}_i. Each wiring predicate has a unique multilinear extension

add~i,mult~i:Fsi×Fsi+1×Fsi+1F.\widetilde{\mathrm{add}}_i,\,\widetilde{\mathrm{mult}}_i : \mathbb{F}^{s_i} \times \mathbb{F}^{s_{i+1}} \times \mathbb{F}^{s_{i+1}} \to \mathbb{F}.

Example 1 [wiring predicates]. In our circuit,

add0(,0,1)=1,mult1(0,(0,0),(0,1))=1,add1(1,(1,0),(1,1))=1,\mathrm{add}_0(\emptyset,0,1) = 1,\quad \mathrm{mult}_1(0,(0,0),(0,1)) = 1,\quad \mathrm{add}_1(1,(1,0),(1,1)) = 1,

and all other values are zero. The multilinear extensions are:

add~0(,x,y)=(1x)y,mult~0(,x,y)=0,add~1(z,(x0,x1),(y0,y1))=zx0(1x1)y0y1,mult~1(z,(x0,x1),(y0,y1))=(1z)(1x0)(1x1)(1y0)y1.\begin{align} \widetilde{\mathrm{add}}_0(\emptyset,x,y) &= (1-x)y,\\ \widetilde{\mathrm{mult}}_0(\emptyset,x,y) &= 0,\\ \widetilde{\mathrm{add}}_1(z,(x_0,x_1),(y_0,y_1)) &= zx_0(1-x_1)y_0y_1,\\ \widetilde{\mathrm{mult}}_1(z,(x_0,x_1),(y_0,y_1)) &= (1-z)(1-x_0)(1-x_1)(1-y_0)y_1. \end{align}

Gate propagation and Thaler’s identity. The circuit semantics are captured by the layer-wise gate propagation equation: for i{0,,d1}i \in \{0,\ldots,d-1\} and z{0,1}si\mathbf{z}\in\{0,1\}^{s_i},

Wi(z)=x{0,1}si+1y{0,1}si+1{addi(z,x,y)[Wi+1(x)+Wi+1(y)]+multi(z,x,y)[Wi+1(x)Wi+1(y)]}.W_i(\mathbf{z}) = \sum_{\substack{\mathbf{x}\in\{0,1\}^{s_{i+1}}\\ \mathbf{y}\in\{0,1\}^{s_{i+1}}}} \Big\{ \mathrm{add}_i(\mathbf{z},\mathbf{x},\mathbf{y})\big[W_{i+1}(\mathbf{x})+W_{i+1}(\mathbf{y})\big] + \mathrm{mult}_i(\mathbf{z},\mathbf{x},\mathbf{y})\big[W_{i+1}(\mathbf{x})W_{i+1}(\mathbf{y})\big] \Big\}.

Thaler’s identity is the multilinear-extension analogue: for i{0,,d1}i \in \{0,\ldots,d-1\} and zFsi\mathbf{z}\in\mathbb{F}^{s_i},

W~i(z)=x{0,1}si+1y{0,1}si+1{add~i(z,x,y)[W~i+1(x)+W~i+1(y)]+mult~i(z,x,y)[W~i+1(x)W~i+1(y)]}.\widetilde{W}_i(\mathbf{z}) = \sum_{\substack{\mathbf{x}\in\{0,1\}^{s_{i+1}}\\ \mathbf{y}\in\{0,1\}^{s_{i+1}}}} \Big\{ \widetilde{\mathrm{add}}_i(\mathbf{z},\mathbf{x},\mathbf{y})\big[\widetilde{W}_{i+1}(\mathbf{x})+\widetilde{W}_{i+1}(\mathbf{y})\big] + \widetilde{\mathrm{mult}}_i(\mathbf{z},\mathbf{x},\mathbf{y})\big[\widetilde{W}_{i+1}(\mathbf{x})\widetilde{W}_{i+1}(\mathbf{y})\big] \Big\}.

Example 1 [layer-wise gate propagation and Thaler’s identity]. In our example, (2) expands to

11=x{0,1}y{0,1}(1x)y[(6x)+(6y)].11 = \sum_{x\in\{0,1\}} \sum_{y\in\{0,1\}} (1-x)y\big[(6-x)+(6-y)\big].

and

6z=x0{0,1}x1{0,1}y0{0,1}y1{0,1}{zx0(1x1)y0y1[(2x0x1+x0x1+3)+(2y0y1+y0y1+3)]+  (1z)(1x0)(1x1)(1y0)y1[(2x0x1+x0x1+3)(2y0y1+y0y1+3)]}.\begin{align} 6 - z &= \sum_{x_0\in\{0,1\}}\sum_{x_1\in\{0,1\}}\sum_{y_0\in\{0,1\}}\sum_{y_1\in\{0,1\}} \Big\{ zx_0(1-x_1)y_0y_1\big[(-2x_0x_1+x_0-x_1+3)+(-2y_0y_1+y_0-y_1+3)\big] \notag \\ &\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad + \; (1-z)(1-x_0)(1-x_1)(1-y_0)y_1\big[(-2x_0x_1+x_0-x_1+3)(-2y_0y_1+y_0-y_1+3)\big] \Big\}. \end{align}

What is being verified? The circuit CC (including its wiring predicates) is public. The prover’s private information is the collection of intermediate gate values, equivalently the functions WiW_i. In the single-output setting, the prover’s top-level claim is simply that the output gate evaluates to a particular field element (here, 11).

More generally, Layer 0 may contain multiple output gates. We label the S0S_0 outputs by {0,1}s0\{0,1\}^{s_0}, and the function

W0:{0,1}s0FW_0 : \{0,1\}^{s_0}\to\mathbb{F}

encodes all outputs at once. The prover’s claim is that the true output function W0W_0 equals a purported function W0W_0^* (equivalently, W~0=W~0\widetilde{W}_0=\widetilde{W}_0^* as polynomial functions).

The verifier does not check equality at all points. Instead, they sample a uniformly random ρ0Fs0\rho_0\in\mathbb{F}^{s_0} and check equality at that point:

W~0(ρ0)=W~0(ρ0).\widetilde{W}_0(\rho_0) = \widetilde{W}_0^*(\rho_0).

If W~0W~0\widetilde{W}_0\neq \widetilde{W}_0^*, then W~0W~0\widetilde{W}_0-\widetilde{W}_0^* is a nonzero multilinear polynomial function (degree s0\le s_0), so by Schwartz-Zippel,

Pr[W~0(ρ0)=W~0(ρ0)]=Pr[(W~0W~0)(ρ0)=0]s0#F.\Pr\big[\widetilde{W}_0(\rho_0)=\widetilde{W}_0^*(\rho_0)\big] = \Pr\big[(\widetilde{W}_0-\widetilde{W}_0^*)(\rho_0)=0\big] \le \frac{s_0}{\#\mathbb{F}}.

Thus, a match at a random point gives strong evidence that all output gates are correct.

From Thaler’s identity to GKR. Fix a layer ii. The verifier does not try to check (2) for all zFsi\mathbf{z}\in\mathbb{F}^{s_i}. Instead, they sample a random point ρiFsi\rho_i\in\mathbb{F}^{s_i} and ask the prover to justify (2) at z=ρi\mathbf{z}=\rho_i.

Once ρi\rho_i is fixed, the right-hand side of (2) becomes a polynomial function in the 2si+12s_{i+1} Boolean variables (x,y)(\mathbf{x},\mathbf{y}). The prover and verifier then run sum-check over these variables. At the end of sum-check, the verifier is left with a small number of claimed values of W~i+1\widetilde{W}_{i+1}; the folding step compresses these into a single new claim about W~i+1\widetilde{W}_{i+1} at a fresh random point ρi+1\rho_{i+1}.

As in the sum-check notebook, we distinguish circuit-determined objects from prover-asserted objects. We use ()(\cdot)^* (e.g. W~i\widetilde{W}_i^*) for prover claims, which may be false. For clarity, we sometimes use the notation   =?  \;\overset{?}{=}\; for an equality that may not hold if P is dishonest. Unadorned symbols refer to the true objects induced by the circuit. For readability, we reuse symbols like the verifier challenges rjr_j and the prover’s round polynomials gjg_j across different sum-check invocations; they are “reset” each time a new sum-check begins.

GKR Layer 0. The parties are the verifier V and the prover P. V samples ρ0Fs0\rho_0 \leftarrow \mathbb{F}^{s_0}. Define

g(x,y):=add~0(ρ0,x,y)[W~1(x)+W~1(y)]+mult~0(ρ0,x,y)[W~1(x)W~1(y)],g(\mathbf{x},\mathbf{y}) := \widetilde{\mathrm{add}}_0(\rho_0,\mathbf{x},\mathbf{y})\big[\widetilde{W}_{1}(\mathbf{x})+\widetilde{W}_{1}(\mathbf{y})\big] + \widetilde{\mathrm{mult}}_0(\rho_0,\mathbf{x},\mathbf{y})\big[\widetilde{W}_{1}(\mathbf{x})\widetilde{W}_{1}(\mathbf{y})\big],

the summand in (2) when i=0i=0 and z=ρ0\mathbf{z}=\rho_0. Thus,

W~0(ρ0)=(x,y){0,1}s1×{0,1}s1g(x,y).\widetilde{W}_0(\rho_0) = \sum_{(\mathbf{x},\mathbf{y})\in \{0,1\}^{s_1}\times \{0,1\}^{s_1}} g(\mathbf{x},\mathbf{y}).

Moreover degg4s1\deg g \le 4s_1: the wiring polynomials have degree 2s1\le 2s_1, the multilinear extensions W~1(x)\widetilde{W}_1(\mathbf{x}) and W~1(y)\widetilde{W}_1(\mathbf{y}) have degree s1\le s_1, and the worst case comes from the product term. (In general Layer ii, the same reasoning gives degg4si+1\deg g \le 4s_{i+1}.)

The protocol runs sum-check on (6) (with the prover’s possibly false claim for W~0(ρ0)\widetilde{W}_0(\rho_0) on the left-hand side), with one crucial twist at the final step: instead of having V evaluate g(rx,ry)g(r_x,r_y) directly, GKR uses claimed values of W~1\widetilde{W}_1 and then folds them into a single new claim.

Example 1 [GKR Layer 0]. Here s0=0s_0=0, so Fs0={}\mathbb{F}^{s_0}=\{\emptyset\} and ρ0=\rho_0=\emptyset. Also s1=1s_1=1, and from (3) we set

g(x,y):=(1x)y[(6x)+(6y)].g(x,y) := (1-x)y\big[(6-x)+(6-y)\big].

To see how cheating is forced to “thread the needle”, suppose P falsely claims that W~0(ρ0)\widetilde{W}_0(\rho_0) equals 10 (the truth is 11). The sum-check claim is

W~0(ρ0)=?x,y{0,1}g(x,y),\widetilde{W}_0^*(\rho_0) \overset{?}{=} \sum_{x,y\in\{0,1\}} g(x,y),

which is true iff the left-hand side equals 11. Since P insists on W~0(ρ0)=10\widetilde{W}_0^*(\rho_0) = 10, they must lie consistently, and later they will still need luck to avoid detection.

Sum-check Round 0.0. Define

g0(u0):=y{0,1}g(u0,y)=g(u0,0)+g(u0,1),g_0(u_0) := \sum_{y\in\{0,1\}} g(u_0,y) = g(u_0,0)+g(u_0,1),

so that, as W~0\widetilde{W}_0 and g0g_0 are ground-truth polynomial functions, W~0(ρ0)=g0(0)+g0(1)\widetilde{W}_0(\rho_0)=g_0(0)+g_0(1). P sends g0g_0^*, and V checks:

  1. degg04s1=4\deg g_0^* \le 4s_1 = 4,

  2. W~0(ρ0)=g0(0)+g0(1)\widetilde{W}_0^*(\rho_0)=g_0^*(0)+g_0^*(1).

If both pass, V samples r0Fr_0\leftarrow\mathbb{F} and sends it to P.

In truth, g0(u0)=(1u0)(11u0)g_0(u_0)=(1-u_0)(11-u_0), but V does not know this. To satisfy the checks while forcing g0(0)+g0(1)=10g_0^*(0)+g_0^*(1)=10, P can pick (for example)

g0(u0):=2u0(u07)+11,g_0^*(u_0) := 2u_0(u_0-7)+11,

since

g0(0)+g0(1)=11+(2(6)+11)=10=W~0().g_0^*(0)+g_0^*(1) = 11 + \big(2(-6)+11\big)=10=\widetilde{W}_0^*(\emptyset).

Suppose V chooses r0=17r_0=17.

Sum-check Round 0.1. Define g1(u1):=g(r0,u1)g_1(u_1):=g(r_0,u_1), so g0(r0)=g1(0)+g1(1)g_0(r_0)=g_1(0)+g_1(1). P sends g1g_1^*, and V checks:

  1. degg14\deg g_1^* \le 4,

  2. g0(r0)=g1(0)+g1(1)g_0^*(r_0)=g_1^*(0)+g_1^*(1).

If both pass, V samples r1Fr_1\leftarrow\mathbb{F} and sends it to P.

Since r0=17r_0=17, the truth is

g1(u1)=g(17,u1)=(117)u1[617+6u1]=16u1(5+u1),g_1(u_1)=g(17,u_1)=(1-17)u_1\big[6-17+6-u_1\big]=16u_1(5+u_1),

but P can instead claim

g1(u1):=u1(17u1+334),g_1^*(u_1):=u_1(17u_1+334),

which satisfies

g1(0)+g1(1)=351=217(177)+11=g0(17).g_1^*(0)+g_1^*(1)=351=2\cdot 17(17-7)+11=g_0^*(17).

Suppose V chooses r1=42r_1=42.

Sum-check final check (where GKR diverges). In standalone sum-check, V would check g1(r1)=?g(r0,r1)g_1^*(r_1)\overset{?}{=}g(r_0,r_1), but in GKR V does not directly evaluate g(r0,r1)g(r_0,r_1).

Instead, define

z0:=W~1(r0),z1:=W~1(r1),z_0 := \widetilde{W}_1(r_0),\qquad z_1 := \widetilde{W}_1(r_1),

and P supplies claimed values z0,z1z_0^*,z_1^* asserted to equal z0,z1z_0,z_1.

In our example, the ground truth is

z0=W~1(17)=617=11,z1=W~1(42)=642=36,z_0 = \widetilde{W}_1(17)=6-17=-11,\qquad z_1 = \widetilde{W}_1(42)=6-42=-36,

and also

g(r0,r1)=g(17,42)=1642(5+42)=1974,g(r_0,r_1)=g(17,42)=16\cdot 42(5+42)=1974,

whereas

g1(r1)=g1(42)=42(1742+334)=44016,g_1^*(r_1)=g_1^*(42)=42(17\cdot 42+334)=44016,

so standalone sum-check would reject. GKR postpones this evaluation and moves to folding.

At this point, V has reduced a claim about W~0\widetilde{W}_0 to two claimed values of W~1\widetilde{W}_1. Recursing naïvely would cause a blow-up. Folding avoids this by compressing two claims into one.

GKR folding at Layer 0. At the end of the Layer 0 sum-check, V is left to verify

g2s11(r2s11)=?g(rx,ry),g_{2s_1-1}^*(r_{2s_1-1}) \overset{?}{=} g(r_x,r_y),

where

rx=(r0,,rs11)Fs1,ry=(rs1,,r2s11)Fs1r_x=(r_0,\ldots,r_{s_1-1})\in\mathbb{F}^{s_1},\qquad r_y=(r_{s_1},\ldots,r_{2s_1-1})\in\mathbb{F}^{s_1}

are the verifier challenge vectors from the 2s12s_1 rounds. P supplies claimed values

W~1(rx)=claimPz0,W~1(ry)=claimPz1.\widetilde{W}_1(r_x)\overset{\mathsf{P}}{\underset{\text{claim}}{=}}z_0^*,\qquad \widetilde{W}_1(r_y)\overset{\mathsf{P}}{\underset{\text{claim}}{=}}z_1^*.

Together, (5), (7), and (8) amount to the “bridging” equation

g2s11(r2s11)=?add~0(ρ0,rx,ry)[z0+z1]+mult~0(ρ0,rx,ry)[z0z1].g_{2s_1-1}^*(r_{2s_1-1}) \overset{?}{=} \widetilde{\mathrm{add}}_0(\rho_0,r_x,r_y)\big[z_0^*+z_1^*\big] + \widetilde{\mathrm{mult}}_0(\rho_0,r_x,r_y)\big[z_0^*z_1^*\big].

Since the circuit is public, V can evaluate add~0\widetilde{\mathrm{add}}_0 and mult~0\widetilde{\mathrm{mult}}_0 at any point, so V checks (9) and rejects if it fails.

Now fold the two claims in (8) into a single claim. Define the affine line :FFs1\ell:\mathbb{F}\to\mathbb{F}^{s_1} by

(t):=(1t)rx+try,\ell(t):=(1-t)r_x + t r_y,

and define the associated univariate polynomial function q1:FFq_1 : \mathbb{F} \to \mathbb{F} by

q1(t):=W~1((t)).q_1(t):=\widetilde{W}_1(\ell(t)).

By construction, q1(0)=W~1(rx)q_1(0)=\widetilde{W}_1(r_x) and q1(1)=W~1(ry)q_1(1)=\widetilde{W}_1(r_y).

P sends a univariate polynomial function q1q_1^*, purported to equal q1q_1. V checks:

  1. degq1s1\deg q_1^* \le s_1,

  2. q1(0)=z0q_1^*(0)=z_0^* and q1(1)=z1q_1^*(1)=z_1^*.

If these checks pass, V samples τ1F\tau_1\leftarrow\mathbb{F} and sets

ρ1:=(τ1)Fs1.\rho_1 := \ell(\tau_1)\in\mathbb{F}^{s_1}.

In an honest execution, q1q^*_1 is the true q1q_1, and hence q1(τ1)q_1^*(\tau_1) is equal to W~1(ρ1)\widetilde{W}_1(\rho_1). Thus the two claims in (8) have been reduced to a single claim about W~1\widetilde{W}_1 at the random point ρ1\rho_1. The protocol then proceeds to Layer 1.

Example 1 [GKR folding at Layer 0]. In this example, rx=r0r_x=r_0 and ry=r1r_y=r_1. P supplies z0,z1z_0^*,z_1^*, and V checks

g1(r1)=?(1r0)r1[z0+z1].g_1^*(r_1) \overset{?}{=} (1-r_0)r_1\big[z_0^*+z_1^*\big].

Define \ell as in (10) and q1q_1 as in (11). Here (t)=(1t)r0+tr1\ell(t)=(1-t)r_0+tr_1 and q1(t)=W~1((t))=6(t)q_1(t)=\widetilde{W}_1(\ell(t))=6-\ell(t). P sends q1q_1^* and V checks the endpoint constraints (and degq11\deg q_1^*\le 1). Then V samples τ1F\tau_1\leftarrow\mathbb{F} and defines ρ1=(τ1)\rho_1=\ell(\tau_1) as in (12). In an honest execution, q1(τ1)q_1^*(\tau_1) equals W~1(ρ1)\widetilde{W}_1(\rho_1), and by Thaler’s identity this equals

q1(τ1)=?x0{0,1}x1{0,1}y0{0,1}y1{0,1}{ρ1x0(1x1)y0y1[(2x0x1+x0x1+3)+(2y0y1+y0y1+3)]+  (1ρ1)(1x0)(1x1)(1y0)y1[(2x0x1+x0x1+3)(2y0y1+y0y1+3)]}.\begin{align} q_1^*(\tau_1) &\overset{?}{=} \sum_{x_0\in\{0,1\}}\sum_{x_1\in\{0,1\}}\sum_{y_0\in\{0,1\}}\sum_{y_1\in\{0,1\}} \Big\{ \rho_1 x_0(1-x_1)y_0y_1\big[(-2x_0x_1+x_0-x_1+3)+(-2y_0y_1+y_0-y_1+3)\big] \notag \\ &\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad + \; (1-\rho_1)(1-x_0)(1-x_1)(1-y_0)y_1\big[(-2x_0x_1+x_0-x_1+3)(-2y_0y_1+y_0-y_1+3)\big] \Big\}. \end{align}

With the concrete values above, (r0,r1)=(17,42)(r_0,r_1)=(17,42) and g1(r1)=44016g_1^*(r_1)=44016. To satisfy (13), P must choose z0,z1z_0^*,z_1^* with

z0z1g1(r1)[(1r0)r1]1modp.z_0^*z_1^* \equiv g_1^*(r_1)\big[(1-r_0)r_1\big]^{-1}\bmod p.

Since [(117)42]1405848844modp\big[(1-17)\cdot 42\big]^{-1}\equiv 405848844\bmod p, one possible choice is

z0=255440969,z1=150407875.z_0^* = 255440969,\qquad z_1^* = 150407875.

Then P can define q1(t):=(1t)z0+tz1q_1^*(t):=(1-t)z_0^*+t z_1^*, which automatically satisfies the endpoint checks.

Suppose V chooses τ1=3\tau_1=3. Then ρ1=(3)=92\rho_1=\ell(3)=92, and the truth is q1(3)=W~1(92)=692=86q_1(3)=\widetilde{W}_1(92)=6-92=-86, whereas

q1(3)=25544096910503309432087825334modp.q_1^*(3)=255440969-105033094\cdot 3 \equiv 2087825334 \bmod p.

Thus in the next sum-check (Layer 1), P is forced to justify the false claim

2087825334=?x0{0,1}x1{0,1}y0{0,1}y1{0,1}{92x0(1x1)y0y1[(2x0x1+x0x1+3)+(2y0y1+y0y1+3)]+  (192)(1x0)(1x1)(1y0)y1[(2x0x1+x0x1+3)(2y0y1+y0y1+3)]}.\begin{align} 2087825334 &\overset{?}{=} \sum_{x_0\in\{0,1\}}\sum_{x_1\in\{0,1\}}\sum_{y_0\in\{0,1\}}\sum_{y_1\in\{0,1\}} \Big\{ 92 x_0(1-x_1)y_0y_1\big[(-2x_0x_1+x_0-x_1+3)+(-2y_0y_1+y_0-y_1+3)\big] \notag \\ &\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad + \; (1-92)(1-x_0)(1-x_1)(1-y_0)y_1\big[(-2x_0x_1+x_0-x_1+3)(-2y_0y_1+y_0-y_1+3)\big] \Big\}. \end{align}

The true value of the right-hand side is 2147483561. V does not know this, but after the Layer 1 sum-check the inconsistency is detected with high probability.

GKR Layer i (1id21 \le i \le d-2). At the start of Layer ii, V holds a point ρiFsi\rho_i\in\mathbb{F}^{s_i} and a claimed value qi(τi)Fq_i^*(\tau_i)\in\mathbb{F}, which (if P is honest) equals W~i(ρi)\widetilde{W}_i(\rho_i). V and P run sum-check to justify Thaler’s identity at z=ρi\mathbf{z}=\rho_i.

Define

g(x,y):=add~i(ρi,x,y)[W~i+1(x)+W~i+1(y)]+mult~i(ρi,x,y)[W~i+1(x)W~i+1(y)],g(\mathbf{x},\mathbf{y}) := \widetilde{\mathrm{add}}_i(\rho_i,\mathbf{x},\mathbf{y})\big[\widetilde{W}_{i+1}(\mathbf{x})+\widetilde{W}_{i+1}(\mathbf{y})\big] + \widetilde{\mathrm{mult}}_i(\rho_i,\mathbf{x},\mathbf{y})\big[\widetilde{W}_{i+1}(\mathbf{x})\widetilde{W}_{i+1}(\mathbf{y})\big],

a polynomial function on Fsi+1×Fsi+1\mathbb{F}^{s_{i+1}}\times\mathbb{F}^{s_{i+1}}. Sum-check is applied to

qi(τi)=?x{0,1}si+1y{0,1}si+1g(x,y).q_i^*(\tau_i) \overset{?}{=} \sum_{\substack{\mathbf{x}\in\{0,1\}^{s_{i+1}}\\ \mathbf{y}\in\{0,1\}^{s_{i+1}}}} g(\mathbf{x},\mathbf{y}).

Let m:=2si+1m:=2s_{i+1}, and identify (x,y)(\mathbf{x},\mathbf{y}) with v=(v0,,vm1)Fmv=(v_0,\ldots,v_{m-1})\in\mathbb{F}^m, where x=(v0,,vsi+11)\mathbf{x}=(v_0,\ldots,v_{s_{i+1}-1}) and y=(vsi+1,,vm1)\mathbf{y}=(v_{s_{i+1}},\ldots,v_{m-1}). The sum-check routine has mm rounds, with verifier challenges r=(r0,,rm1)Fmr=(r_0,\ldots,r_{m-1})\in\mathbb{F}^m. Write rx=(r0,,rsi+11)Fsi+1r_x=(r_0,\ldots,r_{s_{i+1}-1})\in\mathbb{F}^{s_{i+1}} and ry=(rsi+1,,rm1)Fsi+1r_y=(r_{s_{i+1}},\ldots,r_{m-1})\in\mathbb{F}^{s_{i+1}}. As usual, the prover sends round polynomials gjg_j^*, and the verifier checks the degree bound and consistency equations. After the final challenge rm1r_{m-1}, sum-check reduces consistency to gm1(rm1)=g(r0,,rm1)=g(rx,ry)g_{m-1}^*(r_{m-1}) = g(r_0,\ldots,r_{m-1}) = g(r_x,r_y).

Expanding g(rx,ry)g(r_x,r_y) yields

g(rx,ry)=add~i(ρi,rx,ry)[zx+zy]+mult~i(ρi,rx,ry)[zxzy],g(r_x,r_y) = \widetilde{\mathrm{add}}_i(\rho_i,r_x,r_y)\big[z_x+z_y\big] + \widetilde{\mathrm{mult}}_i(\rho_i,r_x,r_y)\big[z_x z_y\big],

where zx:=W~i+1(rx)z_x:=\widetilde{W}_{i+1}(r_x) and zy:=W~i+1(ry)z_y:=\widetilde{W}_{i+1}(r_y).

GKR folding at Layer i. P supplies claimed values zx,zyFz_x^*,z_y^*\in\mathbb{F}. V checks the bridging equation

gm1(rm1)=?add~i(ρi,rx,ry)[zx+zy]+mult~i(ρi,rx,ry)[zxzy],g_{m-1}^*(r_{m-1}) \overset{?}{=} \widetilde{\mathrm{add}}_i(\rho_i,r_x,r_y)\big[z_x^*+z_y^*\big] + \widetilde{\mathrm{mult}}_i(\rho_i,r_x,r_y)\big[z_x^* z_y^*\big],

rejecting if it fails. To fold the two claims into one, define

(t):=(1t)rx+try,\ell(t):=(1-t)r_x + t r_y,

and

qi+1(t):=W~i+1((t)).q_{i+1}(t):=\widetilde{W}_{i+1}(\ell(t)).

Then qi+1(0)=W~i+1(rx)q_{i+1}(0)=\widetilde{W}_{i+1}(r_x) and qi+1(1)=W~i+1(ry)q_{i+1}(1)=\widetilde{W}_{i+1}(r_y). P sends qi+1q_{i+1}^*, and V checks:

  1. degqi+1si+1\deg q_{i+1}^* \le s_{i+1},

  2. qi+1(0)=zxq_{i+1}^*(0)=z_x^* and qi+1(1)=zyq_{i+1}^*(1)=z_y^*.

If these pass, V samples τi+1F\tau_{i+1}\leftarrow\mathbb{F} and defines

ρi+1:=(τi+1)Fsi+1.\rho_{i+1}:=\ell(\tau_{i+1})\in\mathbb{F}^{s_{i+1}}.

In an honest execution, qi+1(τi+1)q_{i+1}^*(\tau_{i+1}) equals W~i+1(ρi+1)\widetilde{W}_{i+1}(\rho_{i+1}). The protocol proceeds to the next layer until reaching d1d-1.

GKR Layer d - 1 (final layer). Layer d1d-1 is handled differently because its child gates lie in the input layer dd. Here the recursion bottoms out: W~d\widetilde{W}_d is fully determined by the public inputs, so the verifier can evaluate W~d\widetilde{W}_d directly.

As before, at the start of Layer d - 1, V holds ρd1Fsd1\rho_{d-1}\in\mathbb{F}^{s_{d-1}} and a claimed value qd1(τd1)q_{d-1}^*(\tau_{d-1}) (honestly W~d1(ρd1)\widetilde{W}_{d-1}(\rho_{d-1})). The parties run sum-check on Thaler’s identity at layer d1d-1, producing challenge vectors rx,ryFsdr_x,r_y\in\mathbb{F}^{s_d} and reducing to a final check of the form g2sd1(r2sd1)=?g(rx,ry)g_{2s_d-1}^*(r_{2s_d-1}) \overset{?}{=} g(r_x,r_y). Unlike earlier layers, V now computes zx=W~d(rx)z_x=\widetilde{W}_d(r_x) and zy=W~d(ry)z_y=\widetilde{W}_d(r_y) directly from the public inputs, and checks the corresponding bridging equation. If it holds, V accepts; otherwise V rejects.

This completes the description of the GKR protocol.

Example 1 [GKR Layer d - 1]. In our example d=2d=2, so the final nontrivial layer is d1=1d-1=1. The input layer has size S2=4S_2=4 and hence s2=2s_2=2. At the end of Layer 0, V holds ρ1Fs1=F\rho_1\in\mathbb{F}^{s_1}=\mathbb{F} and a claimed value q1(τ1)q_1^*(\tau_1), which (if P is honest) equals W~1(ρ1)\widetilde{W}_1(\rho_1). Sum-check at Layer 1 runs for 2s2=42s_2=4 rounds. At the end, V needs to check g3(r3)=?g(r0,r1,r2,r3)g_3^*(r_3)\overset{?}{=}g(r_0,r_1,r_2,r_3). Crucially, since this is the input layer, V can evaluate W~2\widetilde{W}_2 directly:

W~2(r0,r1)=2r0r1+r0r1+3,W~2(r2,r3)=2r2r3+r2r3+3,\widetilde{W}_2(r_0,r_1)=-2r_0r_1+r_0-r_1+3,\qquad \widetilde{W}_2(r_2,r_3)=-2r_2r_3+r_2-r_3+3,

and therefore V can compute the right-hand side g(r0,r1,r2,r3)g(r_0,r_1,r_2,r_3) explicitly and reject if it disagrees with g3(r3)g_3^*(r_3).

Sum-check for Layer 1. Here s2=2s_2 = 2, so the sum-check protocol runs for 2s2=42s_2 = 4 rounds. Recall that the layer-1 claim being justified is the (possibly false) value q1(τ1)q_1^*(\tau_1), which in an honest execution equals W~1(ρ1)\widetilde{W}_1(\rho_1); see the setup in the preceding discussion (in particular, the explicit identity in (14) above).

Sum-check Round 1.0. Define

g0(u0):=x1{0,1}y0{0,1}y1{0,1}g(u0,x1,y0,y1).g_0(u_0) := \sum_{x_1 \, \in \, \{0,1\}} \sum_{y_0 \, \in \, \{0,1\}} \sum_{y_1 \, \in \, \{0,1\}} g(u_0,x_1,y_0,y_1).

For the true g0g_0 and gg, we have g0(0)+g0(1)=g()g_0(0)+g_0(1)=\sum g(\cdot), so the sum-check consistency condition for the prover’s first message is

q1(τ1)=?g0(0)+g0(1).q_1^*(\tau_1) \overset{?}{=} g_0^*(0) + g_0^*(1).

The prover P sends a polynomial g0g_0^*, claiming it is the same as g0g_0. V checks:

  1. degg04s2=8\deg g_0^* \le 4s_2 = 8,

  2. q1(τ1)=g0(0)+g0(1)q_1^*(\tau_1) = g_0^*(0) + g_0^*(1).

If either check fails, V rejects. Otherwise, V samples

r0Fr_0 \leftarrow \mathbb{F}

and sends it to P.

With our specific values (ρ1=92\rho_1 = 92), the true polynomial is

g0(u0)=274u02+732u0+2147483101.g_0(u_0) = 274u_0^2 + 732u_0 + 2147483101.

However, since P is pursuing the false claim from earlier, P must send some different polynomial g0g_0^* that still passes the two checks above. Suppose P chooses

g0(u0)=275u02+2087826151u0+2147483101.g^*_0(u_0) = 275u_0^2 + 2087826151u_0 + 2147483101.

Then the degree bound holds, and in Z/pZ\mathbb{Z}/p\mathbb{Z} we have

g0(0)+g0(1)=2147483101+(275+2087826151+2147483101)=2087825334=q1(τ1).g^*_0(0) + g^*_0(1) = 2147483101 + (275 + 2087826151 + 2147483101) = 2087825334 = q_1^*(\tau_1).

So far, P’s messages are consistent and V does not reject. Suppose V’s random challenge is

r0=99.r_0 = 99.

Sum-check Round 1.1. Define

g1(u1):=y0{0,1}y1{0,1}g(r0,u1,y0,y1),g_1(u_1) := \sum_{y_0 \, \in \, \{0,1\}} \sum_{y_1 \, \in \, \{0,1\}} g(r_0,u_1,y_0,y_1),

so that, as these are the true polynomials,

g0(r0)=g1(0)+g1(1).g_0(r_0) = g_1(0) + g_1(1).

P sends g1g_1^* (claiming it is the same as g1g_1). V checks:

  1. degg18\deg g_1^* \le 8,

  2. g0(r0)=g1(0)+g1(1)g_0^*(r_0) = g_1^*(0) + g_1^*(1).

If the checks pass, V samples

r1Fr_1 \leftarrow \mathbb{F}

and sends it to P.

With our specific values (r0=99r_0 = 99), the true polynomial is

g1(u1)=5361856u12+2139364395u1+2757396.g_1(u_1) = 5361856u_1^2 + 2139364395u_1 + 2757396.

Suppose P instead claims

g1(u1)=5361857u12+528176917u1+2757396.g^*_1(u_1) = 5361857u_1^2 + 528176917u_1 + 2757396.

V verifies the degree bound and the consistency equation by checking (in Z/pZ\mathbb{Z}/p\mathbb{Z})

g0(99)=275(992)+2087826151(99)+2147483101=539053566,g1(0)+g1(1)=2757396+(5361856+2139364395+2757396)=539053566.\begin{align} g^*_0(99) & = 275(99^2) + 2087826151(99) + 2147483101 = 539053566,\\ g^*_1(0) + g^*_1(1) & = 2757396 + (5361856 + 2139364395 + 2757396) = 539053566. \end{align}

Thus the transcript remains consistent so far. Suppose V’s next random challenge is

r1=7.r_1 = 7.

Sum-check Round 1.2. Define

g2(u2):=y1{0,1}g(r0,r1,u2,y1),g_2(u_2) := \sum_{y_1 \, \in \, \{0,1\}} g(r_0,r_1,u_2,y_1),

so that, as these are the true polynomials,

g1(r1)=g2(0)+g2(1).g_1(r_1) = g_2(0) + g_2(1).

P sends g2g_2^* (claiming it is the same as g2g_2). V checks:

  1. degg28\deg g_2^* \le 8,

  2. g1(r1)=g2(0)+g2(1)g_1^*(r_1) = g_2^*(0) + g_2^*(1).

If successful, V samples

r2Fr_2 \leftarrow \mathbb{F}

and sends it to P.

With our specific values (r0,r1)=(99,7)(r_0,r_1)=(99,7), the true polynomial is

g2(u2)=69133476u22+2010688435u2+138157656.g_2(u_2) = 69133476u_2^2 + 2010688435u_2 + 138157656.

Suppose P instead claims this is

g2(u2)=69133477u22+1469794372u2+138157656.g^*_2(u_2) = 69133477u_2^2 + 1469794372u_2 + 138157656.

V verifies the degree bound and the consistency equation by checking (in Z/pZ\mathbb{Z}/p\mathbb{Z})

g1(7)=5361856(7)2+2139364395(7)+2757396=1815243161,g2(0)+g2(1)=138157656+(69133477+1469794372+138157656)=1815243161.\begin{align} g^*_1(7) & = 5361856(7)^2 + 2139364395(7) + 2757396 = 1815243161,\\ g^*_2(0) + g^*_2(1) & = 138157656 + (69133477 + 1469794372 + 138157656) = 1815243161. \end{align}

So V still does not reject. Suppose V’s next random challenge is

r2=1001.r_2 = 1001.

Sum-check Round 1.3. Define

g3(u3):=g(r0,r1,r2,u3),g_3(u_3) := g(r_0,r_1,r_2,u_3),

so that, as these are the true polynomials,

g2(r2)=g3(0)+g3(1).g_2(r_2) = g_3(0) + g_3(1).

P sends g3g_3^* (claiming it is the same as g3g_3). V checks:

  1. degg38\deg g_3^* \le 8,

  2. g2(r2)=g3(0)+g3(1)g_2^*(r_2) = g_3^*(0) + g_3^*(1).

If the checks pass, V samples

r3Fr_3 \leftarrow \mathbb{F}

and sends it to P.

With our specific values (r0,r1,r2)=(99,7,1001)(r_0,r_1,r_2)=(99,7,1001), the true polynomial is

g3(u3)=421362090u32+655825959u3.g_3(u_3) = 421362090u_3^2 + 655825959u_3.

Suppose P instead claims this is

g3(u3)=421362091u32+387749940u3.g^*_3(u_3) = 421362091u_3^2 + 387749940u_3.

V verifies consistency by checking (in Z/pZ\mathbb{Z}/p\mathbb{Z})

g2(1001)=69133477(1001)2+1469794372(1001)+138157656=809112031,g3(0)+g3(1)=0+(421362091+387749940)=809112031.\begin{align} g^*_2(1001) & = 69133477(1001)^2 + 1469794372(1001) + 138157656 = 809112031,\\ g^*_3(0) + g^*_3(1) & = 0 + (421362091 + 387749940) = 809112031. \end{align}

Thus the transcript is still internally consistent. Suppose V’s final random challenge is

r3=666.r_3 = 666.

Sum-check final check (no folding). At this point,

g3(r3)=g(r0,r1,r2,r3).g_3(r_3) = g(r_0,r_1,r_2,r_3).

In earlier layers, this is where folding would be used. Here, however, we are at the input layer, so V can evaluate g(r0,r1,r2,r3)g(r_0,r_1,r_2,r_3) directly from the public data.

Expanding the right-hand side gives

g(r0,r1,r2,r3)=add~1(ρ1,(r0,r1),(r2,r3))[W~2(r0,r1)+W~2(r2,r3)]+mult~1(ρ1,(r0,r1),(r2,r3))[W~2(r0,r1)W~2(r2,r3)].\begin{aligned} g(r_0,r_1,r_2,r_3) &= \widetilde{\mathrm{add}}_1(\rho_1,(r_0,r_1),(r_2,r_3)) \big[ \widetilde{W}_{2}(r_0,r_1) + \widetilde{W}_{2}(r_2,r_3) \big] + \widetilde{\mathrm{mult}}_1(\rho_1,(r_0,r_1),(r_2,r_3)) \big[ \widetilde{W}_{2}(r_0,r_1)\widetilde{W}_{2}(r_2,r_3) \big]. \end{aligned}

Since the circuit is public, V can evaluate the wiring predicates:

add~1(ρ1,(r0,r1),(r2,r3))=ρ1r0(1r1)r2r3,mult~1(ρ1,(r0,r1),(r2,r3))=(1ρ1)(1r0)(1r1)(1r2)r3.\begin{align} \widetilde{\mathrm{add}}_1(\rho_1,(r_0,r_1),(r_2,r_3)) &= \rho_1 r_0(1-r_1)r_2r_3,\\ \widetilde{\mathrm{mult}}_1(\rho_1,(r_0,r_1),(r_2,r_3)) &= (1-\rho_1)(1-r_0)(1-r_1)(1-r_2)r_3. \end{align}

Crucially, because this is the input layer, V can also compute W~2\widetilde{W}_2 directly:

W~2(r0,r1)=2r0r1+r0r1+3,W~2(r2,r3)=2r2r3+r2r3+3.\widetilde{W}_{2}(r_0,r_1) = -2r_0r_1 + r_0 - r_1 + 3, \qquad \widetilde{W}_{2}(r_2,r_3) = -2r_2r_3 + r_2 - r_3 + 3.

V therefore checks whether

g3(r3)=?g(r0,r1,r2,r3),g_3^*(r_3) \overset{?}{=} g(r_0,r_1,r_2,r_3),

rejecting if the equality fails. If it holds, V accepts and the protocol terminates.

With our concrete values (r0,r1,r2,r3)=(99,7,1001,666)(r_0,r_1,r_2,r_3)=(99,7,1001,666), V computes

g3(r3)=g3(666)=421362091(666)2+387749940(666)=577775939.g^*_3(r_3) = g_3^*(666) = 421362091(666)^2 + 387749940(666) = 577775939.

If P were honest, we would instead have

g3(r3)=421362090(666)2+655825959(666)=874818336.g_3(r_3) = 421362090(666)^2 + 655825959(666) = 874818336.

Although V does not know g3(r3)g_3(r_3) directly, V does compute the right-hand side exactly:

g(r0,r1,r2,r3)=g(99,7,1001,666)=874818336.g(r_0,r_1,r_2,r_3) = g(99,7,1001,666) = 874818336.

Since 874818336577775939874818336 \ne 577775939, V rejects P’s original claim.

The GKR protocol (formal description)

Setup. Let CC be a constant-input, strictly layered arithmetic circuit of depth dd with fan-in two.
For each layer i{0,,d}i \in \{0,\ldots,d\}, let sis_i denote the bit-length of gate labels at Layer ii, and let

Wi:{0,1}siF,W~i:FsiFW_i : \{0,1\}^{s_i} \to \mathbb{F}, \qquad \widetilde{W}_i : \mathbb{F}^{s_i} \to \mathbb{F}

be the gate-value function and its multilinear extension.

For each i{0,,d1}i \in \{0,\ldots,d-1\}, the circuit wiring is public and encoded by multilinear extensions

add~i,  mult~i:Fsi×Fsi+1×Fsi+1F.\widetilde{\mathrm{add}}_i,\;\widetilde{\mathrm{mult}}_i : \mathbb{F}^{s_i} \times \mathbb{F}^{s_{i+1}} \times \mathbb{F}^{s_{i+1}} \to \mathbb{F}.

Layer 0 (output layer).

In an honest execution, W~0=?W~0\widetilde{W}_0^* \overset{?}{=}\widetilde{W}_0, and hence α0=?W~0(ρ0)\alpha_0\overset{?}{=}\widetilde{W}_0(\rho_0). The remainder of the protocol is devoted to justifying this value. (We place a question mark over an equality symbol to remind the reader that these equalities may not hold if P is dishonest.)

Layer i, 0id10 \le i \le d-1. At the start of Layer i, V holds:

which, in an honest execution, satisfy αi=?W~i(ρi)\alpha_i\overset{?}{=}\widetilde{W}_i(\rho_i). Define the polynomial function

g(x,y):=add~i(ρi,x,y)[W~i+1(x)+W~i+1(y)]+mult~i(ρi,x,y)[W~i+1(x)W~i+1(y)],g(\mathbf{x},\mathbf{y}) := \widetilde{\mathrm{add}}_i(\rho_i,\mathbf{x},\mathbf{y}) \big[\widetilde{W}_{i+1}(\mathbf{x})+\widetilde{W}_{i+1}(\mathbf{y})\big] + \widetilde{\mathrm{mult}}_i(\rho_i,\mathbf{x},\mathbf{y}) \big[\widetilde{W}_{i+1}(\mathbf{x})\widetilde{W}_{i+1}(\mathbf{y})\big],

a polynomial on Fsi+1×Fsi+1\mathbb{F}^{s_{i+1}} \times \mathbb{F}^{s_{i+1}}. If P is honest, then by Thaler’s identity,

αi=?(x,y){0,1}si+1×{0,1}si+1g(x,y),\alpha_i \overset{?}{=} \sum_{(\mathbf{x},\mathbf{y}) \in \{0,1\}^{s_{i+1}} \times \{0,1\}^{s_{i+1}}} g(\mathbf{x},\mathbf{y}),

and this equality must hold in order for the protocol to continue without rejection.

Sum-check at Layer i.

At the end of sum-check, correctness reduces to

gm1(rm1)=?g(rx,ry).g_{m-1}^*(r_{m-1}) \overset{?}{=} g(r_x,r_y).

Bridging and folding. V cannot evaluate g(rx,ry)g(r_x,r_y) directly, since it depends on W~i+1\widetilde{W}_{i+1}. P therefore supplies two field elements

zx,zyF,z_x^*, \, z_y^* \in \mathbb{F},

intended (in an honest execution) to equal

W~i+1(rx),W~i+1(ry).\widetilde{W}_{i+1}(r_x), \, \widetilde{W}_{i+1}(r_y).

Using only public data, V checks

gm1(rm1)=?add~i(ρi,rx,ry)[zx+zy]+mult~i(ρi,rx,ry)[zxzy].g_{m-1}^*(r_{m-1}) \overset{?}{=} \widetilde{\mathrm{add}}_i(\rho_i,r_x,r_y)\big[z_x^*+z_y^*\big] + \widetilde{\mathrm{mult}}_i(\rho_i,r_x,r_y)\big[z_x^*z_y^*\big].

(V computes both sides themself.) If this check fails, V rejects.

Assuming it passes, define the affine line

i+1:FFsi+1,i+1(t):=(1t)rx+try,\ell_{i+1} : \mathbb{F} \to \mathbb{F}^{s_{i + 1}}, \quad \ell_{i+1}(t) := (1-t)r_x + t r_y,

and the associated ground-truth univariate polynomial function

qi+1:FF,qi+1(t):=W~i+1(i+1(t)).q_{i + 1} : \mathbb{F} \to \mathbb{F}, \quad q_{i+1}(t) := \widetilde{W}_{i+1}(\ell_{i+1}(t)).

P sends a univariate polynomial qi+1q_{i+1}^*, purported to equal qi+1q_{i+1}. V checks:

  1. degqi+1?si+1\deg q_{i+1}^* \overset{?}{\le} s_{i+1},

  2. qi+1(0)=?zxq_{i+1}^*(0) \overset{?}{=} z_x^* and qi+1(1)=?zyq_{i+1}^*(1) \overset{?}{=} z_y^*.

If these checks pass, V samples

τi+1F\tau_{i+1} \leftarrow \mathbb{F}

uniformly at random, and sets

ρi+1:=i+1(τi+1),αi+1:=qi+1(τi+1).\rho_{i+1} := \ell_{i+1}(\tau_{i+1}), \qquad \alpha_{i+1} := q_{i+1}^*(\tau_{i+1}).

In an honest execution, αi+1=?W~i+1(ρi+1)\alpha_{i+1}\overset{?}{=}\widetilde{W}_{i+1}(\rho_{i+1}). The protocol then proceeds to Layer i + 1.

Final layer. At Layer d - 1, the same procedure is followed through the sum-check. There is no folding step: the child layer dd consists of input gates, so W~d\widetilde{W}_d is fully determined by the public inputs, and V computes zx=W~d(rx)z_x = \widetilde{W}_d(r_x) and zy=W~d(ry)z_y = \widetilde{W}_d(r_y) directly. V then checks the bridging equation with these true values. If it holds, V accepts; otherwise, V rejects.

Completeness and soundness

Completeness. If P is honest and V’s calculations are accurate, V accepts with probability 1.

Proof. An honest P sends W~0=W~0\widetilde{W}_0^* = \widetilde{W}_0, so α0=W~0(ρ0)\alpha_0 = \widetilde{W}_0(\rho_0). Suppose inductively that αi=W~i(ρi)\alpha_i = \widetilde{W}_i(\rho_i) at the start of Layer ii. By Thaler’s identity, αi\alpha_i really is the sum of gg over {0,1}si+1×{0,1}si+1\{0,1\}^{s_{i+1}} \times \{0,1\}^{s_{i+1}}, so the honest round polynomials satisfy every degree bound and every consistency condition of the sum-check, and the terminal value is gm1(rm1)=g(rx,ry)g_{m-1}(r_{m-1}) = g(r_x, r_y). The honest endpoints zx=W~i+1(rx)z_x^* = \widetilde{W}_{i+1}(r_x) and zy=W~i+1(ry)z_y^* = \widetilde{W}_{i+1}(r_y) make the bridging check the definition of g(rx,ry)g(r_x,r_y), hence an identity. The honest qi+1=qi+1=W~i+1i+1q_{i+1}^* = q_{i+1} = \widetilde{W}_{i+1} \circ \ell_{i+1} has degree at most si+1s_{i+1} (a multilinear polynomial composed with an affine line: each monomial kTi+1(t)k\prod_{k \, \in \, T} \ell_{i+1}(t)_k has degree Tsi+1|T| \le s_{i+1} in tt) and matches both endpoints, so the folding checks pass and

αi+1=qi+1(τi+1)=W~i+1(i+1(τi+1))=W~i+1(ρi+1),\alpha_{i+1} = q_{i+1}(\tau_{i+1}) = \widetilde{W}_{i+1}(\ell_{i+1}(\tau_{i+1})) = \widetilde{W}_{i+1}(\rho_{i+1}),

closing the induction. At the final layer, V evaluates zx,zyz_x, z_y itself from the public inputs, and the bridging check is again an identity. Every check is an equality between correctly computed quantities, so V accepts.

Soundness. A dishonest P may claim incorrect output values and still pass. We now bound the probability of this event and locate exactly where it can occur. There are only three places in the whole protocol where P is exposed to V’s randomness: the choice of ρ0\rho_0, the challenge rjr_j of each sum-check round, and the challenge τi+1\tau_{i+1} of each fold. Everything else (the bridging equations, the endpoint claims zx,zyz_x^*, z_y^*, the boundary conditions on qi+1q_{i+1}^*), P can, and a clever P will, satisfy identically, by lying consistently. The soundness error is the union bound over those exposures and nothing more.

Notation for the proof. Fix a layer ii and drop the layer superscript. As in the sum-check notebook, the true round polynomials of the Layer ii sum-check are

gj(u):=b{0,1}m1jg(r0,,rj1,u,b),0jm1,\begin{align} g_j(u) &:= \sum_{\mathbf{b} \, \in \, \{0,1\}^{m-1-j}} g(r_0,\ldots,r_{j-1},u,\mathbf{b}), \qquad 0 \le j \le m-1, \end{align}

so that

g0(0)+g0(1)=(x,y)g(x,y)=W~i(ρi)(Thaler’s identity),gj1(rj1)=gj(0)+gj(1),1jm1,gm1(rm1)=g(rx,ry),\begin{align} g_0(0) + g_0(1) &= \sum_{(\mathbf{x},\mathbf{y})} g(\mathbf{x},\mathbf{y}) = \widetilde{W}_i(\rho_i) \quad \text{(Thaler's identity)}, \\ g_{j-1}(r_{j-1}) &= g_j(0) + g_j(1), \qquad 1 \le j \le m-1, \\ g_{m-1}(r_{m-1}) &= g(r_x, r_y), \end{align}

and deggjdegjg2\deg g_j \le \deg_j g \le 2, as observed in the protocol description. We say the carried claim at Layer ii is false if αiW~i(ρi)\alpha_i \ne \widetilde{W}_i(\rho_i). P is of course free to send whatever it likes; the objects above are the honest ones, well-defined whether or not anyone computes them, and V’s checks are comparisons against P’s actual messages g0,,gm1,zx,zy,qi+1g_0^*, \ldots, g_{m-1}^*, z_x^*, z_y^*, q_{i+1}^*.

Two families of lucky events will carry the whole error budget:

Li,j:gjgj   and   gj(rj)=gj(rj)(round j of Layer i’s sum-check),Mi:qi+1qi+1   and   qi+1(τi+1)=qi+1(τi+1)(the fold, 0id2).\begin{align} L_{i,j} &: \quad g_j^* \ne g_j \;\text{ and }\; g_j^*(r_j) = g_j(r_j) \qquad \text{(round $j$ of Layer $i$'s sum-check)}, \\ M_i &: \quad q_{i+1}^* \ne q_{i+1} \;\text{ and }\; q_{i+1}^*(\tau_{i+1}) = q_{i+1}(\tau_{i+1}) \qquad \text{(the fold, $0 \le i \le d-2$)}. \end{align}
# Reproduce the first row of the table: the worked example over GF(101).
# A dishonest machine prover corrupts the output claim and plants maximal
# roots at every opportunity; we count how often V accepts. Takes ~10 s.
import random

from gkr.ac import ArithmeticCircuit
from gkr.protocol import Sink, RandomVerifier, run_gkr
from gkr.protocol.gkr_parties import GkrMachineProver
from gkr.utils.display import TerminalOutput

random.seed(2026)
quiet = TerminalOutput(enable_paging=False)
quiet.print = lambda *a, **k: None            # discard the narration

ac = ArithmeticCircuit('(3*2) + (4 + 1)', prime=101)

N, accepted = 400, 0
for _ in range(N):
    sink = Sink(lambda e: True)
    prover = GkrMachineProver(ac, sink, secret_mode=False, dishonest_claim=True, out=quiet)
    result = run_gkr(ac, prover=prover, verifier=RandomVerifier(ac.field, out=quiet),
                     sink=sink, out=quiet)
    accepted += (result.status == "accept")

rate = accepted / N
half = 1.96 * (rate * (1 - rate) / N) ** 0.5
print(f"union bound:  13/101 = {13/101:.4f}")
print(f"measured:     {accepted}/{N} = {rate:.4f}  (+/- {half:.4f} at 95%)")
union bound:  13/101 = 0.1287
measured:     50/400 = 0.1250  (+/- 0.0324 at 95%)

Costs

We do not develop the cost analysis here. See 3 for a full account of the verifier’s and prover’s runtimes, the round complexity and communication cost, and 3 for the separate question of evaluating add~i\widetilde{\mathrm{add}}_i and mult~i\widetilde{\mathrm{mult}}_i efficiently, which is the delicate term in V’s runtime and the reason the protocol is usually stated for circuits whose wiring has repeated structure. The techniques that bring P’s runtime down to O(SlogS)O(S\log S) are due to 4.

A note on this implementation. The code accompanying these notes makes no attempt at any of this. It constructs add~i\widetilde{\mathrm{add}}_i, mult~i\widetilde{\mathrm{mult}}_i and W~i\widetilde{W}_i symbolically over the whole Boolean hypercube, which is exponential in the label lengths. The object here is to watch the protocol’s structure, not to run it at scale, but it is why the worked examples are small.

References
  1. Goldwasser, S., Kalai, Y. T., & Rothblum, G. N. (2008). Delegating computation: Interactive proofs for muggles. Proceedings of the 40th Annual ACM Symposium on Theory of Computing (STOC), 113–122. 10.1145/1374376.1374396
  2. Goldwasser, S., Kalai, Y. T., & Rothblum, G. N. (2015). Delegating computation: Interactive proofs for muggles. Journal of the ACM, 62(4), 1–64. 10.1145/2699436
  3. Thaler, J. (2022). Proofs, Arguments, and Zero-Knowledge. Foundations and Trends in Privacy and Security, 4(2–4), 117–660. 10.1561/3300000030
  4. Cormode, G., Mitzenmacher, M., & Thaler, J. (2012). Practical verified computation with streaming interactive proofs. Proceedings of the 3rd Innovations in Theoretical Computer Science Conference (ITCS), 90–112. 10.1145/2090236.2090245