Polynomial commitment based on discrete-log and pairing
KZG: pairing
We have G as a group of prime order p with generator g. We have a bilinear map e:G×G→GT where G≅GT≅Cp are p-order cyclic groups. We use F=Fp≤d[X], and the public parameters gp are generated as
(g,gτ,gτ2,…,gτd)←setup(λ,F;τ)
where τ is a random element in Fp; after computing, abort the random τ. To commit to a polynomial f(X)=∑i=0dfiXi, we compute
i=0∏d(gτi)fi←commit(gp,f).
In the evaluation phase, with input u, the prover sends v and a proof π for the verifier to verify f(u)=v using π. The idea is if f(u)=v, then f(X)−v is divisible by X−u. Let q(X)=(f(X)−v)/(X−u), then the proof is written as π=gq(τ) and (v,π)←open(gp,f,u). The verifier checks if e(gτ−u,π)=e(gvcomf,g). The verifier knows gτ−u because it knows gτ from the global parameter and it can compute gu from u.
Time: commit O(d) group exponentiations, open (including computing q) O(d) group exponentiations and O(d) group multiplications, verify O(1) pairings. Size: proof and commitment are both O(1) group elements.
The completeness is trivial. For soundness, if the prover outputs another (v′,π′) such that f(u)=v′ and e(gτ−u,π′)=e(gv′comf,g), then we have (denote δ=f(u)−v′):
where the operations on the exponent are in Fp which corresponds to the multiplication in the groups G and GT. This is the q-Strong Bilinear Diffie-Hellman** assumption, which says that it is hard to compute e(g,g)τ−u1 given (p,G,g,GT,e) and gp=(g,gτ,…,gτd).
Knowledge Soundness
The plain KZG is not knowledge soundness without assumptions like KoE or GGM. We will discuss the assumptions in the PCP-based SNARK.
Zero-Knowledge-ness
The plain KZG is not zk since the commit algorithm is deterministic. For example, you can use gf(τ) to test if f is a zero polynomial. Here, we denote the protocol modified to zk in the graph below.
Setup: sample τ,η$Fp and compute gp←(g,gτ,…,gτd,gη); then delete τ,η.Proverr$Fp,comf=gf(τ)+rη←commit(gp,f;r)r′$Fp,v←f(u),π=(gq(τ)+r′η,gr−r′(τ−u))←open(gp,f,u,r;r′)comfu∈Fpv,πVerifiere(π1,gτ−u)e(π2,gη)=?e(gvcomf,g)
The polynomial is hidden by the random r′.
Variants of KZG
For multivariate poly: f(x1,…,xk)−f(u1,…,uk)=∑i∈[k](xi−ui)qi(x1,…,xk) . Prover computes and sends πi=gqi(τ1,…,τn) . Prover time is O(km) group exponentials where m≤2k is the number of terms of f . [Chopin] claims to reduce the prover time to m+O(m) MSMs (compute ∏jgjaj ).
For batch query on u1,…,um: f(x)−h(x)=q(x)∏i∈[m](x−ui) where h(x) is the extrapolation of (ui,f(ui))’s.
For multi-party, each party has a private number for setup, and the public parameters are (for example, 2-party) gp=(g,gst,…,g(st)d). The parameters can be generated party after party, since g(st)i=(gsi)ti.
And it is worth noting that PLONK uses univariate KZG and plonk IOP, while vSQL uses multivariate KZG and sum-check protocol.
Bulletproofs: discrete-log
KZG requires trusted setup. Here we present Bulletproofs which has transparent setup. The goal of the prover is to convince the verifier that f(u)=v where f=∑i=0d+1fixi∈Fp[X]. The setup phase is just a random gp=(gp0,0,…,gp0,d)∈G and we assume d+1=2k is some exponential of 2. Then the prover and verifier go through a interaction shown below:
round 1:round 2:round k:final :Provercomf=i=0∏2k−1gp0,ifi←commit(gp,f)f=f0→fL+u2k−1fR,L=i=0∏2k−1−1gp0,i+2k−1f0,i,R=i=2k−1∏2k−1gp0,i−2k−1f0,i,vL=fL(u),vR=fR(u)f1←rfL+fRf1→fL+u2k−2fR,L=i=0∏2k−2−1gp1,i+2k−2f1,i,R=i=2k−2∏2k−1−1gp1,i−2k−2f1,i,vL=fL(u),vR=fR(u)...fk−1→fL+ufR,L=gpk−1,1fk−1,0,R=gpk−1,0fk−1,1,vL=fL(u),vR=fR(u)fk∈Fp←rfL+fRcomf,vL,R,vL,vRgp1,rL,R,vL,vR...L,R,vL,vRgpk,rVerifier“I verify f0(u)=v ”: v=?vL+vRu2k−1gp1←(gp0,ir−1gp0,i+2k−1)i∈[0,2k−1),r$Fp[X],v1←rvL+vR,comf1←LrRr−1comf“ I verify f1(u)=v1”: v1=?vL+vRu2k−2...“I verify fk−1(u)=vk−1 ”: vk−1=?vL+vRugpk←(gpk−1,0r−1gpk−1,1),r$Fp[X],vk←rvL+vR,comfk←LrRr−1comfk−1“ I verify fk=vk as a constant polynomial ”: comfk=?gpkvk
The r’s at every round is sampled randomly and independently. Then we apply Fiat-Shamir to the protocol. The gp’s should be computed by the verifier to prevent backdoor in parameters.
Time analysis
Setup: O(d) sampling
Commit: O(d) group exponentiations
Prover: O(d) group exponentiations
Verifier: O(d) group exponentiations
The proof size is O(logd) group elements, and the commitment size is O(1) group elements (this is the first commitment comf. Other commitments are computed by the verifier).
Soundness analysis.
Statistical soundness: we assume the prover does not know the correct v. The final fk is a multilinear polynomial of all the random r’s, say fk=gf(r1,…,rk) and the function gf is deterministic. Note that every f corresponds to a unique gf.
So, conditioned on the prover does not know the correct v but send a v∗=v instead, we can say v∗=f∗(u) for some f∗=f. Thus by the Schwartz-Zippel lemma, we have
because f(u)=uTFu′=∑i=0d−1∑j=0d−1fi,juid+j.
Setup phase samples a random hash function. Then in commit phase, the prover encode each row of F with a [n,d] linear code (this encoding is a public algorithm, e.g. Reed-Solomon code), represented by a matrix C∈Fpd×n. The result is a matrix of d×n:
P=f0Cf1C⋮fd−1C.
After encoding, use Merkle tree to generate the commitment with the hash function in the global parameters. The leaf nodes are the n columns of the matrix P. The root hash is the commitment of the function.
Then the prover and verifier go through the following interaction to verify f(u)=x:
Proverw←rTF(originally we send encoded version rTP, this is for optimization)Generate Merkle proof π that the s-th column of P equals to v∈Fpdw′←uTFGenerate Merkle proof π that the s-th column of P equals to v∈Fpdrwsπ,vw′sπ,vVerifierr$Fpdw←wC is indeed a codewords$Fpverify the proof π, and verify rTv=ws, then repeat sampling s multiple timesw′←w′C is indeed a codewords$Fpverify the proof π, and verify rTv=ws′, then repeat sampling s multiple timesw′u′=?x
Analysis of the protocol is as follows:
Keygen: O(1), transparent
Commit:
Encoding: O(dlogd) field multiplications using Reed-Solomon code, O(d) using linear-time encodable code
Merkle tree: O(d) hashes, O(1) commitment size
Prover time: O(d) field multiplications
Proof size: O(d)
Verifier time: O(d)
Fast Reed-Solomon IOPP
Intro: Merkle trees for univariate poly-commitment
An intuitive attempt is to commit to a vector of evaluations of a given polynomial f∈Fp≤d[X]. The leaves of the tree are {f(x):x∈Fp} and the tree hashes every neighboring 2 nodes to form a new layer. When V requires f(r), the prover sends the hash values along the path up to the root.
The Merkle tree for commitment requires O(pd) field multiplication (using Qin-Horner method) to commit, and the proof size is O(logp) hash values. The verifier takes O(logp) hashes. The setup only generates a hash function, so it is transparent.
There are 2 problems:
The field may be very large; and the time is linear to the max degree.
The verifier cannot know if f has degree at most d.
Fix the Problem 1
FRI commitment uses a multiplicative subset of Fp: Ω={ωi:ωn=1,i=0,1,…,n−1}, for example, {1,3,9,27,−1,−3,−9,−27} in F41. The leaves of the Merkle tree will be the values f(ωi).
We call the rate ρ=nd the FRI blowup factor.
Fix the Problem 2
round 1:round 2:round log2k:query :Proverf0=f,degf0≤k−1,Ω0={1,ω,…,ωn−1},n=ρ−1kf0(X)=f0,e(X2)+Xf0,o(X2)f1(Z)=f0,e(Z)+r1f0,o(Z),degf1≤2k−1,Ω1={x2:x∈Ω0}f1(X)=f1,e(X2)+Xf1,o(X2)f2(Z)=f1,e(Z)+r2f1,o(Z),degf2≤4k−1,Ω2={x2:x∈Ω1}...ft−1(X)=ft−1,e(X2)+Xft−1,o(X2)ft(Z)=ft−1,e(Z)+rtft−1,o(Z),degft=0,Ωt={x2log2k:x∈Ω0}对于每个jq,打开从第t=log2k层到第0层的路径:πt,jq←MerkleOpen(comt,jq)πt−1,jq+,πt−1,jq−←MerkleOpen(comt−1,对应的两个索引)...com0=MerkleCommit(f0∣Ω0)r1com1=MerkleCommit(f1∣Ω1)r2com2=MerkleCommit(f2∣Ω2)rtcomt=ft∣Ωt{jq}q=1s所有打开值+路径Verifierr1$Fpr2$Fp...rt$Fpverify that ft∣Ωt is a constant vector随机选择j1,…,js∈[0,∣Ωt∣−1]验证每条路径的一致性;同时,对于第t层: ft(ωtjq)是常数对于第i层: 检查fi+1(z)=?2xri+1+xfi(x)+−2xri+1−xfi(−x)其中z=x2,x=ωij,ωi是第i层的生成元
Remark.
It is easy from fi∣Ωi to fi+1∣Ωi+1. This is because fi+1(x2)=fi,e(x2)+ri+1fi,o(x2)=2fi(x)+fi(−x)+ri+12xfi(x)−fi(−x). Also, the verifying process relies on this equation.
To analysis the soundness, we introduce the relative Hamming distance HamΩ(f,g)=∣Ω∣∣{x∈Ω:f(x)=g(x)}∣ and δ=minh∈Fp≤k−1[X](HamΩ(f,h)), which is the distance on Ω of f to the closest degree-(k−1) polynomial.
We consider f such that δ≤1−ρ, which is to say, the f is far from any degree-(k−1) polynomial.
A cheating prover has a high (>k−1) degree polynomial f. In case the prover is accepted, either it folds incorrectly, or it folds correctly and is lucky to have those ri’s that reduce the degree to 0 eventually. In the first case, the accept probability is (1−δ)t; in the second case, the accept probability is at most pk. As a result, to reach an accept probability 2−λ (λ is the security parameter), s should be Ω(logρ−1λ).
(The security proof is problematic.)
Polynomial commitment from FRI
The FRI introduces another two problems:
Prover has only committed to evaluations on a subset Ω⊂Fp.
Verifier only knows that f is close to a low-degree polynomial (in the sense of Hamming distance), but not necessarily a low-degree polynomial.
There is an attack to the first problem: the prover can commit to a polynomial g that agrees with f on T⊂Ω with much lower degree (∣T∣=k). Then δ<1−ρ<1−ρ and the soundness is broken.
Then to confirm that f(r)=v where f∈Fp≤d[X], the prover applies FRI on the polynomial (f(x)−v)/(x−r), which has degree at most d−1.
Fiat-Shamir transform
Definition. (Interactive Security) A poly-commitment scheme runs at λ bits of interactive security if and only if: assume P cannot find a collision of the hash function in the global parameters, then for every P∗, the probability that P∗ can make the verifier accept a false claim is at most 2−λ.
To find out if a challenge is lucky, the prover should interact with the verifier at least 2λ times in average. It is unlikely that V continues to interact after rejecting the same prover so many rounds. So following is the
Definition. (Non-interactive security) A poly-commitment scheme runs at λ bits of non-interactive security if and only if: for every P∗ willing to compute 2k hashs, the probability that P∗ can make the verifier accept a false claim is at most 2k−λ.
In this scheme, a lying P can propose the grinding attack silently, without interacting. This definition is weaker than the interactive security, i.e., if a prover breaks the interactive security of one interactive protocol, then it can also break the non-interactive security of the Fiat-Shamir transform of that protocol.
We show that Fiat-Shamir transform may be insecure. Consider a protocol of the empty language. In this protocol, P sends a nonce, and then V sends a random bit r, and accepts iff r=1. The V accepts iff every round it accepts, so the soundness error is 2−λ with λ rounds. However, the Fiat-Shamir transform of this protocol is insecure, since the prover can grind for a nonce 2 times per round in average, in order to find a nonce that leads to r=1 for every round. The cost is 2λ in average, which is much smaller than 2λ and the protocol does not satisfy the non-interactive security.
Applying Fiat-Shamir to a many-round interactive protocol can lead to a huge loss in security, whereby the resulting non-interactive protocol is totally insecure. So we need “round-by-round” soundness to describe the security of an interactive protocol, which means that for every prover in every round, if the prover is not “lucky” enough to make the verifier accept, then the probability that the prover can make the verifier accept in the next round is at most 2−λ.
The sum-check protocol is round-by-round sound, so its Fiat-Shamir transform is secure.