Various constructions for zkSNARKs over R1CS exist—, for instance, achieves O(nlogn) proving time and O(1) proof size, but requires a per-statement trusted setup with a large common reference string. Recent transparent zkSNARKs, such as Hyrax, STARK, Aurora, Ligero, and Bulletproofs, eliminate the need for trusted setups yet often impose limitations like circuit restrictions or linear verification costs. In Spartan, a new zkSNARK for arbitrary R1CS instances with sub-linear verification cost is introduced.
Background
Problem statement
Prior works are still lacking to achieve truly succinct SNARK without any trusted setup.
The computational model of is layered arithmetic circuits, where the verifier’s costs and the proof sizes scale linearly in the depth of the circuit. For a depth-d circuit, converting to a layered form increases the circuit size by a factor of O(d), so Hyrax is restricted to low-depth circuits. Also, Hyrax achieves sublinear verification costs only for circuits with a uniform structure (e.g., data-parallel circuits).
requires circuits with a sequence of identical sub-circuits, otherwise it does not achieve sublinear verification costs. Any circuit can be converted to this form, but the transformation increases circuit sizes by 10–1000×, which translates to a similar factor increase in the prover’s costs ().
, , and incur O(n) verification costs.
So to summarize, there is two main challenges with achieving succinct verification:
Arbitrary circuits have no structure.
The verifier must know what statement is being proven. Because of these challenges, the verification must have complexity of at least O(∣C∣) where ∣C∣ implies circuit size.
Spartan solution: Verifier preprocesses the circuits - without secret trapdoors to avoid any form of trusted setup.
Verifier retains a commitment to the circuit.
Preprocessing incurs O(∣C∣) costs but is amortized.
The amortized cost here implies that even though the upfront computational or resource expense might be high, when spread over a large number of operations or over time, the average cost per operation becomes more manageable or efficient.
Succinct interactive arguments of knowledge
The sumcheck protocol
This proof system does not require a trusted setup. It can be made zero-knowledge and non-interactive with existing compilers but still cannot be used as a zkSNARK. The main two reasons for this are:
We need an efficient reduction from R1CS statements to sumcheck instances.
The proof system is not succinct (both proof sizes and verification times).
Multilinear polynomial extension
Polynomial commitment scheme for multilinear polynomials
From this paper, we adopt the notation ⟨A(za),B(zb)⟩(x) to denote the random variable representing the local output of machine B when interacting with the machine A on common input x, when the random tapes for each machine are uniformly and independently chosen, and A and B has auxiliary inputs za and zb, respectively.
Let ⟨P,V⟩ denote a pair of algorithms and Setup denotes an algorithm that outputs public parameters pp given as input the security parameter λ.
from the paper. A protocol between a pair of algorithms ⟨P,V⟩ is called a public-coin succinct interactive argument of knowledge for a language L if:
Completeness. For any problem instance x∈L, there exists a witness w such that for all r∈{0,1}∗, Pr{⟨P(pp,w),V(pp,r)⟩(x)=1}≥1−negl(λ).
Soundness. For any non-satisfiable problem instance x, any PPT prover P∗ , and for all w,r∈{0,1}∗, Pr{⟨P∗(pp,w),V(pp,r)⟩(x)=1}≤negl(λ).
Knowledge soundness. For any PPT adversary A, there exists a PPT extractor E such that for any problem instance x and for all w,r∈{0,1}∗ , if Pr{⟨A(pp,w),V(pp,r)⟩(x)=1}≥negl(λ), then Pr{SatL(x,w′)=1∣w′←EA(pp,x)}≥negl(λ).
Succinctness. The total communication between P and V is sublinear in the size of the NP statement x∈L.
Public coin. V's messages are chosen uniformly at random.
Using , a prover can prove statements of the form:
x∈{0,1}μ∑G(x)=?T
We can denote the sumcheck protocol as IsSat←⟨Psc,Vsc(r)⟩(G,μ,l,T) for any μ-variate polynomial G with degree at most l in each variable. This is typically reduced to the claim G(r)=?e and using μ round interactive protocol which can be denoted as e←⟨Psc(G),Vsc(r)⟩(μ,l,T)
Generally, the verifier must evaluate G at some random point in its domain r=(r1,…,rμ).
. (Multilinear polynomial) A multivariate polynomial is called a multilinear polynomial if the degree of the polynomial in each variable is at most one.
. (Low-degree polynomial) A multivariate polynomial G over a finite field F is called low-degree polynomial if the degree of G in each variable is exponentially smaller than ∣F∣.
Low-degree extensions (LDEs). Suppose g:{0,1}μ→F is a function that maps μ-bit elements into an element of F. A polynomial extension of g is a low-degree μ-variate polynomial g~(⋅) such that g~(x)=g(x) for all x∈{0,1}μ.
Multilinear extension (MLE) is a LDE where the extension is a multilinear polynomial. Given a function Z:{0,1}μ→F, the MLE of Z(⋅) is the unique multilinear polynomial Z~:Fμ→F. It can be computed as follows:
Note that eq(x,e) is the MLE of the following function:
eq(x,e)={10ifx=eotherwise
For any r∈Fμ, Z~(r) can be computed in O(2μ) operations in F. [, ]
A polynomial commitment scheme for multilinear polynomials is a tuple of four protocols PC=(Setup,Commit,Open,Eval).
pp←Setup(1λ,μ): takes as input μ (the number of variables in a multilinear polynomial); produces public parameters pp.
(C;S)←Commit(pp;G): takes as input a μ-variate multilinear polynomial over a finite field G∈F[X1,...,Xμ]; produces a public commitment C and a secret opening hint S.
b←Open(pp,C,G,S): verifies the opening of commitment C to the μ-variate multilinear polynomial G∈F[X1,…,Xμ] with the opening hint S; outputs a boolean b∈{0,1}.
b←Eval(pp,C,r,v;G,S) is an interactive public-coin protocol between a prover P and verifier V. Both V and P hold a commitment C, a scalar v∈F , and r∈Fμ. P additionally knows a μ-variate multilinear polynomial G∈F[X1,…,Xμ] and its secret opening hint S. P attempts to convince V that G(r)=v. At the end of the protocol, V outputs b∈{0,1}.
from the paper. For any R1CS instance x=(F,A,B,C,io,m,n) there exists a degree-3, logm-variate polynomial G such that ∑x∈{0,1}logmG(x)=0 if and only if there exists a witness w such that Sat(x,w)=1 (except for a soundness error that is negligible in λ). Here, n is the upper bound on the non-zero entries in the A,B,C matrices.
If we denote logm=s for the sake of simplicity, for a given A,B,C∈Fm×m, we can view them as functions with the following signature: {0,1}s×{0,1}s→F. Furthermore, given a witness w to instance x, let Z=(io,1,w). Then we can also view Z as a function mapping {0,1}s→F.
We define Fio(⋅) that can be used to encode w as:
from the paper.∀x∈{0,1}s,Fio(x)=0 if and only if Sat(x,w)=1.
Proof. This follows from the definition of SatR1CS(x,w) (Section 2.1) and of Z(⋅). □
Unfortunately, Fio(⋅) is a function, not a polynomial, so it cannot be directly used in the sumcheck protocol. But, consider its polynomial extension F~io:Fs→F:
from the paper. Then, ∀x∈{0,1}s,F~io(x)=0 if and only if Sat(x,w)=1.
Proof. For any x∈{0,1}s, F~io(x)=Fio(x), so the result follows from Lemma 4.1. □
Since F~io(⋅) is a low-degree multivariate polynomial over F in s variables, a verifier could check if ∑x∈{0,1}sF~io(x)=0 using the sumcheck protocol. But the sum being 0 doesn't exactly mean that each of them was 0 since some of the terms in the sum may cancel each other out. This is addressed using a prior idea from by taking:
∀t∈{0,1}s, Qio(t)=0⇔Sat(x,w)=1 . Therefore, Since it has 2s solutions, it has to be a 0 polynomial over the Fs if and only if Sat(x,w)=1.
This implies that Qio(τ) is zero-polynomial if and only if Sat(x,w)=1 and to check if Qio(⋅) is a zero-polynomial, its enough with a single random challenge Qio(rτ)=?0 where rτ∈RFs (this will introduce soundness error ∣F∣logm).
Proof of . For a given R1CS instance x=(F,A,B,C,io,m,n), define, Gio,τ(x)=F~io(x)⋅eq(τ,x), so Qio(τ)=∑x∈{0,1}sGio,τ(x). Observe that Gio,τ(⋅) is a degree-3 s-variate polynomial if multilinear extensions of A,B,C, and Z are used in F~io(⋅). In the terminology of the sumcheck protocol, T=0, μ=s=logm, and l=3. Furthermore, if rτ∈RFs, ∑x∈{0,1}sGio,rτ(x)=0 if and only F~io(x)=0, ∀x∈{0,1}s—except for soundness error that is negligible in λ under the assumptions noted above (). This combined with implies the desired result.
from the paper. Given an extractable polynomial commitment scheme for multilinear polynomials, there exists a public-coin succinct interactive argument of knowledge where security holds under the assumptions needed for the polynomial commitment scheme and assuming ∣F∣ is exponential in λ and the size parameter of R1CS instance n=O(λ).
established that for V to verify if an R1CS instance x=(F,A,B,C,io,m,n) is satisfiable, it can check if ∑x∈{0,1}logmGio,τ(x)=0. By using the sumcheck protocol, we can reduce the claim about the sum to ex=?Gio,τ(rx) where rx∈Fs, so V needs a mechanism to evaluate Gio,τ(rx)—without incurring O(m) communication from P to V.
Now, the prover can make three separate claims Aˉ(rx)=vA,Bˉ(rx)=vB,Cˉ(rx)=vC and verifier can check:
Gio,τ(rx)=(vA⋅vB−vC)⋅eq(rx,τ)=?ex
Of course, the verifier still needs verify the vA,vB,vC claims and to do so, it can run three independent instances of sumcheck protocol but instead, we can use a to combine these into a single claim:
Verifier samples rA,rB,rC←F and computes c=rA⋅vA+rB⋅vB+rC⋅vC.
Observe that the only term in Mrx(ry) that depends on the prover’s witness is Z~(ry). This is because all other terms in the above expression can be computed locally by V using x=(F,A,B,C,io,m,n) in O(n) time ( in the paper discusses how to reduce the cost of those evaluations to be sub-linear in n).
To evaluate Z~(ry), V does the following. WLOG, assume ∣w∣=∣io∣+1. Thus, by the closed form expression of multilinear polynomial evaluations, we have:
V: Abort with IsSat=0 if ey=(rA⋅v1+rB⋅v2+rC⋅v3)⋅vZ
V: return IsSat=1
O(n) for each sumcheck instances
Cost of PC.Commit and PC.Eval for logm-variate multilinear polynomial w~(⋅).
O(logm) for each sumcheck instances
Cost of PC.Eval for logm-variate multilinear polynomial w~(⋅)
O(n) to evaluate A~,B~,C~ at (rx,ry)
O(logm) for each sumcheck instances
The size of the commitment to w~(⋅) and the communication in PC.Eval
The protocol described above is not succinct yet since the verifier incurs costs linear in the size of the R1CS instance to evaluate A~,B~,C~ at (rx,ry) on step 16. We can get around this by introducing an offline preprocessing step for V. In this offline step, V with access to non-io portions of an R1CS instance x=(F,A,B,C,io,m,n) executes the following, where ppcc←PC.Setup(1λ,2logm) and PC is an extractable polynomial commitment scheme for multilinear polynomials.
Encode(ppcc,(A,B,C)):
(CA,⊥)←PC.Commit(ppcc,A~)
(CB,⊥)←PC.Commit(ppcc,B~)
(CC,⊥)←PC.Commit(ppcc,C~)
After encoding, V retains the commitments and instead of evaluating at step 16, it verifies the opening proof of A~,B~,C~ at (rx,ry). Unfortunately, existing polynomial commitment schemes are not efficient enough to be practical. Since, the number of variables in A~,B~,C~ is 2logm, existing polynomial commitment schemes incur O(22logm)=O(m2)=O(n2) cost for the prover side. Furthermore, in schemes such as Hyrax-PC, VEval incurs O(n) costs. This problem is addressed by introducing a new cryptographic compiler to transform an existing extractable polynomial commitment scheme for dense multilinear polynomials to one that can efficiently handle sparse multilinear polynomials.
According to the table below, which is taken from the paper, among the proof-succinct NIZKs, SpartanNIZK is 100× faster than Hyrax, 113× faster than Aurora, and 22× faster than Ligero at 220 constraints. The commitment scheme used for this benchmark is Hyrax-PC over curve25519 ().