1. 引言
微软研究中心2020年论文《Spartan: Efficient and general-purpose zkSNARKs without trusted setup》,发表于Crypto 2020。
代码实现参见:
- https://github.com/microsoft/Spartan 【由Rust语言实现】
要点:
本论文实现了将R1CS instance ENCODE为 a degree-3 multivariate polynomial,变量个数为
⌈
log
m
⌉
\left \lceil \log m \right \rceil
⌈logm⌉。
以R1CS表示为:(其中
A
,
B
,
C
\mathbf{A},\mathbf{B},\mathbf{C}
A,B,C表示为n*m矩阵(
n
n
n行
m
m
m列,为简化表示,本论文中取n=m),
Z
⃗
\vec{Z}
Z为长度为
m
m
m的向量。)
(
A
Z
⃗
)
∗
(
B
Z
⃗
)
−
(
C
Z
⃗
)
=
0
⃗
(\mathbf{A}\vec{Z})*(\mathbf{B}\vec{Z})-(\mathbf{C}\vec{Z})=\vec{0}
(AZ)∗(BZ)−(CZ)=0
- Vitalik 博客Quadratic Arithmetic Programs: from Zero to Hero 中将R1CS转换为QAP——即 将
A
,
B
,
C
\mathbf{A},\mathbf{B},\mathbf{C}
A,B,C分别在
x
=
1
,
x
=
2
,
⋯
,
x
=
n
x=1,x=2,\cdots,x=n
x=1,x=2,⋯,x=n进行Lagrange插值为
m
m
m组degree为
n
−
1
n-1
n−1阶 单变量 多项式,最终的QAP表示为:【未对
Z
⃗
\vec{Z}
Z进行encode】
< Z ⃗ , [ A 1 ( x ) , ⋯ , A m ( x ) ] > ∗ < Z ⃗ , [ B 1 ( x ) , ⋯ , B m ( x ) ] > − < Z ⃗ , [ C 1 ( x ) , ⋯ , C m ( x ) ] > = H ∗ Z ( x ) <\vec{Z}, [A_1(x),\cdots, A_m(x)]>*<\vec{Z}, [B_1(x),\cdots,B_m(x)]>-<\vec{Z}, [C_1(x),\cdots, C_m(x)]>=H*Z(x) <Z,[A1(x),⋯,Am(x)]>∗<Z,[B1(x),⋯,Bm(x)]>−<Z,[C1(x),⋯,Cm(x)]>=H∗Z(x)
其中 Z ( x ) = ( x − 1 ) ( x − 2 ) ⋯ ( x − n ) Z(x)=(x-1)(x-2)\cdots (x-n) Z(x)=(x−1)(x−2)⋯(x−n)
- 本文,取
s
=
⌈
log
m
⌉
s=\left \lceil \log m \right \rceil
s=⌈logm⌉,以具有
s
s
s个变量的multilinear 多项式
Z
(
y
⃗
)
=
Z
(
y
1
,
⋯
,
y
s
)
=
a
0
+
a
1
y
1
+
a
2
y
2
+
a
3
y
3
+
a
4
y
1
y
2
+
a
5
y
1
y
3
+
a
6
y
2
y
3
+
a
7
y
1
y
2
y
3
+
⋯
+
a
2
s
−
1
y
1
y
2
⋯
y
s
Z(\vec{y})=Z(y_1,\cdots,y_s)=a_0+a_1y_1+a_2y_2+a_3y_3+a_4y_1y_2+a_5y_1y_3+a_6y_2y_3+a_7y_1y_2y_3+\cdots+a_{2^s-1}y_1y_2\cdots y_s
Z(y)=Z(y1,⋯,ys)=a0+a1y1+a2y2+a3y3+a4y1y2+a5y1y3+a6y2y3+a7y1y2y3+⋯+a2s−1y1y2⋯ys来表示
Z
⃗
\vec{Z}
Z,使得
Z
[
0
]
=
Z
(
0
,
0
,
⋯
,
0
)
,
⋯
,
Z
[
m
]
=
Z
(
1
,
1
,
⋯
,
1
)
Z[0]=Z(0,0,\cdots,0),\cdots,Z[m]=Z(1,1,\cdots,1)
Z[0]=Z(0,0,⋯,0),⋯,Z[m]=Z(1,1,⋯,1)。
仍然以Vitalik 博客Quadratic Arithmetic Programs: from Zero to Hero 中的 Z ⃗ = [ 1 , 3 , 35 , 9 , 27 , 30 ] \vec{Z}=[1,3,35,9,27,30] Z=[1,3,35,9,27,30]为例,可以 s = ⌈ log 6 ⌉ = 3 s=\left \lceil \log 6 \right \rceil=3 s=⌈log6⌉=3个变量的multilinear 多项式 Z ( y ⃗ ) = Z ( y 1 , y 2 , y 3 ) = 1 + 26 y 1 + 34 y 2 + 2 y 3 − 28 y 2 y 3 + y 1 y 3 Z(\vec{y})=Z(y_1,y_2,y_3)=1+26y_1+34y_2+2y_3-28y_2y_3+y_1y_3 Z(y)=Z(y1,y2,y3)=1+26y1+34y2+2y3−28y2y3+y1y3 来表示,使得 Z ( 0 , 0 , 0 ) = 1 , Z ( 0 , 0 , 1 ) = 3 , Z ( 0 , 1 , 0 ) = 35 , Z ( 0 , 1 , 1 ) = 9 , Z ( 1 , 0 , 0 ) = 27 , Z ( 1 , 0 , 1 ) = 30 Z(0,0,0)=1,Z(0,0,1)=3,Z(0,1,0)=35, Z(0,1,1)=9, Z(1,0,0)=27, Z(1,0,1)=30 Z(0,0,0)=1,Z(0,0,1)=3,Z(0,1,0)=35,Z(0,1,1)=9,Z(1,0,0)=27,Z(1,0,1)=30。【即通过多变量multilinear多项式 Z ( y ⃗ ) Z(\vec{y}) Z(y)来表示 Z ⃗ \vec{Z} Z】
同理,对于R1CS矩阵 A , B , C ∈ F n × m \mathbf{A},\mathbf{B},\mathbf{C}\in\mathbb{F}^{n\times m} A,B,C∈Fn×m,相当于在Vitalik博客介绍的单变量多项式 A ( x ) A(x) A(x)的基础上,增加了 y ⃗ \vec{y} y变量,构建多变量multilinear多项式 A ( x , y ⃗ ) = A ( x , y 1 , y 2 , y 3 ) A(x,\vec{y})=A(x,y_1,y_2,y_3) A(x,y)=A(x,y1,y2,y3),使得 A ( x , 0 , 0 , 0 ) = A 1 ( x ) , A ( x , 0 , 0 , 1 ) = A 2 ( x ) , A ( x , 0 , 1 , 0 ) = A 3 ( x ) , A ( x , 0 , 1 , 1 ) = A 4 ( x ) , A ( x , 1 , 0 , 0 ) = A 5 ( x ) , A ( x , 1 , 0 , 1 ) = A 6 ( x ) A(x,0,0,0)=A_1(x), A(x,0,0,1)=A_2(x), A(x,0,1,0)=A_3(x), A(x,0,1,1)=A_4(x), A(x,1,0,0)=A_5(x), A(x,1,0,1)=A_6(x) A(x,0,0,0)=A1(x),A(x,0,0,1)=A2(x),A(x,0,1,0)=A3(x),A(x,0,1,1)=A4(x),A(x,1,0,0)=A5(x),A(x,1,0,1)=A6(x)成立。从而有:
F i o ( x ) = ( ∑ y ⃗ ∈ { 0 , 1 } s A ( x , y ⃗ ) ⋅ Z ( y ⃗ ) ) ⋅ ( ∑ y ⃗ ∈ { 0 , 1 } s B ( x , y ⃗ ) ⋅ Z ( y ⃗ ) ) − ∑ y ⃗ ∈ { 0 , 1 } s C ( x , y ⃗ ) ⋅ Z ( y ⃗ ) F_{io}(x)=(\sum_{\vec{y}\in\{0,1\}^s}A(x,\vec{y})\cdot Z(\vec{y}))\cdot (\sum_{\vec{y}\in\{0,1\}^s}B(x,\vec{y})\cdot Z(\vec{y}))-\sum_{\vec{y}\in\{0,1\}^s}C(x,\vec{y})\cdot Z(\vec{y}) Fio(x)=(∑y∈{0,1}sA(x,y)⋅Z(y))⋅(∑y∈{0,1}sB(x,y)⋅Z(y))−∑y∈{0,1}sC(x,y)⋅Z(y)
当任意的 x = 1 , x = 2 , ⋯ , x = n x=1,x=2,\cdots,x=n x=1,x=2,⋯,x=n时, F i o ( x ) = 0 F_{io}(x)=0 Fio(x)=0。
但是 F i o ( ⋅ ) F_{io}(\cdot) Fio(⋅)为a function,不是a polynomial,无法直接使用the sum-check protocol。(详细可参见博客 function和polynomial的关系)
需要将function扩展为polynomial:
F ~ i o : F s → F \tilde{F}_{io}:\mathbb{F}^s\rightarrow \mathbb{F} F~io:Fs→F
即:
F ~ i o ( x ) = ( ∑ y ⃗ ∈ { 0 , 1 } s A ~ ( x , y ⃗ ) ⋅ Z ~ ( y ⃗ ) ) ⋅ ( ∑ y ⃗ ∈ { 0 , 1 } s B ~ ( x , y ⃗ ) ⋅ Z ~ ( y ⃗ ) ) − ∑ y ⃗ ∈ { 0 , 1 } s C ~ ( x , y ⃗ ) ⋅ Z ~ ( y ⃗ ) \tilde{F}_{io}(x)=(\sum_{\vec{y}\in\{0,1\}^s}\tilde{A}(x,\vec{y})\cdot \tilde{Z}(\vec{y}))\cdot (\sum_{\vec{y}\in\{0,1\}^s}\tilde{B}(x,\vec{y})\cdot \tilde{Z}(\vec{y}))-\sum_{\vec{y}\in\{0,1\}^s}\tilde{C}(x,\vec{y})\cdot \tilde{Z}(\vec{y}) F~io(x)=(∑y∈{0,1}sA~(x,y)⋅Z~(y))⋅(∑y∈{0,1}sB~(x,y)⋅Z~(y))−∑y∈{0,1}sC~(x,y)⋅Z~(y)
当任意的 x = 1 , x = 2 , ⋯ , x = n x=1,x=2,\cdots,x=n x=1,x=2,⋯,x=n时, F ~ i o ( x ) = F i o ( x ) = 0 \tilde{F}_{io}(x)=F_{io}(x)=0 F~io(x)=Fio(x)=0。
此时 F ~ i o ( ⋅ ) \tilde{F}_{io}(\cdot) F~io(⋅)为a low-degree multivariate polynomial over F \mathbb{F} F in s s s variables,且此时verifier V V V 可check if ∑ { 0 , 1 } s F ~ i o ( x ) = 0 \sum_{\{0,1\}^s}\tilde{F}_{io}(x)=0 ∑{0,1}sF~io(x)=0 using the sum-check protocol with a prover P P P。但是,若 ∑ i = 1 n − 1 F ~ i o ( i ) = 0 \sum_{i=1}^{n-1}\tilde{F}_{io}(i)=0 ∑i=1n−1F~io(i)=0并不代表对任意的 { x = 1 , x = 2 , ⋯ , x = n } \{x=1,x=2,\cdots,x=n\} {x=1,x=2,⋯,x=n} F ~ i o ( x ) = 0 \tilde{F}_{io}(x)=0 F~io(x)=0 成立。因此,需要借助[13,32,43]的思想,构建多变量多项式 Q i o ( t ⃗ ) Q_{io}(\vec{t}) Qio(t)使得其为zero-polynomial if and only if F ~ i o ( ⋅ ) \tilde{F}_{io}(\cdot) F~io(⋅) evaluates to zero at all points in the s s s-dimensional Boolean hypercube:
注意, Q i o ( ⋅ ) Q_{io}(\cdot) Qio(⋅) is a multivariate polynomial such that Q i o ( t ⃗ ) = F ~ i o ( t ⃗ ) Q_{io}(\vec{t})=\tilde{F}_{io}(\vec{t}) Qio(t)=F~io(t) for all t ∈ { 0 , 1 } s t\in\{0,1\}^s t∈{0,1}s。因此, Q i o ( t ⃗ ) Q_{io}(\vec{t}) Qio(t)为zero-polynomial (如,it evaluates to 0 for all points in its domain) if and only if F ~ i o ( ⋅ ) \tilde{F}_{io}(\cdot) F~io(⋅) evaluates to zero at all points in the s s s-dimensional Boolean hypercube (也意味着,if and only if F ~ i o ( ⋅ ) \tilde{F}_{io}(\cdot) F~io(⋅) encodes a witness w w w such that S a t R 1 C S = ( X , w ) = 1 Sat_{R1CS}=(\mathbb{X},w)=1 SatR1CS=(X,w)=1)。
为了验证 Q i o ( ⋅ ) Q_{io}(\cdot) Qio(⋅)是a zero-polynomial,仅需验证 Q i o ( τ ) = 0 Q_{io}(\tau)=0 Qio(τ)=0就足够了,其中 τ ∈ R F s \tau\in_R\mathbb{F}^s τ∈RFs。
对于R1CS instance X = ( F , A , B , C , i o → , m , n ) \mathbb{X}=(\mathbb{F}, \mathbf{A}, \mathbf{B}, \mathbf{C}, \overrightarrow{io}, m, n) X=(F,A,B,C,io,m,n),定义 G i o , τ ( x ) = F ~ i o ( x ) ⋅ e q ~ ( τ , x ) \mathcal{G}_{io,\tau}(x)=\tilde{F}_{io}(x)\cdot \tilde{eq}(\tau,x) Gio,τ(x)=F~io(x)⋅eq~(τ,x),使得 Q i o ( τ ) = ∑ x ∈ { 0 , 1 } s G i o , τ ( x ) Q_{io}(\tau)=\sum_{x\in\{0,1\}^s}\mathcal{G}_{io,\tau}(x) Qio(τ)=∑x∈{0,1}sGio,τ(x)。注意其中 G i o , τ ( ⋅ ) \mathcal{G}_{io,\tau}(\cdot) Gio,τ(⋅)为a degree-3 s s s-variate polynomial if multilinear extensions of A , B , C , Z ⃗ \mathbf{A},\mathbf{B},\mathbf{C},\vec{Z} A,B,C,Z are used in F ~ ( ⋅ ) \tilde{F}(\cdot) F~(⋅)。
此外,若 τ ∈ R F s \tau\in_R\mathbb{F}^s τ∈RFs,则 ∑ x ∈ { 0 , 1 } s G i o , τ ( x ) = 0 \sum_{x\in\{0,1\}^s}\mathcal{G}_{io,\tau}(x)=0 ∑x∈{0,1}sGio,τ(x)=0 if and only if F ~ i o ( x ) = 0 \tilde{F}_{io}(x)=0 F~io(x)=0 for ∀ x ∈ { 0 , 1 } s \forall x\in\{0,1\}^s ∀x∈{0,1}s——except for soundness error that is negligible in λ \lambda λ under the assumptions noted in lemma 4.3。
本文构建的Spartan,为针对rank-1 constraint satisfiability (R1CS) 构建的zkSNARK,为an NP-complete language that generalizes arithmetic circuit satisfiability:
- 构建了第一个without trusted setup 的zkSNARK (可称为transparent zkSNARK)for NP。
- verify a proof incurs sub-linear costs——without requiring uniformity in the NP statement’s structure。
- 可支持time-optimal prover,该属性现有zkSNARKs文献中均未提及。
本文构建了一种具有重大意义的interactive proof protocol——sum-check protocol,相关关键技术有:
- 1)computation commitments:a primitive用于为a description of computation 创建succinct commitment,该技术对于Verifier achieve sub-linear costs after investing a one-time, public computation to preprocess a given NP statement至关重要。
- 2)SPARK:a cryptographic compiler to transform any existing extractable polynomial commitment scheme for multilinear polynomials to one that efficiently handles sparse multilinear polynomials,该技术对于实现a time-optimal prover很重要。
- 3)a compact encoding of an R1CS instance as a low-degree polynomial。
最终的结果是a public-coin succinct interactive argument of knowledge for NP (which can be viewed as a succinct variant of the sum-check protocol),本文借助以上技术将其转换为a zkSNARK。通过将SPARK用于不同的commitment schemes,可实现多种zkSNARKs,相应的Verifier’s costs和proof size可range from O ( log 2 n ) O(\log^2n) O(log2n) to O ( n ) O(\sqrt{n}) O(n) depending on the underlying commitment scheme (其中 n n n表示the size of the NP statement)。除了其中一种需要a universal trusted setup之外,其它的schemes都不需要trusted setup。
https://github.com/microsoft/Spartan
由约8000行Rust语言组成,实现了a transparent zkSNARK in the random oracle model,其中security holds under the discrete logarithm assumption。
以具有
2
20
2^{20}
220个constraints的R1CS为例:
- 与现有的transparent zkSNARKs方案相比:
Spartan实现了最快的Prover(36~152倍 depending on the baseline),生成了更短的proof size(1.2~416倍),具有最少的verification time (缩短 3.6~1326倍)。唯一例外的是proof size under Bulletproofs,其具有slower verification both asymptotically and concretely。【Bulletproofs生成的proof size比Spartan短,但是具有更慢的verification both asymptotically and concretely。】 - 与现有的trusted setup zkSNARKs方案相比:
Spartan的Prover比任意R1CS instances快2倍,若支持data-parallel workloads,其速度将快16倍。
zkSNARKs可广泛用于delegation of computation或者是privacy。
本文主要关注的是针对satisfiability of R1CS instances over a finite field
F
\mathbb{F}
F构建的zkSNARKs。
R1CS为an NP-complete language that generalizes arithmetic circuit satisfiability:
已知 a problem instance
X
=
(
F
,
A
,
B
,
C
,
i
o
,
m
,
n
)
\mathbb{X}=(\mathbb{F},\mathbf{A},\mathbf{B},\mathbf{C},io,m,n)
X=(F,A,B,C,io,m,n),需要证明the knowledge of a witness
w
w
w,使得
S
a
t
R
1
C
S
(
X
,
w
)
=
1
Sat_{R1CS}(\mathbb{X},w)=1
SatR1CS(X,w)=1成立。
本文之所以关注R1CS的zkSNARKs,是因为目前有很多现有的工具可将high-level applications 转换为R1CS:[18, 20, 24, 38, 75, 88, 91, 95, 102].
- Ben-Sasson等人2013年论文《Fast reductions from RAMs to delegatable succinct constraint satisfaction problems: Extended abstract》
- Ben-Sasson等人2013年论文《SNARKs for C: Verifying program executions succinctly and in zero knowledge》
- Ben-Sasson等人2014年论文《Succinct non-interactive zero knowledge for a von Neumann architecture》
- Braun等人2013年论文《Verifying computations with state》
- Kosba等人 2018年论文《xJsnark: A framework for efficient verifiable computation》
- Parno等人2013年论文《Pinocchio: Nearly practical verifiable computation》
- Setty等人2018年论文《Proving the correct execution of concurrent services in zero-knowledge》
- Setty等人2012年论文《Taking proof-based verified computation a few steps closer to practicality》
- Wahby等人2015年论文《Efficient RAM and control flow in verifiable outsourced computation》
1.1 相关研究成果
-
1992年,Kilian论文《A note on efficient zero-knowledge proofs and arguments (extended abstract)》 中首次将probabilistically checkable proof (PCPs) 与Merkle trees结合,实现了succinct interactive argument protocol。
-
1994年,Micali论文《CS proofs》中借助random oracle model,实现了与Kilian类似的protocol,是第一个zkSNARK。
但是,其底层的PCP机制对于Prover和Verifier来说,仍然是extremely expensive的。 -
2007年,Ishai等人论文《Efficient arguments without short PCPs》中涉及了第一个interactive argument protocol without employing short PCPs。该论文中使用了linear PCPs,a type of PCP in which the proof is a linear function。linear PCPs比short PCPs更简单,但是也是size exponential in n n n。
-
2013年,Gennaro 等人论文 [GGPR]《Quadratic span programs and succinct NIZKs without PCPs》 中引入了quadratic arithmetic programs (QAPs)概念,构建了a zkSNARK for R1CS,其中Prover的running time为 O ( n log n ) O(n\log n) O(nlogn),proof size为 O ( 1 ) O(1) O(1),验证proof时Verifier需要 O ( ∣ i o ∣ ) O(|io|) O(∣io∣) computation,其中 n n n为statement size, i o io io为public input and output。
但是,[GGPR] 论文需要a per-statement trusted setup来生成 an O λ ( n ) O_{\lambda}(n) Oλ(n)-sized structured common reference string,在setup过程中的trapdoor信息必须保持secret以保证soundness。
在[GGPR]的基础上进行了改进的相关研究成果有:[20, 24, 30, 64, 66, 88],[93]
1)Ben-Sasson等人2013年论文《SNARKs for C: Verifying program executions succinctly and in zero knowledge》 【需要trusted setup】
2)Ben-Sasson等人2014年论文《Succinct non-interactive zero knowledge for a von Neumann architecture》【需要trusted setup】
3)Bitansky等人2013年论文《Succinct non-interactive arguments via linear interactive proofs》【需要trusted setup】
4)Groth等人2016年论文《On the size of pairing-based non-interactive arguments》【需要trusted setup】
5)Groth等人2018年论文《Updatable and universal common reference strings with applications to zk-SNARKs》【需要trusted setup】
6)Parno等人2013年论文《Pinocchio: Nearly practical verifiable computation》【需要trusted setup】
7)Setty等人2013年论文《Resolving the conflict between generality and plausibility in verified computation》【需要interaction】
1.1.1 transparent zkSNARKs
与以上需要trusted setup的zkSNARKs相对应的是transparent zkSNARKs,其目标是去除trusted setup。transparent zkSNARKs prove security in the random oracle model, which is acceptable in practice。transparent zkSNARKs相关研究成果有:
- Wahby等人2018年论文《Hyrax: Doubly-efficient zkSNARKs without trusted setup》中实现了doubly-efficient interactive proofs (IPs) 的transparent zkSNARKs。
- Ben-Sasson等人2018年论文《STARK: Scalable, transparent, and post-quantum secure computational integrity》 和 Ben-Sasson等人2019年论文《Aurora: Transparent succinct arguments for R1CS》 基于interactive oracle proofs (IOPs) 构建了transparent zkSNARKs。
- Ames等人2017年论文《Ligero: Lightweight sublinear arguments without a trusted setup》 基于“MPC in the head” paradigm 构建了transparent zkSNARKs。
- Bunz等人2018年论文《Bulletproofs: Short proofs for confidential transactions and more》和在 Bootle等人2016年论文《Efficient Zero-Knowledge Arguments for Arithmetic Circuits in the Discrete Log Setting》的基础上,构建了transparent zkSNARKs。
- Bunz等人2019年论文《Supersonic: Transparent SNARKs from DARK Compilers》中的transparent polynomial commitment scheme。
- Chiesa等人2019年论文《Fractal: Post-quantum and transparent recursive proofs from holography》
- J. Zhang等人2020年论文《Virgo: Transparent polynomial delegation and its applications to zero knowledge proof》中的transparent polynomial commitment scheme。
但是以上transparent zkSNARKs存在如下问题:
- Hyrax:计算模型为layered arithmetic circuits,其中Verifier cost和proof size都将随着circuit depth线性增加。而将任意的circuit转换为layered form将increase its size quadratically。因此Hyrax适合用于low-depth circuits。同时,Hyrax将达成sub-linear verification costs only for circuits with a uniform structure (e.g., data-parallel circuits)。
- STARK:需要circuits具有a sequence of identical sub-circuits,否则无法达成sub-linear verification costs。任意的circuit都可转换为具有a sequence of identical sub-circuits的形式,但是该转换将使得circuit size增加10~1000倍,这将相应地增加Prover’s cost。
- Ligero, Bulletproofs和Aurora均需要 O ( n ) O(n) O(n) verification costs。
- Virgo的computation model与Hyrax一样,仅能对low-depth, uniform circuits实现sub-linear verification costs。
- Fractal和Supersonic可对任意NP statements达成sub-linear verification costs:Verifier对NP statement进行preprocess过程中不需要secret trapdoors,来创建commitment to the structure of the statement。换句话说,他们实例化了the computation commitment primitive,但是他们需要orders of magnitude higher expense than Spartan。
相关对比为:
其中:
-
S
p
a
r
t
a
n
K
E
Spartan_{KE}
SpartanKE:基于的是
q
q
q-type knowledge of exponent assumption,借鉴了Xie等人2019年论文《Libra: Succinct zero-knowledge
proofs with optimal prover computation》中的思想。相比于Libra, S p a r t a n K E Spartan_{KE} SpartanKE支持任意的R1CS instances而不是layered arithmetic circuits。另外,与Libra不同, S p a r t a n K E Spartan_{KE} SpartanKE的proof size和Verifier的running time 都不会scale linearly with the circuit depth。Libra仅对low-depth uniform circuits实现了sub-linear verification costs,而 S p a r t a n K E Spartan_{KE} SpartanKE借助computation commitments,对任意的R1CS instance都实现了sub-linear verification cost。 - S p a r t a n D L Spartan_{DL} SpartanDL:基于的是discrete logarithm assumption。
- S p a r t a n R O Spartan_{RO} SpartanRO:基于的是post-quantum secure assumption。
- S p a r t a n C L Spartan_{CL} SpartanCL:基于的是 Supersonic算法中的unknown order group 构建的,其commitment scheme做了调整。
而 S p a r t a n D L Spartan_{DL} SpartanDL,本文做了两种实现:
- S p a r t a n S N A R K Spartan_{SNARK} SpartanSNARK:具有sub-linear verification。
- S p a r t a n N I Z K Spartan_{NIZK} SpartanNIZK:具有linear-time verification。
1.1.2 transparent polynomial commitment scheme
现有的transparent polynomial commitment scheme有:[39,103,107]
- Bunz等人2019年论文《Supersonic: Transparent SNARKs from DARK Compilers》中的transparent polynomial commitment scheme。
- Wahby等人2018年论文《Hyrax: Doubly-efficient zkSNARKs without trusted setup》中的transparent polynomial commitment scheme。
- J. Zhang等人2020年论文《Virgo: Transparent polynomial delegation and its applications to zero knowledge proof》中的transparent polynomial commitment scheme。
1.1.3 offline memory checking 技术
现有的offline memory checking techniques有:[7, 31, 47, 53, 91]
- Arasu等人2017年论文《Concerto: A high concurrency key-value store with integrity》
- Blum等人1991年论文《Checking the correctness of memories》
- Clarke等人2003年论文《Incremental multiset hash functions and their application to memory integrity checking》
- Dwork等人2007年论文《How efficient can memory checking be?》
- Setty等人2018年论文《Proving the correct execution of concurrent services in zero-knowledge》
1.2 本文主要贡献
本文构建的Spartan,可用于证明satisfiability of NP statements expressed in R1CS:
- 是目前第一个具有sub-linear verification costs for arbitrary NP statements的transparent zkSNARK。
- 同时可支持time-optimal prover属性,现有的zkSNARKs方案都很难实现。
- 将polynomial commitment scheme作为a black box,使得支持a family of zkSNARKs where each variant employs a different polynomial commitment scheme。
- 陈述了doubly-efficient IPs, MIPs和short PCPs这些概念之间的联系。
- 实现了sum-check protocol——意义重大的interactive proof protocol,其具有unconditionally soundness,可用于a suitably-constructed low-degree polynomial,从而可生成powerful但低效的interactive proof protocol,其中低效问题可引入以下新技术来解决:
1)computation commitments:【可实现sub-linear verification cost】
a primitive for creating succinct cryptographic commitments to a mathematical description of an NP statement。
通过引入a public preprocessing setup来实现sub-linear verification cost。
computation commitments支持verifiably delegating the necessary polynomial evaluations to the prover。
在Spartan中:
(a)Verifier读取an R1CS instance (without the i o io io component),然后保留a short cryptographic commitment to a set of sparse multilinear polynomials that encode the R1CS structure。
(b)Prover生成proof时,会evaluate the necessary polynomials同时证明the sparse polynomial evaluations are consistent with the commitment retained by the Verifier。
(c)Verifier需要 O ( n ) O(n) O(n) cost来计算computation commitments,该cost可amortized over all future proofs produced for all R1CS instances with the same structure。该amortization方法与Gennaro 等人2013年论文 [GGPR]《Quadratic span programs and succinct NIZKs without PCPs》 中的方法类似,只是[GGPR]需要trusted setup,而本文的computation commitment不需要任何secret trapdoors。
2)SPARK:【可实现time-optimal prover】
a cryptographic compiler,用于将任意的extractable polynomial commitment scheme for multilinear polynomials 转换为 one that efficiently handles sparse multilinear polynomials。
借助SPARK compiler,可实现time-optimal costs for both creating commitments to sparse multilinear polynomials and to produce proofs of evaluations of the committed polynomials。
SPARK将现有的extractable polynomial commitment scheme作为a black box,然后将其与special-purpose zkSNARK和使用了offline memory checking 技术的 carefully-constructed circuit结合,实现了efficiently prove evaluations of sparse multilinear polynomials。
3)将R1CS instance compact encode为a degree-3 multivariate polynomial,该degree为3的多变量多项式可分解为4个multilinear polynomials。【该多项式分解过程可实现time-optimal prover in the sum-check protocol。】
- Spartan改进了之前需要universal trusted setup的zkSNARKs:
对于[87,108]中需要q-type, knowledge of exponent assumption的polynomial commitment scheme, Spartan提供了Libra [106]的一种备选方案—— S p a r t a n K E Spartan_{KE} SpartanKE。相比于Libra, S p a r t a n K E Spartan_{KE} SpartanKE支持任意的R1CS instances而不是layered arithmetic circuits。另外,与Libra不同, S p a r t a n K E Spartan_{KE} SpartanKE的proof size和Verifier的running time 都不会scale linearly with the circuit depth。Libra仅对low-depth uniform circuits实现了sub-linear verification costs,而 S p a r t a n K E Spartan_{KE} SpartanKE借助computation commitments,对任意的R1CS instance都实现了sub-linear verification cost。
1.3 相关约定
- F \mathbb{F} F表示a finite field。
- F p \mathbb{F}_p Fp 表示a prime field for a large prime p p p。
- λ \lambda λ表示security parameter。
- n e g l ( λ ) negl(\lambda) negl(λ)表示a negligible function in λ \lambda λ。
- PPT algorithm:表示 probabilistic polynomial time algorithms。
- R1CS instance定义:
可参看博客 rank-1 constraint system R1CS 中的例子说明。
R1CS generalizes arithmetic circuit satisfiability,原因在于:在 A , B , C \mathbf{A},\mathbf{B},\mathbf{C} A,B,C 矩阵中的entries可用于encode addition和multiplication gates over F \mathbb{F} F。也可用于encode a class of degree-2 constraints of the form L ( z ⃗ ) ⋅ R ( z ⃗ ) = O ( z ⃗ ) L(\vec{z})\cdot R(\vec{z})=O(\vec{z}) L(z)⋅R(z)=O(z),其中 L , R , O L,R,O L,R,O为degree-1 polynomials over variables that take values specified by z ⃗ = ( i o → , 1 , w ⃗ ) \vec{z}=(\overrightarrow{io},1,\vec{w}) z=(io,1,w)。换句话说,R1CS支持arbitrary fan-in addition gates, and multiplication gates that verify arbitrary bilinear relations over the entire z ⃗ \vec{z} z。
可有如下定义:
1.4 多项式及其low-degree extension
-
polynomial G \mathcal{G} G over F \mathbb{F} F 表示的是:
monomials(单项式)之和
其中每个单项式是 the product of a constant (from F \mathbb{F} F) and powers of one or more variables (which take values from F \mathbb{F} F)。所有的计算都performed over F \mathbb{F} F。 -
单项式的degree为:the sum of the exponents of variables in the monomial。
-
多项式的degree为:the maximum degree of any monomial in G \mathcal{G} G。
-
多项式的degree in a particular variable x i x_i xi为:the maximum exponent that x i x_i xi takes in any of the monomials in G \mathcal{G} G。
-
多变量多项式是指:具有不只一个变量的多项式。只有一个变量的多项式称为univariate polynomial单变量多项式。
-
multilinear polynomial是指:多变量多项式的任一变量的degree均不大于1.
-
low-degree polynomial是指:多变量多项式 G \mathcal{G} G over a finite field F \mathbb{F} F 的degree in each variable is exponentially smaller than ∣ F ∣ |\mathbb{F}| ∣F∣。
-
Low-degree extensions (LDEs)是指:假设 g : { 0 , 1 } m → F g:\{0,1\}^m\rightarrow \mathbb{F} g:{0,1}m→F为a function that maps m m m-bit elements into an element of F \mathbb{F} F。 A polynomial extension of g g g is a low-degree m m m-variate polynomial g ~ ( ⋅ ) \tilde{g}(\cdot) g~(⋅) 使得 g ~ ( x ) = g ( x ) \tilde{g}(x)=g(x) g~(x)=g(x) for all x ∈ { 0 , 1 } m x\in\{0,1\}^m x∈{0,1}m。
-
multilinear polynomial extension (简称为MLE) 是指:Given a function Z : { 0 , 1 } m → F Z:\{0,1\}^m\rightarrow \mathbb{F} Z:{0,1}m→F,the multilinear extension of Z ( ⋅ ) Z(\cdot) Z(⋅) is the unique multilinear polynomial Z ~ : F m → F \tilde{Z}: \mathbb{F}^m\rightarrow \mathbb{F} Z~:Fm→F。计算方式为:
Z ~ ( x 1 , ⋯ , x m ) = ∑ e ∈ { 0 , 1 } m Z ( e ) ⋅ ∏ i = 1 m ( x i ⋅ e i + ( 1 − x i ) ⋅ ( 1 − e i ) ) = ∑ e ∈ { 0 , 1 } m Z ( e ) ⋅ e q ~ ( x , e ) = < ( Z ( 0 ) , ⋯ , Z ( 2 m − 1 ) ) , ( e q ~ ( x , 0 ) , ⋯ , e q ~ ( x , 2 m − 1 ) ) > \tilde{Z}(x_1,\cdots,x_m)=\sum_{e\in\{0,1\}^m}Z(e)\cdot \prod_{i=1}^{m}(x_i\cdot e_i+(1-x_i)\cdot (1-e_i))=\sum_{e\in\{0,1\}^m}Z(e)\cdot \tilde{eq}(x,e)=<(Z(0),\cdots,Z(2^m-1)), (\tilde{eq}(x,0),\cdots, \tilde{eq}(x,2^m-1))> Z~(x1,⋯,xm)=∑e∈{0,1}mZ(e)⋅∏i=1m(xi⋅ei+(1−xi)⋅(1−ei))=∑e∈{0,1}mZ(e)⋅eq~(x,e)=<(Z(0),⋯,Z(2m−1)),(eq~(x,0),⋯,eq~(x,2m−1))>
其中 e q ~ ( x , e ) = ∏ i = 1 m ( e i ⋅ x i + ( 1 − e i ) ⋅ ( 1 − x i ) ) \tilde{eq}(x,e)=\prod_{i=1}^{m}(e_i\cdot x_i+(1-e_i)\cdot (1-x_i)) eq~(x,e)=∏i=1m(ei⋅xi+(1−ei)⋅(1−xi)), e q ~ ( x , e ) \tilde{eq}(x,e) eq~(x,e) is the MLE of the following function:
e q ( x , e ) = { 1 if x=e 0 otherwise eq(x,e)= \left\{\begin{matrix} 1 & \text{if x=e} \\ 0 &\text{otherwise} \end{matrix}\right. eq(x,e)={10if x=eotherwise
对于任一的 r ∈ F m r\in\mathbb{F}^m r∈Fm,可在 O ( 2 m ) O(2^m) O(2m)次operations in F \mathbb{F} F 之内计算出 Z ~ ( r ) \tilde{Z}(r) Z~(r)的值。
由于a function的MLE是唯一的,因此MLE可用于represent 任意的multilinear polynomial。对于a multilinear polynomial
G
(
⋅
)
:
F
m
→
F
\mathcal{G}(\cdot):\mathbb{F}^m\rightarrow \mathbb{F}
G(⋅):Fm→F,可唯一表示为 the list of evaluations of
G
(
⋅
)
\mathcal{G}(\cdot)
G(⋅) over the Boolean hypercube
{
0
,
1
}
m
\{0,1\}^m
{0,1}m (如a function that maps
{
0
,
1
}
m
→
F
\{0,1\}^m\rightarrow \mathbb{F}
{0,1}m→F)。这种表示方式可称为
D
e
n
s
e
R
e
p
r
(
G
)
DenseRepr(\mathcal{G})
DenseRepr(G)。
2. 针对multilinear polynomial的polynomial commitment
Bunz等人2020年论文《Supersonic: Transparent SNARKs from DARK Compilers》 中将Kate等人2010年论文《Constant-size commitments to polynomials and their applications》中的定义generalize为允许interactive evaluation proof。
本文借用了Supersonic中的标记方式:
在a list of arguments或者returned tuples中,分号之前的变量为public info,分号后面的为secret info。若没有secret info,可忽略分号。
针对multilinear polynomial的polynomial commitment,主要包含4个算法 P C = ( S e t u p , C o m m i t , O p e n , E v a l ) PC=(Setup,Commit,Open,Eval) PC=(Setup,Commit,Open,Eval):
- p p ← S e t u p ( 1 λ , μ ) pp\leftarrow Setup(1^{\lambda},\mu) pp←Setup(1λ,μ):输入为 μ \mu μ(multilinear 多项式中的变量个数);输出为public parameters p p pp pp。
- ( C ; S ) ← C o m m i t ( p p ; G ) (C;S)\leftarrow Commit(pp;\mathcal{G}) (C;S)←Commit(pp;G):输入为a μ \mu μ-variate multilinear polynomial over a finite field G ∈ F [ μ ] \mathcal{G}\in\mathbb{F}[\mu] G∈F[μ];输出为a public commitment C C C和a secret opening hint S S S。
- b ← O p e n ( p p , C , G , S ) b\leftarrow Open(pp,C,\mathcal{G}, S) b←Open(pp,C,G,S):verifies the opening of commitment C C C to the μ \mu μ-variate multilinear polynomial G ∈ F [ μ ] \mathcal{G}\in\mathbb{F}[\mu] G∈F[μ] with the opening hint S S S;输出为a b ∈ { 0 , 1 } b\in\{0,1\} b∈{0,1}。
- b ← E v a l ( p p , C , r ⃗ , v , μ ; G , S ) b\leftarrow Eval(pp,C,\vec{r},v,\mu;\mathbb{G},S) b←Eval(pp,C,r,v,μ;G,S):为 an interactive public-coin protocol between a PPT prover P P P and verifier V V V。其中 V V V和 P P P的公共信息有:commitment C C C,变量数量 μ \mu μ,scalar v ∈ F v\in\mathbb{F} v∈F和 r ⃗ ∈ F μ \vec{r}\in\mathbb{F}^{\mu} r∈Fμ。 P P P的私有信息为: μ \mu μ-variate multilinear polynomial G ∈ F [ μ ] \mathcal{G}\in\mathbb{F}[\mu] G∈F[μ]和相应的secret opening hint S S S。 P P P attempts to convince V V V that G ( r ⃗ ) = v \mathcal{G}(\vec{r})=v G(r)=v。最终结果为, V V V输出 b ∈ { 0 , 1 } b\in\{0,1\} b∈{0,1}。
3. the sum-check protocol:机遇与挑战
Spartan使用的interactive proof protocol为 the sum-check protocol。(详细可参见Lund等人1990年论文《 Algebraic methods for interactive proof systems》)
假设存在
μ
\mu
μ-variate low-degree polynomial,
G
:
F
μ
→
F
\mathcal{G}: \mathbb{F}^{\mu}\rightarrow \mathbb{F}
G:Fμ→F,其中
G
\mathcal{G}
G中每个variable的degree不高于
l
l
l。a verifier
V
S
C
V_{SC}
VSC is interested in checking a claim of the following form by an untrusted prover
P
S
C
P_{SC}
PSC:
T
=
∑
x
1
∈
{
0
,
1
}
∑
x
2
∈
{
0
,
1
}
⋯
∑
x
μ
∈
{
0
,
1
}
G
(
x
1
,
x
2
,
⋯
,
x
μ
)
T=\sum_{x_1\in\{0,1\}}\sum_{x_2\in\{0,1\}}\cdots\sum_{x_{\mu}\in\{0,1\}}\mathcal{G}(x_1,x_2,\cdots,x_{\mu})
T=∑x1∈{0,1}∑x2∈{0,1}⋯∑xμ∈{0,1}G(x1,x2,⋯,xμ)
若直接将 G ( ⋅ ) \mathcal{G}(\cdot) G(⋅)给 V S C V_{SC} VSC,则verifier可直接计算如上的sum值,然后验证该sum值是否为 T T T。但是Verifier做该计算需要time exponential in μ \mu μ。
Lund等人1990年论文《 Algebraic methods for interactive proof systems》中指出,可实现far less computation but provides a probabilistic guarantee (on
V
S
C
V_{SC}
VSC's behalf):
V
S
C
V_{SC}
VSC与
P
S
C
P_{SC}
PSC 依次交互
μ
\mu
μ 轮。在最后一轮交互,
V
S
C
V_{SC}
VSC输出
b
∈
{
0
,
1
}
b\in\{0,1\}
b∈{0,1}。
V
S
C
V_{SC}
VSC的主要开销在于evaluate
G
\mathcal{G}
G at a random point in its domain
r
⃗
∈
F
μ
\vec{r}\in\mathbb{F}^{\mu}
r∈Fμ。
将以上the sum-check protocol表示为:
b
←
<
P
S
C
,
V
S
C
(
r
⃗
)
>
(
G
,
μ
,
l
,
T
)
b\leftarrow <P_{SC},V_{SC}(\vec{r})>(\mathcal{G},\mu,l,T)
b←<PSC,VSC(r)>(G,μ,l,T)
对于任意的
μ
\mu
μ-variate polynomial
G
\mathcal{G}
G with degree at most
l
l
l in each variable,具有如下属性:
这样在本论文中,可将验证
∑
x
⃗
∈
{
0
,
1
}
μ
G
(
x
⃗
)
=
T
\sum_{\vec{x}\in\{0,1\}^{\mu}}\mathcal{G}(\vec{x})=T
∑x∈{0,1}μG(x)=T是否成立reduce为验证
G
(
r
⃗
)
=
e
\mathcal{G}(\vec{r})=e
G(r)=e是否成立,详细的reduce流程为:
3.1 使用the sum-check protocol来构建succinct arguments的挑战
为了使用the sum-check protocol来构建succinct interactive argument of knowledge(进一步compile为a zkSNARK),需要考虑如下问题:
- 1)将R1CS instance encode为sum-check instance。
对于任意的R1CS instance X = ( F , A , B , C , i o , m , n ) \mathbb{X}=(\mathbb{F},\mathbf{A},\mathbf{B},\mathbf{C},io,m,n) X=(F,A,B,C,io,m,n),需要设计a degree- l l l, μ \mu μ-variate polynomial that sums to a specific value T T T over { 0 , 1 } μ \{0,1\}^{\mu} {0,1}μ if and only if there exists a witness w w w,使得 S a t R 1 C S ( X , w ) = 1 Sat_{R1CS}(\mathbb{X},w)=1 SatR1CS(X,w)=1成立,其中 μ = O ( log m ) \mu=O(\log m) μ=O(logm)且 l l l为a small constant。 - 2)实现communication succinctness。
尽管the sum-check protocol提供了succinctness (假设 the first sub-problem is solved with constraints on μ \mu μ and l l l noted above),building a succinct interactive argument is non-trivial。原因是,after the sum-check reduction, V V V必须验证 G ( r ⃗ ) = e \mathcal{G}(\vec{r})=e G(r)=e是否成立,而 G ( r ⃗ ) \mathcal{G}(\vec{r}) G(r)需要依赖 P P P的witness w w w to X \mathbb{X} X,但是 a naive evaluation of G ( r ⃗ ) \mathcal{G}(\vec{r}) G(r) 需要 O ( m ) O(m) O(m) communication to transmit w w w。同时,直接transmit w w w也不符合zero-knowledge要求。 - 3)实现Verifier succinctness。
为了compile an interactive argument to a zkSNARK, V V V的costs必须sub-linear in the size of an NP statement,但是evaluating G ( r ⃗ ) \mathcal{G}(\vec{r}) G(r)需要 O ( n ) O(n) O(n) computation if the statement has no structure (如 data-parallelism)。
一种可能的解决策略是 V V V preprocess the structure of the R1CS instance 来加速 all future verification of proofs for different R1CS instances with the same structure。但是为了避免任意形式的trusted setup,该preprocessing过程中应不包含任何secret trapdoors。
接下来,将介绍对以上三个sub-problems的解决方案。
3.2 解决方案
-
自Babai等人1991年论文《Checking computations in polylogarithmic time》和1992年论文《Non-deterministic exponential time has two-prover interactive protocols》等probabilistic proofs早期文献,提供了适合 the sum-check protocol structure的low-degree polynomial G ( ⋅ ) \mathcal{G}(\cdot) G(⋅)。但是这些早期的文献关注的都是构建such a polynomial 用于encode the satisfiability of a Boolean formula 或者 the correct execution of a program under a pointer machine,这些实现比R1CS表示冗长一个量级。
-
在Babai等人1992年论文《Non-deterministic exponential time has two-prover interactive protocols》的基础上,Blumberg等人2014年论文《Verifiable computation using multiple prover》中提供了a low-degree polynomial as part of a multi-prover interactive proof (MIP) protocol for the arithmetic cricuit satisfiability (ACS) problem。理论上,这解决了上面的第一个sub-problem,单实际上,arithmetic circuits 强加了overheads that range from small constant factors to orders of magnitude compared to R1CS。此外,还存在programmability challenges问题——如,ACS必须明确地encode加法门而R1CS obtains them for free,checking a non-deterministic witness requires additional effort as part of the toolchain or the programmer。
同时,通过引入2个或多个非共谋(non-colluding)的provers,MIP prtocols也可解决上面的第二个sub-problem。如:
(1) V V V使用 the sum-check protocol与第一个Prover交互,要求 V V V evaluate G ( ⋅ ) \mathcal{G}(\cdot) G(⋅) at a random point。之前已指出,该过程需要 O ( ∣ w ∣ ) O(|w|) O(∣w∣) communication from P P P to V V V。
(2) V V V通过 low-degree tests来与第二个Prover交互,用于 learn the desired evaluation of G ( ⋅ ) \mathcal{G}(\cdot) G(⋅)。除了复杂的soundness error 分析,该协议仅能达到23-bits of security for ∣ F ∣ ≈ 2 300 |\mathbb{F}|\approx 2^{300} ∣F∣≈2300。 -
尽管MIP要求non-colluding provers,但是Bitansky和Chiesa 2012年论文《Succinct arguments from multi-prover interactive proofs and their efficiency benefits》中,依赖fully-homomorphic encryption (FHE)在理论上实现了将MIP转换为SNARK。
从这个角度来看,本论文Spartan在不借助FHE或者low-degree tests来实现将 Blumberg等人2014年论文《Verifiable computation using multiple prover》中的two-prover protocol compile为 a public-coin succinct interactive argument of knowledge (and then into a zkSNARK without trusted setup)。
(1)Bitansky和Chiesa 2012年论文《Succinct arguments from multi-prover interactive proofs and their efficiency benefits》中需要a non-falsifiable variant of FHE,仅能实现 a designated verifier argument。
(2)而Spartan借助random oracle model,实现了publicly-verifiable argument。 -
Thaler 2017年课件《A state of the art MIP for circuit satisfiability》中指出,借助a polynomial commitment scheme,可将Blumberg等人2014年论文《Verifiable computation using multiple prover》中的MIP compile为a single prover argument。但是Thaler的方案无法解决上面的第三个sub-problem——即实现sub-linear verification costs for the verifier,因此也无法实现a zkSNARK。
-
在Spartan中:
(1)Spartan Prover不需要实现a low-degree extention (LDE) of w w w,而仅需要cryptographically commit to a multilinear extension of w w w using w w w alone。
(2)Spartan Prover不需要实现all possible responses to the verifier’s challenges in the sum-check protocol。相反,Spartan Prover engages in an interactive sum-check protocol with V V V。
(3)Babai等人1991年论文《Checking computations in polylogarithmic time》中避免使用multilinear extensions (MLE) of a witness,原因是the resulting PCP string will be super-polynomial in the size of the NP instance。但是,由于Spartan的Prover不需要实现the entire PCP,因此使用MLE的效率要优于其他LDE,同时,也支持使用simple cryptographic primitives to commit to such an MLE without ever materializing it。 -
[48,61,96,98-100] 中的Doubly-efficient interactive proofs可解决以上三个sub-problems——by restricting themselves to deterministic circuits in a layered form。They apply a sequence of sum-check protocols to recursively reduce a claim about outputs to a claim about inputs of the circuit。最终,the low-degree polynomial that V V V must evaluate as part of the final instance of the sum-check protocol is only over the inputs to the circuit, which V V V can locally compute。由于 V V V’s work is linear in the circuit depth,所以这适于low-depth circuits。此外,the circuits in these works cannot take a non-deterministic witness w w w as an input from P P P——without incurring O ( ∣ w ∣ ) O(|w|) O(∣w∣) communication from P P P to V V V[99] or using additional machinery。
-
Zhang等人2018年论文《vSQL: Verifying arbitrary SQL queries over dynamic outsourced databases》通过引入a polynomial commitment scheme 来 extend doubly-efficient IPs to the complexity class NP,从而将interactive argument转换为a zkSNARK。但是他们的polynomial commitment scheme需要a trusted setup。
-
Wahby等人2018年论文《Hyrax: Doubly-efficient zkSNARKs without trusted setup》中在不需要trusted setup的情况下,将zero-knowledge transformation和a new polynomial commitment scheme结合,实现了将Giraffe IP [101] (a doubly-efficient IP in the GKR [61] line of work [48,96,100,101]) 转换为 a zkSNARK。
在Hyrax和vSQL论文中,都需要layered circuits。 -
Kalai 2017年论文《Delegating computation: A new perspective》中描述了“squashed GKR” [71]:instead of running the GKR protocol on a layered circuit, it is run on a low-depth circuit that takes as input a witness whose size is proportional to the number of gates in the layered circuit。为了避免Verifier需要materialize the witness,该论文中引入了low-degree tests和a polynomial commitment scheme。但是该scheme需依赖于FHE,且仅支持designated verifier proofs。而且,该论文方案无法从根本上解决第三个sub-problem来实现sub-linear costs for the verifier。
为了实现sub-linear verification costs,Hyrax和vSQL论文中关注了data-parallel computations,但是在实际应用时附加了严重的限制。为了缓解这种限制,Hyrax中设计了 一种称为redistribution layer (RDL)的 irregular circuit layer,以支持跨different data-parallel units 来共享witness elements。此时, V V V需要linear costs for RDL。在其中的2个benchmark中, V V V的主要开销在于RDL的相关计算。 -
Spartan去除了对layered circuits的依赖,同时实现了sub-linear verification costs——without requiring any homogeneity (同质) in circuit structure。同时,借助the sum-check protocol (applied to a suitable low-degree polynomial G ( ⋅ ) \mathcal{G}(\cdot) G(⋅)), V V V可delegate the required evaluation of G ( ⋅ ) \mathcal{G}(\cdot) G(⋅) at a random point in its domain to the prover P P P。
4. 将R1CS instance ENCODE为low-degree polynomial
本论文实现了将R1CS instance ENCODE为 a degree-3 multivariate polynomial,变量个数为 ⌈ log m ⌉ \left \lceil \log m \right \rceil ⌈logm⌉。
以R1CS表示为:(其中
A
,
B
,
C
\mathbf{A},\mathbf{B},\mathbf{C}
A,B,C表示为n*m矩阵(
n
n
n行
m
m
m列,为简化表示,本论文中取n=m),
Z
⃗
\vec{Z}
Z为长度为
m
m
m的向量。)
(
A
Z
⃗
)
∗
(
B
Z
⃗
)
−
(
C
Z
⃗
)
=
0
⃗
(\mathbf{A}\vec{Z})*(\mathbf{B}\vec{Z})-(\mathbf{C}\vec{Z})=\vec{0}
(AZ)∗(BZ)−(CZ)=0
- Vitalik 博客Quadratic Arithmetic Programs: from Zero to Hero 中将R1CS转换为QAP——即 将
A
,
B
,
C
\mathbf{A},\mathbf{B},\mathbf{C}
A,B,C分别在
x
=
1
,
x
=
2
,
⋯
,
x
=
n
x=1,x=2,\cdots,x=n
x=1,x=2,⋯,x=n进行Lagrange插值为
m
m
m组degree为
n
−
1
n-1
n−1阶单变量多项式,最终的QAP表示为:【未对
Z
⃗
\vec{Z}
Z进行encode】
< Z ⃗ , [ A 1 ( x ) , ⋯ , A m ( x ) ] > ∗ < Z ⃗ , [ B 1 ( x ) , ⋯ , B m ( x ) ] > − < Z ⃗ , [ C 1 ( x ) , ⋯ , C m ( x ) ] > = H ∗ Z ( x ) <\vec{Z}, [A_1(x),\cdots, A_m(x)]>*<\vec{Z}, [B_1(x),\cdots,B_m(x)]>-<\vec{Z}, [C_1(x),\cdots, C_m(x)]>=H*Z(x) <Z,[A1(x),⋯,Am(x)]>∗<Z,[B1(x),⋯,Bm(x)]>−<Z,[C1(x),⋯,Cm(x)]>=H∗Z(x)
其中 Z ( x ) = ( x − 1 ) ( x − 2 ) ⋯ ( x − n ) Z(x)=(x-1)(x-2)\cdots (x-n) Z(x)=(x−1)(x−2)⋯(x−n)
- 本文,取
s
=
⌈
log
m
⌉
s=\left \lceil \log m \right \rceil
s=⌈logm⌉,以具有
s
s
s个变量的multilinear多项式
Z
(
y
⃗
)
=
Z
(
y
1
,
⋯
,
y
s
)
=
a
0
+
a
1
y
1
+
a
2
y
2
+
a
3
y
3
+
a
4
y
1
y
2
+
a
5
y
1
y
3
+
a
6
y
2
y
3
+
a
7
y
1
y
2
y
3
+
⋯
+
a
2
s
−
1
y
1
y
2
⋯
y
s
Z(\vec{y})=Z(y_1,\cdots,y_s)=a_0+a_1y_1+a_2y_2+a_3y_3+a_4y_1y_2+a_5y_1y_3+a_6y_2y_3+a_7y_1y_2y_3+\cdots+a_{2^s-1}y_1y_2\cdots y_s
Z(y)=Z(y1,⋯,ys)=a0+a1y1+a2y2+a3y3+a4y1y2+a5y1y3+a6y2y3+a7y1y2y3+⋯+a2s−1y1y2⋯ys来表示
Z
⃗
\vec{Z}
Z,使得
Z
[
0
]
=
Z
(
0
,
0
,
⋯
,
0
)
,
⋯
,
Z
[
m
]
=
Z
(
1
,
1
,
⋯
,
1
)
Z[0]=Z(0,0,\cdots,0),\cdots,Z[m]=Z(1,1,\cdots,1)
Z[0]=Z(0,0,⋯,0),⋯,Z[m]=Z(1,1,⋯,1)。
仍然以Vitalik 博客Quadratic Arithmetic Programs: from Zero to Hero 中的 Z ⃗ = [ 1 , 3 , 35 , 9 , 27 , 30 ] \vec{Z}=[1,3,35,9,27,30] Z=[1,3,35,9,27,30]为例,可以 s = ⌈ log 6 ⌉ = 3 s=\left \lceil \log 6 \right \rceil=3 s=⌈log6⌉=3个变量的multilinear 多项式 Z ( y ⃗ ) = Z ( y 1 , y 2 , y 3 ) = 1 + 26 y 1 + 34 y 2 + 2 y 3 − 28 y 2 y 3 + y 1 y 3 Z(\vec{y})=Z(y_1,y_2,y_3)=1+26y_1+34y_2+2y_3-28y_2y_3+y_1y_3 Z(y)=Z(y1,y2,y3)=1+26y1+34y2+2y3−28y2y3+y1y3 来表示,使得 Z ( 0 , 0 , 0 ) = 1 , Z ( 0 , 0 , 1 ) = 3 , Z ( 0 , 1 , 0 ) = 35 , Z ( 0 , 1 , 1 ) = 9 , Z ( 1 , 0 , 0 ) = 27 , Z ( 1 , 0 , 1 ) = 30 Z(0,0,0)=1,Z(0,0,1)=3,Z(0,1,0)=35, Z(0,1,1)=9, Z(1,0,0)=27, Z(1,0,1)=30 Z(0,0,0)=1,Z(0,0,1)=3,Z(0,1,0)=35,Z(0,1,1)=9,Z(1,0,0)=27,Z(1,0,1)=30。【即通过多变量multilinear多项式 Z ( y ⃗ ) Z(\vec{y}) Z(y)来表示 Z ⃗ \vec{Z} Z】
同理,对于R1CS矩阵 A , B , C ∈ F n × m \mathbf{A},\mathbf{B},\mathbf{C}\in\mathbb{F}^{n\times m} A,B,C∈Fn×m,相当于在Vitalik博客介绍的单变量多项式 A ( x ) A(x) A(x)的基础上,增加了 y ⃗ \vec{y} y变量,构建多变量multilinear多项式 A ( x , y ⃗ ) = A ( x , y 1 , y 2 , y 3 ) A(x,\vec{y})=A(x,y_1,y_2,y_3) A(x,y)=A(x,y1,y2,y3),使得 A ( x , 0 , 0 , 0 ) = A 1 ( x ) , A ( x , 0 , 0 , 1 ) = A 2 ( x ) , A ( x , 0 , 1 , 0 ) = A 3 ( x ) , A ( x , 0 , 1 , 1 ) = A 4 ( x ) , A ( x , 1 , 0 , 0 ) = A 5 ( x ) , A ( x , 1 , 0 , 1 ) = A 6 ( x ) A(x,0,0,0)=A_1(x), A(x,0,0,1)=A_2(x), A(x,0,1,0)=A_3(x), A(x,0,1,1)=A_4(x), A(x,1,0,0)=A_5(x), A(x,1,0,1)=A_6(x) A(x,0,0,0)=A1(x),A(x,0,0,1)=A2(x),A(x,0,1,0)=A3(x),A(x,0,1,1)=A4(x),A(x,1,0,0)=A5(x),A(x,1,0,1)=A6(x)成立。从而有:
F i o ( x ) = ( ∑ y ⃗ ∈ { 0 , 1 } s A ( x , y ⃗ ) ⋅ Z ( y ⃗ ) ) ⋅ ( ∑ y ⃗ ∈ { 0 , 1 } s B ( x , y ⃗ ) ⋅ Z ( y ⃗ ) ) − ∑ y ⃗ ∈ { 0 , 1 } s C ( x , y ⃗ ) ⋅ Z ( y ⃗ ) F_{io}(x)=(\sum_{\vec{y}\in\{0,1\}^s}A(x,\vec{y})\cdot Z(\vec{y}))\cdot (\sum_{\vec{y}\in\{0,1\}^s}B(x,\vec{y})\cdot Z(\vec{y}))-\sum_{\vec{y}\in\{0,1\}^s}C(x,\vec{y})\cdot Z(\vec{y}) Fio(x)=(∑y∈{0,1}sA(x,y)⋅Z(y))⋅(∑y∈{0,1}sB(x,y)⋅Z(y))−∑y∈{0,1}sC(x,y)⋅Z(y)
当任意的 x = 1 , x = 2 , ⋯ , x = n x=1,x=2,\cdots,x=n x=1,x=2,⋯,x=n时, F i o ( x ) = 0 F_{io}(x)=0 Fio(x)=0。
但是 F i o ( ⋅ ) F_{io}(\cdot) Fio(⋅)为a function,不是a polynomial,无法直接使用the sum-check protocol。(详细可参见博客 function和polynomial的关系)
需要将function扩展为polynomial:
F ~ i o : F s → F \tilde{F}_{io}:\mathbb{F}^s\rightarrow \mathbb{F} F~io:Fs→F
即:
F ~ i o ( x ) = ( ∑ y ⃗ ∈ { 0 , 1 } s A ~ ( x , y ⃗ ) ⋅ Z ~ ( y ⃗ ) ) ⋅ ( ∑ y ⃗ ∈ { 0 , 1 } s B ~ ( x , y ⃗ ) ⋅ Z ~ ( y ⃗ ) ) − ∑ y ⃗ ∈ { 0 , 1 } s C ~ ( x , y ⃗ ) ⋅ Z ~ ( y ⃗ ) \tilde{F}_{io}(x)=(\sum_{\vec{y}\in\{0,1\}^s}\tilde{A}(x,\vec{y})\cdot \tilde{Z}(\vec{y}))\cdot (\sum_{\vec{y}\in\{0,1\}^s}\tilde{B}(x,\vec{y})\cdot \tilde{Z}(\vec{y}))-\sum_{\vec{y}\in\{0,1\}^s}\tilde{C}(x,\vec{y})\cdot \tilde{Z}(\vec{y}) F~io(x)=(∑y∈{0,1}sA~(x,y)⋅Z~(y))⋅(∑y∈{0,1}sB~(x,y)⋅Z~(y))−∑y∈{0,1}sC~(x,y)⋅Z~(y)
当任意的 x = 1 , x = 2 , ⋯ , x = n x=1,x=2,\cdots,x=n x=1,x=2,⋯,x=n时, F ~ i o ( x ) = F i o ( x ) = 0 \tilde{F}_{io}(x)=F_{io}(x)=0 F~io(x)=Fio(x)=0。
此时 F ~ i o ( ⋅ ) \tilde{F}_{io}(\cdot) F~io(⋅)为a low-degree multivariate polynomial over F \mathbb{F} F in s s s variables,且此时verifier V V V 可check if ∑ { 0 , 1 } s F ~ i o ( x ) = 0 \sum_{\{0,1\}^s}\tilde{F}_{io}(x)=0 ∑{0,1}sF~io(x)=0 using the sum-check protocol with a prover P P P。但是,若 ∑ i = 1 n − 1 F ~ i o ( i ) = 0 \sum_{i=1}^{n-1}\tilde{F}_{io}(i)=0 ∑i=1n−1F~io(i)=0并不代表对任意的 { x = 1 , x = 2 , ⋯ , x = n } \{x=1,x=2,\cdots,x=n\} {x=1,x=2,⋯,x=n} F ~ i o ( x ) = 0 \tilde{F}_{io}(x)=0 F~io(x)=0 成立。因此,需要借助[13,32,43]的思想,构建多变量多项式 Q i o ( t ⃗ ) Q_{io}(\vec{t}) Qio(t)使得其为zero-polynomial if and only if F ~ i o ( ⋅ ) \tilde{F}_{io}(\cdot) F~io(⋅) evaluates to zero at all points in the s s s-dimensional Boolean hypercube:
注意, Q i o ( ⋅ ) Q_{io}(\cdot) Qio(⋅) is a multivariate polynomial such that Q i o ( t ⃗ ) = F ~ i o ( t ⃗ ) Q_{io}(\vec{t})=\tilde{F}_{io}(\vec{t}) Qio(t)=F~io(t) for all t ∈ { 0 , 1 } s t\in\{0,1\}^s t∈{0,1}s。因此, Q i o ( t ⃗ ) Q_{io}(\vec{t}) Qio(t)为zero-polynomial (如,it evaluates to 0 for all points in its domain) if and only if F ~ i o ( ⋅ ) \tilde{F}_{io}(\cdot) F~io(⋅) evaluates to zero at all points in the s s s-dimensional Boolean hypercube (也意味着,if and only if F ~ i o ( ⋅ ) \tilde{F}_{io}(\cdot) F~io(⋅) encodes a witness w w w such that S a t R 1 C S = ( X , w ) = 1 Sat_{R1CS}=(\mathbb{X},w)=1 SatR1CS=(X,w)=1)。
为了验证 Q i o ( ⋅ ) Q_{io}(\cdot) Qio(⋅)是a zero-polynomial,仅需验证 Q i o ( τ ) = 0 Q_{io}(\tau)=0 Qio(τ)=0就足够了,其中 τ ∈ R F s \tau\in_R\mathbb{F}^s τ∈RFs。
对于R1CS instance X = ( F , A , B , C , i o → , m , n ) \mathbb{X}=(\mathbb{F}, \mathbf{A}, \mathbf{B}, \mathbf{C}, \overrightarrow{io}, m, n) X=(F,A,B,C,io,m,n),定义 G i o , τ ( x ) = F ~ i o ( x ) ⋅ e q ~ ( τ , x ) \mathcal{G}_{io,\tau}(x)=\tilde{F}_{io}(x)\cdot \tilde{eq}(\tau,x) Gio,τ(x)=F~io(x)⋅eq~(τ,x),使得 Q i o ( τ ) = ∑ x ∈ { 0 , 1 } s G i o , τ ( x ) Q_{io}(\tau)=\sum_{x\in\{0,1\}^s}\mathcal{G}_{io,\tau}(x) Qio(τ)=∑x∈{0,1}sGio,τ(x)。注意其中 G i o , τ ( ⋅ ) \mathcal{G}_{io,\tau}(\cdot) Gio,τ(⋅)为a degree-3 s s s-variate polynomial if multilinear extensions of A , B , C , Z ⃗ \mathbf{A},\mathbf{B},\mathbf{C},\vec{Z} A,B,C,Z are used in F ~ ( ⋅ ) \tilde{F}(\cdot) F~(⋅)。
此外,若 τ ∈ R F s \tau\in_R\mathbb{F}^s τ∈RFs,则 ∑ x ∈ { 0 , 1 } s G i o , τ ( x ) = 0 \sum_{x\in\{0,1\}^s}\mathcal{G}_{io,\tau}(x)=0 ∑x∈{0,1}sGio,τ(x)=0 if and only if F ~ i o ( x ) = 0 \tilde{F}_{io}(x)=0 F~io(x)=0 for ∀ x ∈ { 0 , 1 } s \forall x\in\{0,1\}^s ∀x∈{0,1}s——except for soundness error that is negligible in λ \lambda λ under the assumptions noted in lemma 4.3。
5. A family of NIZKs with succinct proofs for R1CS
首先设计an interactive argument with succinct communication costs;
然后compile it into a family of NIZKs in the random oracle model using prior transformations。
5.1 A new public-coin succinct interactive argument of knowledge
结论为:
若有针对multilinear polynomial的extractable polynomial commitment scheme,则存在a public-coin succinct interactive argument of knowledge,其security为under the assumption needed for the polynomial commitment scheme,同时假设
∣
F
∣
|\mathbb{F}|
∣F∣为exponential in
λ
\lambda
λ,the size parameter of R1CS instance
n
=
O
(
λ
)
n=O(\lambda)
n=O(λ)。
证明思路为:
在Theorem 4.1的证明过程中指出,
V
V
V为了验证an R1CS instance
X
=
(
F
,
A
,
B
,
C
,
i
o
→
,
m
,
n
)
\mathbb{X}=(\mathbb{F}, \mathbf{A}, \mathbf{B}, \mathbf{C}, \overrightarrow{io}, m, n)
X=(F,A,B,C,io,m,n) is satisfiable,可转为验证
∑
x
∈
{
0
,
1
}
s
G
i
o
,
τ
(
x
)
=
0
\sum_{x\in\{0,1\}^s}\mathcal{G}_{io,\tau}(x)=0
∑x∈{0,1}sGio,τ(x)=0是否成立。
通过运行the sum-check protocol,可将 判断
∑
x
∈
{
0
,
1
}
s
G
i
o
,
τ
(
x
)
=
0
\sum_{x\in\{0,1\}^s}\mathcal{G}_{io,\tau}(x)=0
∑x∈{0,1}sGio,τ(x)=0是否成立 reduce 为 判断
e
x
=
G
i
o
,
τ
(
r
x
)
,
其
中
r
x
∈
F
s
e_x=\mathcal{G}_{io,\tau}(r_x),其中r_x\in\mathbb{F}^s
ex=Gio,τ(rx),其中rx∈Fs是否成立。
接下来,需要引入一种机制,使得
V
V
V在evaluate
G
i
o
,
τ
(
r
x
)
\mathcal{G}_{io,\tau}(r_x)
Gio,τ(rx)时,不需要
O
(
m
)
O(m)
O(m) communication from
P
P
P to
V
V
V。
由于 G i o , τ ( x ) = F ~ i o ( x ) ⋅ e q ~ ( τ , x ) \mathcal{G}_{io,\tau}(x)=\tilde{F}_{io}(x)\cdot \tilde{eq}(\tau,x) Gio,τ(x)=F~io(x)⋅eq~(τ,x),为了evaluate G i o , τ ( r x ) \mathcal{G}_{io,\tau}(r_x) Gio,τ(rx), V V V必须evaluate F ~ i o ( r x ) \tilde{F}_{io}(r_x) F~io(rx)和 e q ~ ( τ , r x ) \tilde{eq}(\tau,r_x) eq~(τ,rx)。其中evaluate e q ~ ( τ , r x ) \tilde{eq}(\tau,r_x) eq~(τ,rx)需要 O ( log m ) O(\log m) O(logm) time。
由于:
F
~
i
o
(
r
x
)
=
(
∑
y
⃗
∈
{
0
,
1
}
s
A
~
(
r
x
,
y
⃗
)
⋅
Z
~
(
y
⃗
)
)
⋅
(
∑
y
⃗
∈
{
0
,
1
}
s
B
~
(
r
x
,
y
⃗
)
⋅
Z
~
(
y
⃗
)
)
−
∑
y
⃗
∈
{
0
,
1
}
s
C
~
(
r
x
,
y
⃗
)
⋅
Z
~
(
y
⃗
)
\tilde{F}_{io}(r_x)=(\sum_{\vec{y}\in\{0,1\}^s}\tilde{A}(r_x,\vec{y})\cdot \tilde{Z}(\vec{y}))\cdot (\sum_{\vec{y}\in\{0,1\}^s}\tilde{B}(r_x,\vec{y})\cdot \tilde{Z}(\vec{y}))-\sum_{\vec{y}\in\{0,1\}^s}\tilde{C}(r_x,\vec{y})\cdot \tilde{Z}(\vec{y})
F~io(rx)=(∑y∈{0,1}sA~(rx,y)⋅Z~(y))⋅(∑y∈{0,1}sB~(rx,y)⋅Z~(y))−∑y∈{0,1}sC~(rx,y)⋅Z~(y)
因此为了evaluate
F
~
i
o
(
r
x
)
\tilde{F}_{io}(r_x)
F~io(rx),
V
V
V需要做如下evaluate:
∀
y
⃗
∈
{
0
,
1
}
s
:
A
~
(
r
x
,
y
⃗
)
,
B
~
(
r
x
,
y
⃗
)
,
Z
~
(
y
⃗
)
\forall \vec{y}\in\{0,1\}^s: \tilde{A}(r_x,\vec{y}),\tilde{B}(r_x,\vec{y}), \tilde{Z}(\vec{y})
∀y∈{0,1}s:A~(rx,y),B~(rx,y),Z~(y)
其中,the evaluations of
Z
~
(
y
⃗
)
\tilde{Z}(\vec{y})
Z~(y) for all
y
∈
{
0
,
1
}
s
y\in\{0,1\}^s
y∈{0,1}s is the same as
(
i
o
,
1
,
w
)
(io,1,w)
(io,1,w),因此,the communication from
P
P
P to
V
V
V is
≥
O
(
∣
w
∣
)
\geq O(|w|)
≥O(∣w∣)。
为了减少communication cost,本文采取的策略是将三种协议整合在一起:
- the sum-check protocol
- a randomized mini protocol
- a polynomial commitment scheme
具体实现为:
设置
F
~
i
o
(
r
x
)
=
A
ˉ
(
r
x
)
⋅
B
ˉ
(
r
x
)
−
C
ˉ
(
r
x
)
\tilde{F}_{io}(r_x)=\bar{A}(r_x)\cdot \bar{B}(r_x)-\bar{C}(r_x)
F~io(rx)=Aˉ(rx)⋅Bˉ(rx)−Cˉ(rx)
其中
A
ˉ
(
r
x
)
=
∑
y
⃗
∈
{
0
,
1
}
s
A
~
(
r
x
,
y
⃗
)
⋅
Z
~
(
y
⃗
)
\bar{A}(r_x)= \sum_{\vec{y}\in\{0,1\}^s}\tilde{A}(r_x,\vec{y})\cdot \tilde{Z}(\vec{y})
Aˉ(rx)=∑y∈{0,1}sA~(rx,y)⋅Z~(y)
B
ˉ
(
r
x
)
=
∑
y
⃗
∈
{
0
,
1
}
s
B
~
(
r
x
,
y
⃗
)
⋅
Z
~
(
y
⃗
)
\bar{B}(r_x)= \sum_{\vec{y}\in\{0,1\}^s}\tilde{B}(r_x,\vec{y})\cdot \tilde{Z}(\vec{y})
Bˉ(rx)=∑y∈{0,1}sB~(rx,y)⋅Z~(y)
C
ˉ
(
r
x
)
=
∑
y
⃗
∈
{
0
,
1
}
s
C
~
(
r
x
,
y
⃗
)
⋅
Z
~
(
y
⃗
)
\bar{C}(r_x)= \sum_{\vec{y}\in\{0,1\}^s}\tilde{C}(r_x,\vec{y})\cdot \tilde{Z}(\vec{y})
Cˉ(rx)=∑y∈{0,1}sC~(rx,y)⋅Z~(y)
自此,
- Prover可make three separate claims to V V V, say that A ˉ ( r x ) = v A , B ˉ ( r x ) = v B , C ˉ ( r x ) = v C \bar{A}(r_x)=v_A, \bar{B}(r_x)=v_B, \bar{C}(r_x)=v_C Aˉ(rx)=vA,Bˉ(rx)=vB,Cˉ(rx)=vC;
-
V
V
V可evaluate
G
i
o
,
τ
(
r
x
)
=
(
v
A
⋅
v
B
−
v
C
)
⋅
e
q
~
(
r
x
,
τ
)
\mathcal{G}_{io,\tau}(r_x)=(v_A\cdot v_B- v_C)\cdot \tilde{eq}(r_x,\tau)
Gio,τ(rx)=(vA⋅vB−vC)⋅eq~(rx,τ)
然后验证 G i o , τ = e x \mathcal{G}_{io,\tau}=e_x Gio,τ=ex是否成立即可。 - 同时
V
V
V和
P
P
P需要run three independent instances of the sum-check protocol来验证
A
ˉ
(
r
x
)
=
v
A
,
B
ˉ
(
r
x
)
=
v
B
,
C
ˉ
(
r
x
)
=
v
C
\bar{A}(r_x)=v_A, \bar{B}(r_x)=v_B, \bar{C}(r_x)=v_C
Aˉ(rx)=vA,Bˉ(rx)=vB,Cˉ(rx)=vC是否成立。
借鉴[45,103]中思想,可将这3个claim合并为一个claim:
此时,
V
V
V仍未脱离困境,在上图的the sum-check protocol中,
V
V
V仍然必须evaluate
M
r
x
(
r
y
)
M_{r_x}(r_y)
Mrx(ry) for
r
y
∈
F
s
r_y\in\mathbb{F}^s
ry∈Fs:
M
r
x
(
r
y
)
=
r
A
⋅
A
~
(
r
x
,
r
y
)
⋅
Z
~
(
r
y
)
+
r
B
⋅
B
~
(
r
x
,
r
y
)
⋅
Z
~
(
r
y
)
+
r
C
⋅
C
~
(
r
x
,
r
y
)
⋅
Z
~
(
r
y
)
=
(
r
A
⋅
A
~
(
r
x
,
r
y
)
+
r
B
⋅
B
~
(
r
x
,
r
y
)
+
r
C
⋅
C
~
(
r
x
,
r
y
)
)
⋅
Z
~
(
r
y
)
M_{r_x}(r_y)=r_A\cdot \tilde{A}(r_x,r_y)\cdot \tilde{Z}(r_y)+ r_B\cdot \tilde{B}(r_x,r_y)\cdot \tilde{Z}(r_y)+ r_C\cdot \tilde{C}(r_x,r_y)\cdot \tilde{Z}(r_y)=( r_A\cdot \tilde{A}(r_x,r_y) + r_B\cdot \tilde{B}(r_x,r_y) + r_C\cdot \tilde{C}(r_x,r_y))\cdot \tilde{Z}(r_y)
Mrx(ry)=rA⋅A~(rx,ry)⋅Z~(ry)+rB⋅B~(rx,ry)⋅Z~(ry)+rC⋅C~(rx,ry)⋅Z~(ry)=(rA⋅A~(rx,ry)+rB⋅B~(rx,ry)+rC⋅C~(rx,ry))⋅Z~(ry)
注意,
M
r
x
(
r
y
)
M_{r_x}(r_y)
Mrx(ry)中依赖Prover witness的项只有
Z
~
(
r
y
)
\tilde{Z}(r_y)
Z~(ry),其它项的值都可以由
V
V
V在本地利用
X
=
(
F
,
A
,
B
,
C
,
i
o
→
,
m
,
n
)
\mathbb{X}=(\mathbb{F}, \mathbf{A}, \mathbf{B}, \mathbf{C}, \overrightarrow{io}, m, n)
X=(F,A,B,C,io,m,n)计算获得in
O
(
n
)
O(n)
O(n) time(在本论文第6章将reduce the evaluation cost to be sub-linear in
n
n
n)。
同时,为了evaluate
Z
~
(
r
y
)
\tilde{Z}(r_y)
Z~(ry) without incurring
O
(
∣
w
∣
)
O(|w|)
O(∣w∣) communication from
P
P
P to
V
V
V,可引入an extractable polynomial commitment scheme for multilinear polynomials:(类似的multilinear polynomial commitment scheme在Zhang等人2017年论文《vSQL: Verifying arbitrary SQL queries over dynamic outsourced databases》 中有提及。)
- 利用an extractable multilinear polynomial commitment scheme, P P P 在运行第一个the sum-check protocol之前,发送a commitment to w ~ ( ⋅ ) \tilde{w}(\cdot) w~(⋅) (即 a multilinear extension of its purported witness) to V V V。
-
V
V
V为了evaluate
Z
~
(
r
y
)
\tilde{Z}(r_y)
Z~(ry),不失一般性地假设
∣
w
∣
=
∣
i
o
∣
+
1
|w|=|io|+1
∣w∣=∣io∣+1,则有:
Z ~ ( r y ) = ( 1 − r y [ 0 ] ) ⋅ w ~ ( r y [ 1 ⋅ ⋅ ] ) + r y [ 0 ] ⋅ i o , 1 ~ ( r y [ 1 ⋅ ⋅ ] ) \tilde{Z}(r_y)=(1-r_y[0])\cdot \tilde{w}(r_y[1\cdot\cdot])+r_y[0]\cdot \widetilde{io,1}(r_y[1\cdot\cdot]) Z~(ry)=(1−ry[0])⋅w~(ry[1⋅⋅])+ry[0]⋅io,1 (ry[1⋅⋅])
其中 r y [ 1 ⋅ ⋅ ] r_y[1\cdot\cdot] ry[1⋅⋅]表示a slice of r y r_y ry that excludes the first element。
【注意, Z ( y 1 , y 2 , ⋯ , y s ) Z(y_1,y_2,\cdots,y_s) Z(y1,y2,⋯,ys)为multilinear polynomial,可将其拆分为2个子multilinear polynomial之和表示为:(称为the closed form expression of multilinear polynomial)
Z ( y 1 , y 2 , ⋯ , y s ) = y 1 ⋅ Z 1 ( y 2 , ⋯ , y s ) + ( 1 − y 1 ) ⋅ Z 2 ( y 2 , ⋯ , y s ) Z(y_1,y_2,\cdots,y_s)=y_1\cdot Z_1(y_2,\cdots,y_s)+(1-y_1)\cdot Z_2(y_2,\cdots,y_s) Z(y1,y2,⋯,ys)=y1⋅Z1(y2,⋯,ys)+(1−y1)⋅Z2(y2,⋯,ys)
其中 Z 1 ( y 2 , ⋯ , y s ) Z_1(y_2,\cdots,y_s) Z1(y2,⋯,ys)对应为 ( 1 , y 2 , ⋯ , y s ) (1,y_2,\cdots,y_s) (1,y2,⋯,ys), Z 2 ( y 2 , ⋯ , y s ) Z_2(y_2,\cdots,y_s) Z2(y2,⋯,ys)对应为 ( 0 , y 2 , ⋯ , y s ) (0,y_2,\cdots,y_s) (0,y2,⋯,ys),可覆盖所有的取值范围 ( 0 , 0 , ⋯ , 0 ) ∼ ( 1 , 1 , ⋯ , 1 ) (0,0,\cdots,0) \sim (1,1,\cdots,1) (0,0,⋯,0)∼(1,1,⋯,1)。】
完整的协议描述为:
其中需要an extractable multilinear polynomial commitment scheme
P
C
=
(
S
e
t
u
p
,
C
o
m
m
i
t
,
O
p
e
n
,
E
v
a
l
)
PC=(Setup,Commit,Open,Eval)
PC=(Setup,Commit,Open,Eval)。
5.2 multilinear polynomial commitment scheme选型
现有的很多extractable polynomial commitment schemes for multilinear polynomials [87,103, 107,108]都可满足本文要求,实际使用时,主要根据cost和相应的安全假设进行选择。
5.3 增加zero knowledge属性。
可借助[14,50]中的技术为5.1节中的协议增加zero-knowledge属性。
当前有2种compiler尤其高效:
- (1)Hyrax论文 中的思路——a zero-knowledge argument protocol for proving dot-product relationships and other relationships in zero-knowledge (如 products)。
- (2)Libra论文 和 Virgo论文 中的思路——an extractable polynomial commitment scheme。
5.4 引入computation commitment来减轻Verifier计算压力。
5.1节协议的第16步中,Verifier需计算evaluations
A
~
(
r
x
,
r
y
)
,
B
~
(
r
x
,
r
y
)
,
C
~
(
r
x
,
r
y
)
\tilde{A}(r_x,r_y),\tilde{B}(r_x,r_y),\tilde{C}(r_x,r_y)
A~(rx,ry),B~(rx,ry),C~(rx,ry) with cost linear in the size of the R1CS instance。
接下来讲如何实现sub-linear verification cost:
- 引入preprocessing step for
V
V
V:
在offline phase, V V V with access to non- i o io io portions of an R1CS instance X = ( F , A , B , C , i o → , m , n ) \mathbb{X}=(\mathbb{F}, \mathbf{A}, \mathbf{B}, \mathbf{C}, \overrightarrow{io}, m, n) X=(F,A,B,C,io,m,n) 执行如下协议:(其中 p p c c ← P C . S e t u p ( 1 λ , 2 log m ) pp_{cc}\leftarrow PC.Setup(1^{\lambda},2\log m) ppcc←PC.Setup(1λ,2logm), P C PC PC为an extractable polynomial commitment scheme for multilinear polynomials。)
由于 A ~ , B ~ , C ~ \tilde{A},\tilde{B},\tilde{C} A~,B~,C~对Verifier已知,无需引入hiding要素,由Prover来执行相应的计算,Verifier仅需验证值是否正确,从而减轻了Verifier端的计算压力:
若
V
V
V’s costs to verify the three evaluations and the added communication are sublinear in
O
(
n
)
O(n)
O(n),则the modified interactive argument leads to a zkSNARK。(按之前的策略添加zero-knowledge属性和non-interactivity。)
但是现有的polynomial commitment scheme无法满足效率要求:
- (1)to participate in
Eval
for any of A ~ , B ~ , C ~ \tilde{A},\tilde{B},\tilde{C} A~,B~,C~, P P P需要至少quadratic costs O ( m 2 ) O(m^2) O(m2)。 - (2)在某些polynomial commitment scheme (如 Hyrax-PC)中,通过以上修改并没有improve asymptotics for the verifier。
注意:
- 多项式 A ~ , B ~ , C ~ \tilde{A},\tilde{B},\tilde{C} A~,B~,C~为multilinear extensions of matrices A , B , C \mathbf{A}, \mathbf{B}, \mathbf{C} A,B,C in an R1CS instance X = ( F , A , B , C , i o → , m , n ) \mathbb{X}=(\mathbb{F}, \mathbf{A}, \mathbf{B}, \mathbf{C}, \overrightarrow{io}, m, n) X=(F,A,B,C,io,m,n), A ~ , B ~ , C ~ \tilde{A},\tilde{B},\tilde{C} A~,B~,C~ multilinear polynomials均具有 μ = 2 s , s = log m \mu=2s,s=\log m μ=2s,s=logm个变量。若直接利用图4中现有的polynomial commitment scheme,则 Γ = 2 μ = 2 2 log m \Gamma =2^{\mu}=2^{2\log m} Γ=2μ=22logm,则 P E V A L P_{EVAL} PEVAL至少需要 O ( m 2 ) O(m^2) O(m2) cost,由于 n = O ( m ) n=O(m) n=O(m),也为 O ( n 2 ) O(n^2) O(n2) cost。(根据定义2.1,其中 n n n为non-zero entries in each matrix。)
- 若使用Hyrax-PC, V E V A L V_{EVAL} VEVAL为 O ( Γ ) = O ( n ) O(\sqrt{\Gamma})=O(n) O(Γ)=O(n) cost,则完全没必要引入computation commitment来减轻 V V V的计算压力。(Neither is desirable for instantiating computation commitments, which aims to make V V V’s costs sub-linear in O ( n ) O(n) O(n) by delegating evaluations of A ~ , B ~ , C ~ \tilde{A}, \tilde{B},\tilde{C} A~,B~,C~ at ( r x , r y ) (r_x,r_y) (rx,ry) to P P P。)
本文引入了spark compiler来实现相应的polynomial commitment scheme。
6. The SPARK complier
The SPARK compiler,用于transform an existing extractable polynomial commitment scheme for dense multilinear polynomials to one that can efficiently handle sparse multilinear polynomials。
本文发现,借助zkSNARK可构建a polynomial commitment scheme for sparse multilinear polynomial,具有sub-linear verification costs for a restricted class of NP statements。
有2个备选项:(两者均可实现sub-linear verification costs for NP statements with uniform structure。)
- Hyrax
- 5.2节的Spartan-based NIZK
为了便于说明,接下来重点介绍 SPARK that applies to 2 log m 2\log m 2logm-variate sparse polynomials A ~ , B ~ , C ~ \tilde{A},\tilde{B},\tilde{C} A~,B~,C~ (where their dense representation is of size ≤ n \leq n ≤n),同时,SPARK也可通用于其它sparse multilinear polynomials。
6.1 SPARK-naïve: A straw-man solution
- Hyrax——a zkSNARK that achieves sub-linear verification costs for uniform circuits, specifically data-parallel circuits。
- Vigro——将Hyrax的Prover’s cost降为了linear in the circuit size,但是其Verifier cost为
O
(
d
log
n
+
e
)
O(d\log n+e)
O(dlogn+e),其中
d
d
d为他和depth of the circuit,
e
e
e为the cost to the verifier to participate in
PC.Eval
to evaluate a log ∣ w ∣ \log |w| log∣w∣-variate multilinear polynomial,其中 w w w为a witness to the circuit。
Let
M
M
M denote one of
{
A
,
B
,
C
}
\{A,B,C\}
{A,B,C},and let
s
=
log
m
s=\log m
s=logm,有
μ
=
2
s
\mu=2s
μ=2s。
相应的closed-form expression for multilinear polynomial evaluations at
r
⃗
∈
F
μ
\vec{r}\in\mathbb{F}^{\mu}
r∈Fμ为:
M
~
(
r
⃗
)
=
∑
i
⃗
∈
{
0
,
1
}
μ
:
:
M
(
i
⃗
)
≠
0
M
(
i
⃗
)
⋅
e
q
~
(
i
⃗
,
r
⃗
)
\tilde{M}(\vec{r})=\sum_{\vec{i}\in\{0,1\}^{\mu}::M(\vec{i})\neq 0}M(\vec{i})\cdot \tilde{eq}(\vec{i},\vec{r})
M~(r)=∑i∈{0,1}μ::M(i)=0M(i)⋅eq~(i,r) …… (1)
以上求和公式中至多只有 n n n个terms,原因在于 M ( i ⃗ ) ≠ 0 M(\vec{i})\neq 0 M(i)=0 for at most n n n values of i ⃗ \vec{i} i。同时,each entry in the sum can be computed with O ( μ ) O(\mu) O(μ) multiplications。
将evaluate
M
~
(
r
⃗
)
\tilde{M}(\vec{r})
M~(r)以如下circuit表示:
注意,以上circuit为uniform的:
有
n
n
n个完全相同的sub-circuit,其中每个sub-circuit计算
O
(
μ
)
O(\mu)
O(μ) multiplications;这些sub-circuits的输出到a binary tree of addition gates to compute the final sum。此外,there is no sharing of witness elements across data-parallel units, so it truly data-parallel。
Given an extractable polynomial commitment scheme PC for multilinear polynomials,可构建如下的sparse multilinear polynomial scheme:
回想下,计算
M
~
(
r
⃗
)
\tilde{M}(\vec{r})
M~(r) for
M
∈
{
A
,
B
,
C
}
M\in\{A,B,C\}
M∈{A,B,C} and
r
⃗
∈
F
μ
\vec{r}\in\mathbb{F}^{\mu}
r∈Fμ,需要的cost为
O
(
n
)
O(n)
O(n)。
P
C
n
a
i
v
e
PC^{naive}
PCnaive主要缺点在于 it imposes an asymptotic overhead over its underlying commitment scheme for dense multilinear polynomials。
如若以 Hyrax-PC 作为 the underlying commitment scheme,则
P
C
n
a
i
v
e
PC^{naive}
PCnaive的Prover需要
O
(
n
log
n
)
O(n\log n)
O(nlogn) cost来证明an evaluation of a committed sparse multilinear polynomial。原因在于:the prover must prove the satisfiability of a circuit of size
O
(
n
⋅
μ
)
O(n\cdot \mu)
O(n⋅μ) as well as prove the evaluations of a constant number of
(
log
(
n
⋅
(
μ
+
1
)
)
)
(\log (n\cdot (\mu+1)))
(log(n⋅(μ+1)))-variate multilinear polynomials。
6.2 利用memory checking来清除 P C n a i v e PC^{naive} PCnaive中的asymptotic overhead
通过设计an
O
(
n
)
O(n)
O(n)-sized circuit for sparse polynomial evaluation来对
P
C
n
a
i
v
e
PC^{naive}
PCnaive进行改进。
自然地,the size of the witness to the circuit is also of size
O
(
n
)
O(n)
O(n)。这就允许SPARK实现a linear-time prover if the underlying polynomial commitment scheme offers linear-time costs for the prover。同时,SPARK不会add asymptotic overheads to the prover for proving the evaluations of committed sparse multilinear polynomials。
注意,对于
M
∈
{
A
,
B
,
C
}
M\in\{A,B,C\}
M∈{A,B,C},
M
∈
F
m
×
m
M\in\mathbb{F}^{m\times m}
M∈Fm×m,and any
r
⃗
∈
F
μ
\vec{r}\in\mathbb{F}^{\mu}
r∈Fμ。
μ
=
2
log
m
=
2
s
\mu=2\log m=2s
μ=2logm=2s,可将
r
⃗
\vec{r}
r看成是tuple
(
r
⃗
x
,
r
⃗
y
)
(\vec{r}_x,\vec{r}_y)
(rx,ry),其中
r
⃗
x
,
r
⃗
y
∈
F
s
\vec{r}_x,\vec{r}_y\in\mathbb{F}^s
rx,ry∈Fs,从而可将公式(1)表达为:
M
~
(
r
⃗
x
,
r
⃗
y
)
=
∑
(
i
⃗
,
j
⃗
)
∈
(
{
0
,
1
}
s
,
{
0
,
1
}
s
)
:
:
M
(
i
⃗
,
j
⃗
)
≠
0
M
(
i
⃗
,
j
⃗
)
⋅
e
q
~
(
i
⃗
,
r
⃗
x
)
⋅
e
q
~
(
j
⃗
,
r
⃗
y
)
\tilde{M}(\vec{r}_x,\vec{r}_y)=\sum_{(\vec{i},\vec{j})\in(\{0,1\}^s,\{0,1\}^s):: M(\vec{i},\vec{j})\neq 0}M(\vec{i},\vec{j})\cdot \tilde{eq}(\vec{i},\vec{r}_x)\cdot \tilde{eq}(\vec{j},\vec{r}_y)
M~(rx,ry)=∑(i,j)∈({0,1}s,{0,1}s)::M(i,j)=0M(i,j)⋅eq~(i,rx)⋅eq~(j,ry)
注意,以上sum仍然包含
n
n
n个terms。计算each entry in the sum 仍然需要
(
μ
+
1
)
(\mu+1)
(μ+1) multiplications over
F
\mathbb{F}
F。存在可能,可计算a table of evaluations of
e
q
~
(
i
⃗
,
r
⃗
x
)
\tilde{eq}(\vec{i},\vec{r}_x)
eq~(i,rx) for all
i
⃗
∈
{
0
,
1
}
s
\vec{i}\in\{0,1\}^s
i∈{0,1}s in
O
(
2
s
)
=
O
(
m
)
O(2^s)=O(m)
O(2s)=O(m) time 以及
e
q
~
(
j
⃗
,
r
⃗
y
)
\tilde{eq}(\vec{j},\vec{r}_y)
eq~(j,ry) for all
j
⃗
∈
{
0
,
1
}
s
\vec{j}\in\{0,1\}^s
j∈{0,1}s in
O
(
2
s
)
=
O
(
m
)
O(2^s)=O(m)
O(2s)=O(m) time。
但是,仅能计算这些tables in
O
(
m
)
O(m)
O(m) time是不够的, the sum is taken over the list of
(
i
⃗
,
j
⃗
)
∈
(
{
0
,
1
}
s
,
{
0
,
1
}
s
)
(\vec{i},\vec{j})\in(\{0,1\}^s,\{0,1\}^s)
(i,j)∈({0,1}s,{0,1}s) where
M
(
i
⃗
,
j
⃗
)
≠
0
M(\vec{i},\vec{j})\neq 0
M(i,j)=0 and for an arbitrary
2
s
2s
2s-variate sparse multilinear polynomial, such a list has no structure,因此,计算the sum 需要
n
n
n random accesses into two tables each with
m
m
m entries。
解决办法是——构建支持RAM operation的circuit。
但是,现有的encode RAM in circuits技术,将引起a logarithmic blowup or constants that in practice are larger than a logarithmic blowup。
For m m m RAM operations over a memory of size m m m:
- Braun等人2013年论文(Pantry [38])《Verifying computations with state》中,借助Merkle trees, trees [31, 83],可构建a circuit of size O ( m log m ) O(m\log m) O(mlogm);
- Wahby等人2015年论文《Efficient RAM and control flow in verifiable outsourced computation》中,使用permutation networks [18],可提供a circuit of size O ( m log m ) O(m\log m) O(mlogm) with constants smaller than the ones in Pantry。
- Zhang等人2018年论文《vRAM: Faster verifiable RAM with program-independent preprocessing》可提供an
O
(
m
)
O(m)
O(m)-sized circuit with a constant of
log
∣
F
∣
\log |\mathbb{F}|
log∣F∣ (to encode consistency checks over a memory transcript)。所以实际上,相比于
P
C
n
a
i
v
e
PC^{naive}
PCnaive并未改进。同时它还有2个缺陷:
– 1)仅支持32-bit sized memory cells,而我们需要a memory over elements of F \mathbb{F} F;
– 2)几乎circuit的所有non-deterministic witness都必须committed by P P P during circuit evaluation。
本文的方案在Setty等人2018年论文(Spice[91])《Proving the correct execution of concurrent services in zero-knowledge》的offline memory checking技术[31] 的基础上进行了改进。(Spice[91]) 构建circuits to encode operations on persistent storage with serializable transactions。The storage abstraction can be used as a memory abstraction where for
m
m
m operations, the circuit is of size
O
(
m
)
O(m)
O(m),但是其constant比vRAM要差:
≥
1000
\geq 1000
≥1000 (to encode an elliptic-curve based multiset collision-resistant hash function for each memory operation)。
本文则通过设计an offline memory checking primitive via a new randomized check that only uses public coins来解决该问题。此外,与基于vRAM的解决方案不同,大多数的the non-deterministic witness needed by the circuit can be created by PC.Commit
(即,computation commitment 中的 Encode
算法)。
6.2.1 构建 O ( n ) O(n) O(n)-sized circuit to evaluate M ~ \tilde{M} M~
-
Encoding sparse polynomials:
已知a sparse polynomial M ~ \tilde{M} M~ (如 M ~ ∈ { A ~ , B ~ , C ~ } \tilde{M}\in\{\tilde{A},\tilde{B},\tilde{C}\} M~∈{A~,B~,C~}),可将其表示为 n n n tuples of the form ( i , j , M ( i , j ) ) (i,j,M(i,j)) (i,j,M(i,j)),其中每个tuple具有 3 elements of F \mathbb{F} F 使得 M ( i , j ) ≠ 0 M(i,j)\neq 0 M(i,j)=0。
【注意,此处的encode与 P C n a i v e PC^{naive} PCnaive的不同, P C n a i v e PC^{naive} PCnaive中是将 i , j i,j i,j encode 为a vector of s s s elements of { 0 , 1 } ∈ F \{0,1\}\in\mathbb{F} {0,1}∈F,而此处是 pack s s s bits in i i i (or j j j) into a single element of F \mathbb{F} F,因为 s < log ∣ F ∣ s<\log{|\mathbb{F}|} s<log∣F∣使得该pack可行。】
为了表示方便,将该 n n n tuples中的每个元素以 r o w , c o l , v a l row, col,val row,col,val表示,则有:
for k ∈ [ 0 , n − 1 ] k\in[0,n-1] k∈[0,n−1],有 r o w ( k ) = i , c o l ( k ) = j , v a l ( k ) = M ( i , j ) row(k)=i, col(k)=j, val(k)=M(i,j) row(k)=i,col(k)=j,val(k)=M(i,j)。 -
Encoding metadata for memory checking: “Memory in the head”:
有以下6种vectors的metadata:
1) r e a d − t s r o w ∈ F n read-ts_{row}\in\mathbb{F}^n read−tsrow∈Fn (表示read 操作对应的timestamp)
2) w r i t e − t s r o w ∈ F n write-ts_{row}\in\mathbb{F}^n write−tsrow∈Fn (表示write 操作对应的timestamp)
3) a u d i t − t s r o w ∈ F m audit-ts_{row}\in\mathbb{F}^m audit−tsrow∈Fm (表示the final timestamps of memory cells in the offline memory checking primitive for the address sequence specified by r o w row row over a memory of size m = O ( 2 s ) m=O(2^s) m=O(2s)。)
4) r e a d − t s c o l ∈ F n read-ts_{col}\in\mathbb{F}^n read−tscol∈Fn
5) w r i t e − t s c o l ∈ F n write-ts_{col}\in\mathbb{F}^n write−tscol∈Fn
6) a u d i t − t s c o l ∈ F m audit-ts_{col}\in\mathbb{F}^m audit−tscol∈Fm
计算这些metadata仅需要如下参数:
(1)memory size (已由 2 s = m 2^s=m 2s=m确定);
(2)the sequence of addresses at which the memory is accessed (由 r o w row row和 c o l col col提供)。
相应的rust伪代码示意为:
-
Circuit description:
需采用multiset hash functions,与Spice [91]中采用的ECC-based multiset hash functions不同,本文采用了 a public-coin hash function that verifies the desired multiset relationship。
定义2个hash函数:(其中 F ∗ \mathbb{F}^* F∗表示a multiset with elements from F \mathbb{F} F, γ ∈ R F \gamma\in_R\mathbb{F} γ∈RF。)
1) h γ : F 3 → F h_{\gamma}:\mathbb{F}^3\rightarrow \mathbb{F} hγ:F3→F:
h γ ( a , v , t ) = a ⋅ γ 2 + v ⋅ γ + t h_{\gamma}(a,v,t)=a\cdot \gamma^2+v\cdot \gamma+t hγ(a,v,t)=a⋅γ2+v⋅γ+t …… (2)
2) H γ : F ∗ → F \mathcal{H}_{\gamma}:\mathbb{F}^*\rightarrow \mathbb{F} Hγ:F∗→F:
H γ ( M ) = ∏ e ∈ M ( e − γ ) \mathcal{H}_{\gamma}(M)=\prod_{e\in M}(e-\gamma) Hγ(M)=∏e∈M(e−γ) …… (3)
若已知 ( A , V , T ) ∈ ( F l , F l , F l ) (A,V,T)\in(\mathbb{F}^l,\mathbb{F}^l,\mathbb{F}^l) (A,V,T)∈(Fl,Fl,Fl) for l > 0 l>0 l>0,可定义a map H γ : ( F l , F l , F l ) → F l H_{\gamma}:(\mathbb{F}^l,\mathbb{F}^l,\mathbb{F}^l)\rightarrow \mathbb{F}^l Hγ:(Fl,Fl,Fl)→Fl:
H γ ( A , V , T ) = [ h γ ( A [ 0 ] , V [ 0 ] , T [ 0 ] ) , ⋯ , h γ ( A [ l − 1 ] , V [ l − 1 ] , T [ l − 1 ] ) ] H_{\gamma}(A,V,T)=[h_{\gamma}(A[0], V[0], T[0]),\cdots,h_{\gamma}(A[l-1],V[l-1],T[l-1])] Hγ(A,V,T)=[hγ(A[0],V[0],T[0]),⋯,hγ(A[l−1],V[l−1],T[l−1])]
这两个hash函数和相应的map具有如下特性:
整个circuit可表示为:
以上cricuit description具有如下特性:
6.2.2 构建a polynomial commitment scheme用于高效实现computation commitment
本节的目的是构建a polynomial commitment scheme,用于高效实现5.4节提到的computation commitment。
Spartan verifier会运行the Commit
algorithm (of the sparse polynomial commitment scheme) as part of the Encode
algorithm,所以与通常的polynomial commitment不同,此处创建a commitment的entity是the Verifier自身,而不是an untrusted entity。
因此,the additional memory-checking metadata about the sparse polynomial as part of Commit
也是由Verifier创建的,所以我们不需要验证that the timestamps are well-formed according to its specification in the MemoryInTheHead
procedure as required by lemma 7.5。(这仅是个优化,而不是限制)
总体上来说,Commit
是由 an untrusted entity执行的,可要求其同时提供a proof that proves that timestamps are well-formed。
完整的polynomial commitment scheme for computation commitment实现思路为:
C
i
r
c
u
i
t
e
v
a
l
−
o
p
t
Circuit_{eval-opt}
Circuiteval−opt为uniform的 because computing
H
\mathcal{H}
H using a binary tree of multiplications [96] constitues nearly all of the work in the above circuit。
根据不同的PC选型,相应的
P
C
S
P
A
R
K
PC^{SPARK}
PCSPARK cost为:
6.2.3 优化
可对SPARK做如下优化,以reduce constants:
- 由于在computation commitment中不要求zero-knowledge,因此可使用[96]中的思路来替换Hyrax as a black box。
- For computation commitments, we build a single circuit that produces evaluations of A ~ , B ~ , C ~ \tilde{A},\tilde{B},\tilde{C} A~,B~,C~ at ( r x , r y ) (r_x,r_y) (rx,ry)。This enables reusing parts of the memory checking circuit (related to the state of the memory) across evaluations。
- 在本文的场景中,可设置 ∀ 0 ≤ i < n : w r i t e − t s r o w [ i ] = r e a d − t s r o w [ i ] + 1 , w r i t e − t s c o l [ i ] = r e a d − t s c o l [ i ] + 1 \forall 0\leq i<n: write-ts_{row}[i]=read-ts_{row}[i]+1, write-ts_{col}[i]=read-ts_{col}[i]+1 ∀0≤i<n:write−tsrow[i]=read−tsrow[i]+1,write−tscol[i]=read−tscol[i]+1。这样就可以不要commit to w r i t e − t s r o w ~ \widetilde{write-ts_{row}} write−tsrow 和 w r i t e − t s c o l ~ \widetilde{write-ts_{col}} write−tscol 。(原因在于与传统的offline memory checking setting不同,传统的offline memory checking setting中其read timestamps是不可信的。)
- During
P
C
S
P
A
R
K
.
E
v
a
l
PC^{SPARK}.Eval
PCSPARK.Eval,at the witness layer in Hyrax,
V
V
V需要evaluate a number of multilinear polynomial at either
r
r
o
w
,
r
c
o
l
∈
F
log
n
r_{row},r_{col}\in\mathbb{F}^{\log n}
rrow,rcol∈Flogn or
r
m
e
m
∈
F
log
m
r_{mem}\in\mathbb{F}^{\log m}
rmem∈Flogm。可借助其succinct representations来避免对其commit:
- 可以将 k k k个 μ \mu μ-variate multilinear polynomials combine为a single multilinear polynomial over μ + log k \mu+\log k μ+logk variables。本文借助这种combination可reduce the number of committed multilinear polynomials from 23 to 3。
7. 实现及性能对比
本文将Spartan与如下方案进行了对比:
- Groth16 [41] Groth 2016年论文《On the size of pairing-based non-interactive arguments》,为效率最高的zkSNARK with trusted setup,其实现基于GGPR [58] Gennaro等人2013年论文《Quadratic span programs and succinct NIZKs without PCPs》。
- Ligero [6] Ames等人2017年论文《Ligero: Lightweight sublinear arguments without a trusted setup》,为a prior proof-succinct NIZK with a light-weight prover。
- Hyrax [103] Wahby等人2018年论文《Hyrax: Doubly-efficient zkSNARKs without trusted setup》,为a prior transparent zkSNARK that achieves sub-linear verification costs for data-parallel computations。
- Aurora [21] Ben-Sasson等人2019年论文《Aurora: Transparent succinct arguments for R1CS》 为 a prior proof-succinct NIZK。
- Fractal [46] Chiesa等人2019年论文《Fractal: Post-quantum and transparent recursive proofs from holography》,为 a recent transparent zkSNARK that instantiates computation commitments to achieve sub-linear verification costs。
其它相关研究性能对比:(基于本文实际代码测试出的性能结论)
- STARK [15]的性能比Aurora差 for arbitrary R1CS instances。
- Virgo [107] specialized to layered circuits over F p \mathbb{F}_p Fp,其中 p = 2 61 − 1 p=2^{61}-1 p=261−1,因此其将阻碍computations such as cryptographic operations that operate over fields of size ≈ 2 256 \approx 2^{256} ≈2256 [1,40,41,76,86,105]。Swithching to such a prime field increases Virgo’s reproted prover’s costs by at least 17 × 17\times 17×,比Spartan慢。
- SuperSonic [39] 中评估了 a proof size of ≈ 10 K B \approx 10KB ≈10KB and a verification time of ≈ 100 \approx 100 ≈100 ms for a 2 20 2^{20} 220-gate circuit,但是他们没有报告相应的Prover’s costs,我们实际测试发现they can be several orders of magnitude higher than S p a r t a n D L Spartan_{DL} SpartanDL。
- Bulletproofs [42] is a NIZK with short proofs ( ≈ 1.5 K B \approx 1.5KB ≈1.5KB),但是其concrete costs are orders of magnitude higher than Spartan and other schemes [106, Table 1]。对于circuits with 2 20 2^{20} 220 gates,我们评估the Prover takes ≈ 804 \approx 804 ≈804 s,而Verifier takes ≈ 31 \approx 31 ≈31 s。
实际性能对比时的代码库和曲线选型等参数信息如下:
- Groth16:性能测试时基于的是 C++代码库中的bn128曲线:
https://github.com/scipr-lab/libsnark: - Hyrax:在https://github.com/hyraxZK/fennel 代码库的基础上,基于curve25519进行了重构实现。To compare Spartan with Hyrax, we tranform R1CS instances to depth-1 arithmetic circuits where the circuit evaluates constraints in the R1CS instance, and outputs a vector of zeros when all constraints are satisfied。For an arbitrary R1CS instance, this circuit has no structure, and hence Hyrax incurs linear-time verification costs。
- Ligero、Aurora 和 Fractal 中,均采用的 https://github.com/scipr-lab/libiop 代码库 with prime field of size
≈
2
256
\approx 2^{256}
≈2256。其中Aurora和Fractal的实现支持两组参数:proven和non-proven (also known as heuristic)。该代码库中默认的是heuristic parameters,需依赖non-standard conjectures related to Reed-Solomon codes (如,in the FRI protocol) for soundness。
与proven parameters相比,the heuristic parameters使用了 ≈ 10 × \approx 10\times ≈10× fewer query repetitions of FRI,所以,相比于provable版本,heuristic版本实现了 ≈ 10 × \approx 10\times ≈10× lower verification costs and proof size。
最终的性能对比如下图所示:(从Prove time; Proof size; Verify time; preprocess encode time 这四个方面进行了对比)
参考资料
1.medium博客 Spartan: zkSNARKS without trusted setup