Nova

Presentation: https://www.youtube.com/watch?v=dDsAroTRaFI

Problem Statement

How to prove y=F(n)(x)y=F^{(n)}(x)? The naïve approach would be unrolling this into a single circuit and proving with some SNARK. But this would require a lot of memory and the proof is not incrementally updatable. Also, the verifier's time may depend on nn. To tackle this problem more efficiently, a new approach called incrementally-verifiable computation was introduced in Val08, BCTV14. In IVC, an augmented circuit is introduced which ensures correct execution of FF as well as some verifier circuit which can now be used to inductively prove the correct execution of F(n)(x)F^{(n)}(x).

Folding R1CS

Standard R1CS

Given three m×mm\times m matrices A,B,C\bm{A},\bm{B},\bm{C} and public input x\mathsf{x}, does there exist witness W\bm{W} such that: AZBZ=CZ\bm{AZ}\circ \bm{BZ}=\bm{CZ} where Z=(W,x,1)\bm{Z}=(\bm{W},\mathsf{x},1). Here, we use x\mathsf{x} instead of vector x\bm{x} for public input since in Nova, it is typically a hash value.

An attempt to fold R1CS

Suppose prover P\mathsf{P} holds W1\bm{W}_1 and W2\bm{W}_2 and verifier V\mathsf{V} holds U1=(W1,x1)U_1=(\bm{W}_1,\mathsf{x}_1) and U2=(W2,x2)U_2=(\bm{W}_2,\mathsf{x}_2).

  1. Verifier picks random rr and send it to the prover.

  2. Verifier computes xx1+rx2\mathsf{x}\leftarrow \mathsf{x}_1 + r\cdot \mathsf{x}_2 so the folded instance becomes (A,B,C,x)(\bm{A},\bm{B},\bm{C},\mathsf{x}).

  3. Prover computes the folded witness WW1+rW2\bm{W}\leftarrow \bm{W}_1 + r\cdot \bm{W}_2.

Figure 1. Folding R1CS. Credit: https://www.youtube.com/watch?v=ilrvqajkrYY

Unfortunately there exists many rr such that AZBZCZ\bm{AZ}\circ \bm{BZ} \neq \bm{CZ} for Z=(W,x,1)\bm{Z}=(\bm{W},\mathsf{x},1).

AZBZ=(AZ1BZ1)+r2(AZ2BZ2)+r(AZ2BZ1+AZ1BZ2)\bm{AZ}\circ \bm{BZ}=(\bm{AZ}_1\circ \bm{BZ}_1) + r^2\cdot(\bm{AZ}_2\circ \bm{BZ}_2) + r\cdot (\bm{AZ}_2\circ \bm{BZ}_1 + \bm{AZ}_1 \circ \bm{BZ}_2)

This shows 3 issues:

  1. Need to account the cross-term: r(AZ2BZ1+AZ1BZ2)r\cdot (\bm{AZ}_2\circ \bm{BZ}_1 + \bm{AZ}_1 \circ \bm{BZ}_2)

  2. Mismatch in coefficient of CZ2:r2CZ2rCZ2\bm{CZ}_2: r^2\cdot \bm{CZ}_2 \neq r\cdot \bm{CZ}_2

  3. Even ZZ1+rZ2\bm{Z}\neq \bm{Z}_1 + r\cdot \bm{Z}_2 since Z1+rZ2=(W,x,1+r1)\bm{Z}_1 + r\cdot \bm{Z}_2=(\bm{W},\mathsf{x},1+r\cdot 1)

To address first issue, we add error vector EFm\bm{E}\in \mathbb{F}^m which absorbs the cross-terms. To handle the second and third issues, we introduce a scalar uu, which absorbs an extra factor of rr in CZ2CZ_2 and in Z=(W,x,1+r1)\bm{Z}=(\bm{W},\mathsf{x},1 + r\cdot 1). We refer to the R1CS with these additional terms as relaxed R1CS.

Relaxed R1CS

Definition 11 from the paper. Consider a finite field F\mathbb{F}. Let the public parameters consist of size bounds m,n,lNm, n, l \in \mathbb{N} where m>lm>l. The relaxed R1CS structure consists of sparse matrices A,B,CFm×m\bm{A,B,C}\in \mathbb{F}^{m\times m} with at most n=Ω(m)n=\Omega(m) non-zero values in each matrix. A relaxed R1CS instance consists of an error vector EFm\bm{E} \in \mathbb{F}^m, a scalar uFu\in \mathbb{F}, and public inputs and outputs xFl\mathsf{x}\in \mathbb{F}^l. An instance ((A,B,C),(E,u,x))((\bm{A},\bm{B},\bm{C}),(\bm{E},u,\mathsf{x})) is satisfied by a witness WFml1\bm{W} \in F^{m-l-1} if

AZBZ=uCZ+E\bm{AZ}\circ \bm{BZ}=u\cdot \bm{CZ} + \bm{E}

where Z=(W,x,u)\bm{Z}=(\bm{W},\mathsf{x},u). In this setup, notice that if u=1u=1 and E=0\bm{E}=\vec{0} then it is same as standard R1CS.

Folding relaxed R1CS

To fold relaxed R1CS, the prover and verifier additionally compute:

  1. uu1+ru2u\leftarrow u_1 + r\cdot u_2

  2. EE1+r(AZ1BZ2+AZ2BZ1u1CZ2u2CZ1)+r2E2\bm{E} \leftarrow \bm{E}_1 + r\cdot (\bm{AZ}_1 \circ \bm{BZ}_2 + \bm{AZ}_2 \circ \bm{BZ}_1 - u_1\bm{CZ}_2 - u_2\bm{CZ}_1) + r^2\cdot \bm{E}_2

  3. Now, the folded instance is (A,B,C,E,u,x)(\bm{A,B,C,E},u,\mathsf{x}).

Figure 2. Folding relaxed R1CS. Credit: https://www.youtube.com/watch?v=mY-LWXKsBLc

Now, you will be able get AZBZ=uCZ+E\bm{AZ}\circ \bm{BZ} = u\cdot\bm{CZ} + \bm{E} where Z=Z1+rZ2\bm{Z}=\bm{Z}_1 + r\cdot \bm{Z}_2. But there is still a few issues remaining:

  1. The verifier has to compute E\bm{E} which has multiple large matrix multiplications so it is non-trivial.

  2. Verifier cannot check if WW is indeed the outcome of W1+rW2\bm{W}_1 + r\cdot \bm{W}_2 so it cannot be zero-knowledge because verifier needs to know W1\bm{W}_1 and W2\bm{W}_2 to fully verify.

To circumvent these issues, we use succinct and hiding additive homomorphic commitments to W\bm{W} and E\bm{E} in the instance, and treat both W\bm{W} and E\bm{E} as the witness. We refer to this variant as committed relaxed R1CS.

Committed Relaxed R1CS

Definition 12 from the paper. Consider a finite field F\mathbb{F} and a commitment scheme Com\mathsf{Com} over F\mathbb{F}. Let the public parameters consist of size bounds m,n,lNm, n, l \in \mathbb{N} where m>lm > l, and commitment parameters ppW\mathsf{pp}_W and ppE\mathsf{pp}_E for vectors of size mm and ml1m−l−1 respectively. The committed relaxed R1CS structure consists of sparse matrices A,B,CFm×m\bm{A, B, C} \in \mathbb{F}^{m\times m} with at most n=Ω(m)n = \Omega(m) non-zero entries in each matrix. A committed relaxed R1CS instance is a tuple (A,B,C,Wˉ,Eˉ,u,x)(\bm{A,B,C}, \bar{W},\bar{E},u,\mathsf{x}), where Wˉ\bar{W} and Eˉ\bar{E} are commitments, uFu \in \mathbb{F}, and xFl\mathsf{x} \in \mathbb{F}^l are public inputs and outputs. An instance is satisfied by a witness (W,E,rW,rE)(Fml1,Fm,F,F)(\bm{W},\bm{E}, r_W, r_E ) \in (\mathbb{F}^{m−l−1},\mathbb{F}^m, \mathbb{F},\mathbb{F}) if :

  1. Eˉ=Com(ppE,E,rE)\bar{E} = \mathsf{Com}(\mathsf{pp}_E, E, r_E)

  2. Wˉ=Com(ppW,W,rW)\bar{W} = \mathsf{Com}(\mathsf{pp}_W , W, r_W )

  3. AZBZ=uCZ+E\bm{AZ} \circ \bm{BZ}=u\cdot \bm{CZ} + \bm{E}, where Z=(W,x,u)\bm{Z} = (\bm{W}, \mathsf{x}, \mathsf{u}).

A Folding Scheme for Committed Relaxed R1CS

Suppose prover holds (W1,E1,rW1,rE1)(\bm{W}_1,\bm{E}_1,r_{W_1},r_{E_1}) and (W2,E2,rW2,rE2)(\bm{W}_2, \bm{E}_2, r_{W_2}, r_{E_2}). The verifier takes two committed instances (W1ˉ,E1ˉ,u1,x1)(\bar{W_1},\bar{E_1},u_1,\mathsf{x}_1) and (W2ˉ,E2ˉ,u2,x2)(\bar{W_2},\bar{E_2},\mathsf{u}_2, \mathsf{x}_2). Let Z1=(W1,x1,u1)\bm{Z}_1=(\bm{W}_1,\mathsf{x}_1,u_1) and Z2=(W2,x2,u2)\bm{Z}_2=(\bm{W}_2,\mathsf{x}_2,u_2).

  1. Prover sends Tˉ=Com(ppE,T,rT)\bar{T}=\mathsf{Com}(\mathsf{pp}_E,\bm{T},r_T) where rTFr_T\leftarrow \mathbb{F} and

T=AZ1BZ2+AZ2BZ1u1CZ2u2CZ1\bm{T}=\bm{AZ}_1\circ \bm{BZ}_2 + \bm{AZ}_2\circ \bm{BZ}_1 - u_1\cdot \bm{CZ}_2-u_2\cdot \bm{CZ}_1
  1. Verifier sends challenge rFr\leftarrow \mathbb{F}.

  2. Prover and verifier computes folded instance (Wˉ,Eˉ,u,x)(\bar{W}, \bar{E}, u,\mathsf{x}) where

WˉW1ˉ+rW2ˉEˉE1ˉ+rTˉ+r2E2ˉuu1+ru2xx1+rx2\bar{W}\leftarrow \bar{W_1} + r\cdot \bar{W_2} \\ \bar{E}\leftarrow \bar{E_1} + r\cdot \bar{T} + r^2\cdot \bar{E_2} \\ u\leftarrow u_1 + r\cdot u_2\\ x\leftarrow x_1 + r\cdot x_2
  1. Prover computes the folded witness (W,E,rW,rE)(\bm{W},\bm{E},r_W,r_E) where

WW1+rW2EE1+rT+r2E2rErE1+rrT+r2rE2rWrW1+rrW2\bm{W}\leftarrow \bm{W}_1 + r\cdot \bm{W}_2 \\ \bm{E}\leftarrow \bm{E}_1 + r\cdot \bm{T} + r^2\cdot\bm{E}_2 \\ r_E\leftarrow r_{E_1}+r\cdot r_T + r^2\cdot r_{E_2} \\ r_W\leftarrow r_{W_1}+r\cdot r_{W_2}
Figure 3. Folding Commited Relaxed R1CS. Credit: https://www.youtube.com/watch?v=ilrvqajkrYY

Proof of completeness. To prove completeness, we must show that for any valid witness pairs, the folding verifier will accept the folded instance. For the folded witness to satisfy the constraint, we must have:

A(Z1+rZ2)B(Z1+rZ2)=(u1+ru2)C(Z1+rZ2)+E\bm{A}(\bm{Z}_1 + r\bm{Z}_2)\circ \bm{B}(\bm{Z}_1 + r\cdot \bm{Z}_2)=(u_1 + r\cdot u_2)\cdot \bm{C}(\bm{Z}_1 + r\cdot \bm{Z}_2) + \bm{E}

Distributing, we get:

AZ1BZ1+r(AZ1BZ2+AZ2BZ1)+r2(AZ2BZ2)=u1CZ1+r(u1CZ2+u2CZ1)+r2u2CZ2+E\bm{AZ}_1\circ \bm{BZ}_1 + r(\bm{AZ}_1\circ \bm{BZ}_2 + \bm{AZ}_2\circ \bm{BZ}_1) + r^2(\bm{AZ}_2 \circ \bm{BZ}_2)=\\u_1\cdot \bm{CZ}_1 + r(u_1\cdot \bm{CZ}_2 + u_2\cdot \bm{CZ}_1) + r^2 \cdot u_2 \cdot \bm{CZ}_2 + \bm{E}

Aggregating by powers of rr, we must have:

(AZ1BZ1u1CZ1)+r(AZ1BZ2+AZ2BZ1u1CZ2u2CZ1)+r2(AZ2BZ2u2CZ2)=E(\bm{AZ}_1\circ \bm{BZ}_1 - u_1 \cdot \bm{CZ}_1) + \\r(\bm{AZ}_1\circ \bm{BZ}_2 + \bm{AZ}_2 \circ \bm{BZ}_1 - u_1\cdot \bm{CZ}_2 - u_2\bm{CZ}_1)+\\r^2(\bm{AZ}_2 \circ \bm{BZ}_2 - u_2 \cdot \bm{CZ}_2)\\=\bm{E}

Since W1W_1 and W2W_2 are satisfying witnesses, we have:

E1+rT+r2E2=E\bm{E}_1 + r\cdot \bm{T} + r^2\cdot \bm{E}_2=\bm{E}

which holds by construction.

Proof of soundness. To prove soundness, we must show that for any wrongly constructed folded instance will be rejected by the folding verifier. The intuition is we can extract a satisfying witness from the proof if the verification passes. TODO: elaborate how we can extract it.

Theorem 3 from the paper. The above construction is a public-coin folding scheme for committed relaxed R1CS with perfect completeness, knowledge soundness, and zero-knowledge.

From Folding to IVC

We constructed a way to fold two R1CS instances into one but now what? How do we incrementally prove and verify with this? To prove that zn=Fn(z0)z_n=F^{n}(z_0), for some count nn, initial input z0z_0, and output znz_n, we use an augmented constraint system which in addition to invoking FF, performs additional bookkeeping to fold proofs of prior invocations of itself. A simple version of this augmented constraint system would take two committed relaxed R1CS instances Uacc,i\mathbb{U}_\mathsf{acc,i} and Ui\mathbb{U}_\mathsf{i} as an input where Uacc,i\mathbb{U}_\mathsf{acc,i} represents the correct execution of previous invocations and Ui\mathbb{U}_\mathsf{i} represents correct execution of ii-th invocation. Mainly, it performs two tasks:

  1. (State transition) Execute a step of the incremental computation: instance Ui\mathbb{U}_\mathsf{i} contains ziz_i which the augmented constraint system uses to output zi+1=F(zi)z_{i+1} = F(z_i).

  2. (Folding) Fold Uacc,i\mathbb{U}_\mathsf{acc,i} and Ui\mathbb{U}_\mathsf{i} into a single R1CS instance Uacc,i+1\mathbb{U}_\mathsf{acc,i+1}.

Figure 4: Simple outline of IVC. https://youtu.be/h_PU7FZWiQk?t=784

IVC over a single curve

First, let's understand how we can construct it over a single curve. What we need to constrain within this R1CS\mathsf{R1CS} is:

  1. Check previous state transitions are correct

    1. IsStrict(Ui)=True\mathsf{IsStrict}(\mathbb{U}_\mathsf{i})=\mathsf{True} (checks if error term is 0 and scalar is 1)

    2. Check if Ui.x=H(i,z0,zi,Uacc,i)\mathbb{U_i}.\mathsf{x}=\mathsf{H}(i,z_0,z_i,\mathbb{U}_\mathsf{acc,i}). It might be confusing since we don't use hash here normally. To prove Fn(z0)=znF^n(z_0)=z_n we would typically have x=(z0,zn,n)\mathsf{x}=(z_0,z_n,n). But for IVC, we need to keep track of the accumulated claim as well so we use hash here to keep the input size constant.

  2. Apply the state transition and accumulate instances.

    1. Check if zi+1=F(zi)z_{i+1}=F(z_i)

    2. Accumulate into Uacc,i+1=FoldV(Ui,Uacc,i)\mathbb{U}_\mathsf{acc,i+1}=\mathsf{Fold_V}(\mathbb{U}_\mathsf{i}, \mathbb{U}_\mathsf{acc,i})

  3. Generate the instance for next state transitions.

    1. Set Ui+1.x=H(i+1,z0,zi+1,Uacc,i+1)\mathbb{U}_\mathsf{i+1}.\mathsf{x}=\mathsf{H}(i+1,z_0,z_{i+1},\mathbb{U}_\mathsf{acc,i+1})

    2. Generate Ui+1=(0ˉ,Wˉi+1,x,1)\mathbb{U}_\mathsf{i+1}=(\bar{0},\bar{W}_{i+1},\mathsf{x},1) instance which resembles correct execution of this step. Notice that the error term should be 0 and scalar should be 1 since it is not a folded instance.

Figure 5. In-depth view of the augmented constraint system. https://youtu.be/h_PU7FZWiQk?t=978

IVC Verification

Given a proof π=((Ui,Wi),(Uacc,i,Wacc,i))\pi=((\mathbb{U}_\mathsf{i}, \mathbb{W}_\mathsf{i}),(\mathbb{U}_\mathsf{acc,i}, \mathbb{W}_\mathsf{acc,i})), the IVC verification will do the following:

Verify((i,z0,zi),π):\mathsf{Verify}((i,z_0,z_i),\pi):

  1. IsStrict(Ui)=True\mathsf{IsStrict}(\mathbb{U}_\mathsf{i})=\mathsf{True}

  2. ((Ui,Wi),(Uacc,i,Wacc,i))((\mathbb{U}_\mathsf{i}, \mathbb{W}_\mathsf{i}),(\mathbb{U}_\mathsf{acc,i}, \mathbb{W}_\mathsf{acc,i})) satisfy R1CS\mathsf{R1CS}.

  3. Ui.x=H(i,z0,zi,Uacc,i)\mathbb{U}_\mathsf{i}.\mathsf{x}=\mathsf{H}(i,z_0,z_i,\mathbb{U}_\mathsf{acc,i})

Conclusion

In proof-of-concept benchmarks, Nova was shown to be 4x faster at proving 10000 recursive SHA256 hashes than Halo2 (KZG) and memory usage is constant with respect to number of iterations in Nova while in Halo2 (KZG), the memory usage increases almost linearly with respect to number of iterations. This result is taken from: https://hackmd.io/0gVClQ9IQiSXHYAK0Up9hg?view

References

Written by BATZORIG ZORIGOO from A41

Last updated