零知识证明 - Groth16算法介绍

看zk-SNARK的文章或者资料的时候,经常会碰到一些算法名称,比如Groth16,GGPR13等等。这些名称是由算法提出的作者名称或者名称首字母以及相应的年份组成。Groth16,是由Jens Groth在2016年提出的算法。GGPR13,是由Rosario Gennaro,Craig Gentry,Bryan Parno,Mariana Raykova在2013年提出的算法。

零知识证明(zk-SNARK ),从QSP/QAP到Groth16,期间也有很多学者专家,提出各种优化(优化计算时间,优化证明的大小,优化电路的尺寸等等)。Groth16提出的算法,具有非常少的证明数据(2/3个证明数据)以及一个表达式验证。

Groth16论文(On the Size of Pairing-based Non-interactive Arguments)的下载地址:

https://eprint.iacr.org/2016/260.pdf

本文主要从工程应用理解的角度介绍Groth16算法的证明和验证过程。文章中所用的中文字眼可能和行业中不一样,欢迎批评指出。

术语介绍

Proofs - 在零知识证明的场景下,Proofs指具有完美的完备性(Completeness)以及完美的可靠性(Soundness)。也就是,具有无限计算资源也无法攻破。

Arguments - 在零知识证明的场景下,Arguments是指具有完美的完备性以及多项式计算的可靠性。也就是,在多项式计算能力下,是可靠的。

Schwartz-Zippel 定理 - 假设 f ( x 1 , x 2 , . . . , x n ) f(x_1, x_2, ..., x_n) f(x1,x2,...,xn)是个n元多项式,多项式总的阶为d。如果 r 1 , r 2 , . . . , r n r_1, r_2, ..., r_n r1,r2,...,rn是从有限集合S中随机选取,则 f ( r 1 , r 2 , . . . , r n ) = 0 f(r_1, r_2, ..., r_n) = 0 f(r1,r2,...,rn)=0的概率是小于等于 d ∣ s ∣ \frac{d}{|s|} sd。简单的说,如果多元多项式,在很大的集合中随机选取参数,恰好函数f等于0的概率几乎为0。

https://brilliant.org/wiki/schwartz-zippel-lemma/

线性(Linear)函数 - 假设函数f满足两个条件:1. f ( x + y ) = f ( x ) + f ( y ) f(x+y) = f(x)+f(y) f(x+y)=f(x)+f(y) 2. f ( α x ) = α f ( x ) f(\alpha x) = \alpha f(x) f(αx)=αf(x),则称函数f为线性函数。

Affine 函数 - 假设函数g,能找到一个线性函数f,满足 g ( x ) = f ( x ) + b g(x) = f(x) + b g(x)=f(x)+b,则称函数g为Affine函数。也就是,Affine函数是由一个线性函数和偏移构成。

Trapdoor函数 - 假设一个Trapdoor函数f, x → f ( x ) x \to f(x) xf(x) 很容易,但是 f ( x ) → x f(x) \to x f(x)x非常难。但是,如果提供一个secret, f ( x ) → x f(x) \to x f(x)x也非常容易。

Jens Groth是谁?

Groth是英国伦敦UCL大学的计算机系的教授。伦敦大学学院 (University College London),简称UCL,建校于1826年,位于英国伦敦,是一所世界著名的顶尖高等学府,为享有顶级声誉的综合研究型大学,伦敦大学联盟创始院校,英国金三角名校,与剑桥大学、牛津大学、帝国理工、伦敦政经学院并称G5超级精英大学。

http://www0.cs.ucl.ac.uk/staff/j.groth/

Groth从2009年开始,每年发表一篇或者多篇密码学或者零知识证明的文章,所以你经常会听到Groth09,Groth10等等算法。

简言之,牛人~。

NILP

Groth16的论文先引出NILP(non-interactive linear proofs)的定义:

  1. ( σ , τ ) ← S e t u p ( R ) (\sigma, \tau) \gets Setup(R) (σ,τ)Setup(R) :设置过程,生成 σ ∈ F m \sigma \in F^m σFm, τ ∈ F n \tau \in F^n τFn

  2. π ← P r o v e ( R , σ , ϕ , ω ) \pi \gets Prove(R, \sigma, \phi, \omega) πProve(R,σ,ϕ,ω) :证明过程,证明过程又分成两步:a. 生成线性关系 Π ← P r o o f M a t r i x ( R , ϕ , ω ) \Pi \gets ProofMatrix(R, \phi, \omega) ΠProofMatrix(R,ϕ,ω),其中ProofMatrix是个多项式算法。b. 生成证明: π = Π σ \pi = \Pi\sigma π=Πσ

  3. 0 / 1 ← V f y ( R , σ , ϕ , π ) 0/1 \gets Vfy(R, \sigma, \phi, \pi) 0/1Vfy(R,σ,ϕ,π) :验证过程,验证者使用 ( R , ϕ ) (R, \phi) (R,ϕ)生成电路t,并验证 t ( σ , π ) t(\sigma, \pi) t(σ,π)是否成立。

在NILP定义的基础上,Groth16进一步定义了split NILP,也就是说,CRS分成两部分 ( σ 1 , σ 2 ) (\sigma1, \sigma2) (σ1,σ2),证明者提交的证明也分成两部分 ( π 1 , π 2 ) (\pi1, \pi2) (π1,π2)

总的来说,核心在“Linear”上,证明者生成的证明和CRS成线性关系。

QAP的NILP

QAP的定义为"Relation": R = ( F , a u x , ℓ , { u i ( X ) , v i ( X ) , w i ( X ) } i = 0 m , t ( X ) ) R=(F, aux, \ell, \{u_i(X), v_i(X), w_i(X)\}_{i=0}^m, t(X)) R=(F,aux,,{ui(X),vi(X),wi(X)}i=0m,t(X))。也就是说,statements为 ( a 1 , . . . , a ℓ ) ∈ F ℓ (a_1, ..., a_\ell) \in F^\ell (a1,...,a)F, witness为 ( a l + 1 , . . . , a m ) ∈ F m − ℓ (a_{l+1}, ..., a_m) \in F^{m-\ell} (al+1,...,am)Fm,并且 a 0 = 1 a_0 = 1 a0=1的情况下,满足如下的等式:

∑ i = 0 m a i u i ( X ) ⋅ ∑ i = 0 m a i v i ( X ) = ∑ i = 0 m a i w i ( X ) + h ( X ) t ( X ) \sum_{i=0}^m a_iu_i(X) \cdot \sum_{i=0}^m a_iv_i(X) = \sum_{i=0}^m {a_iw_i(X)+h(X)t(X)} i=0maiui(X)i=0maivi(X)=i=0maiwi(X)+h(X)t(X)

t ( X ) t(X) t(X)的阶为n。

  1. 设置过程:随机选取 α , β , γ , δ , x ← F ∗ \alpha, \beta, \gamma, \delta, x \gets F^* α,β,γ,δ,xF,生成 σ , τ \sigma, \tau σ,τ

    τ = ( α , β , γ , δ , x ) \tau = (\alpha, \beta, \gamma, \delta, x) τ=(α,β,γ,δ,x)

    σ = ( α , β , γ , δ , { x i } i = 0 n − 1 , { β u i ( x ) + α v i ( x ) + w i ( x ) γ } i = 0 ℓ , { β u i ( x ) + α v i ( x ) + w i ( x ) δ } i = ℓ + 1 m , { x i t ( x ) δ } i = 0 n − 2 ) \sigma = (\alpha, \beta, \gamma, \delta, \{x^i\}_{i=0}^{n-1}, \{\cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\gamma}\}_{i=0}^\ell, \{\cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\delta}\}_{i=\ell+1}^m, \{\cfrac{x^it(x)}{\delta}\}_{i=0}^{n-2}) σ=(α,β,γ,δ,{xi}i=0n1,{γβui(x)+αvi(x)+wi(x)}i=0,{δβui(x)+αvi(x)+wi(x)}i=+1m,{δxit(x)}i=0n2)

  2. 证明过程:随机选择两个参数 r 和 s r和s rs,计算 π = Π σ = ( A , B , C ) \pi = \Pi\sigma = (A, B, C) π=Πσ=(A,B,C)

    A = α + ∑ i = 0 m a i u i ( x ) + r δ A = \alpha + \sum_{i=0}^{m} a_i u_i(x) + r\delta A=α+i=0maiui(x)+rδ

    B = β + ∑ i = 0 m a i v i ( x ) + s δ B = \beta + \sum_{i=0}^{m} a_i v_i(x) + s\delta B=β+i=0maivi(x)+sδ

    C = ∑ i = ℓ + 1 m a i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) + h ( x ) t ( x ) δ + A s + r B − r s δ C = \cfrac{\sum_{i=\ell+1}^m a_i (\beta u_i(x)+\alpha v_i(x)+w_i(x))+h(x)t(x)}{\delta} + As + r B - r s \delta C=δi=+1mai(βui(x)+αvi(x)+wi(x))+h(x)t(x)+As+rBrsδ

  3. 验证过程:

    验证过程,计算如下的等式是否成立:

    A ⋅ B = α ⋅ β + ∑ i = 0 ℓ a i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) γ ⋅ γ + C ⋅ δ A\cdot B = \alpha \cdot \beta + \cfrac{\sum_{i=0}^\ell a_i (\beta u_i(x)+\alpha v_i(x)+w_i(x))}{\gamma} \cdot \gamma + C \cdot \delta AB=αβ+γi=0ai(βui(x)+αvi(x)+wi(x))γ+Cδ

注意,设置过程中的x是一个值,不是代表多项式。在理解证明/验证过程的时候,必须要明确,A/B/C的计算是和CRS中的参数成线性关系(NILP的定义)。在明确这一点的基础上,可以看出 α 和 β \alpha和 \beta αβ的参数能保证A/B/C的计算采用统一的 a 0 , a 1 , . . . , a m a_0, a_1, ... , a_m a0,a1,...,am参数。因为 A ⋅ B A\cdot B AB会包含 ∑ i = 0 ℓ a i ( β u i ( x ) + α v i ( x ) ) \sum_{i=0}^\ell a_i (\beta u_i(x)+\alpha v_i(x)) i=0ai(βui(x)+αvi(x))子项,要保证 A ⋅ B A\cdot B AB和C相等,必须采用统一的 a 0 , a 1 , . . . , a m a_0, a_1, ... , a_m a0,a1,...,am参数。参数 r 和 s r和s rs增加随机因子,保证零知识(验证者无法从证明中获取有用信息)。参数 γ 和 δ \gamma和\delta γδ保证了验证等式的最后两个乘积独立于 α 和 β \alpha和 \beta αβ的参数。

完备性证明(Completeness):
完备性证明,也就是验证等式成立。

A ⋅ B = ( α + ∑ i = 0 m a i u i ( x ) + r δ ) ⋅ ( β + ∑ i = 0 m a i v i ( x ) + s δ ) A\cdot B = (\alpha + \sum_{i=0}^{m} a_i u_i(x) + r\delta) \cdot (\beta + \sum_{i=0}^{m} a_i v_i(x) + s\delta) AB=(α+i=0maiui(x)+rδ)(β+i=0maivi(x)+sδ)

= α ⋅ β + α ⋅ ∑ i = 0 m a i v i ( x ) + α s δ = \alpha \cdot \beta + \alpha \cdot \sum_{i=0}^{m} a_i v_i(x) + \alpha s \delta =αβ+αi=0maivi(x)+αsδ
+ β ⋅ ∑ i = 0 m a i u i ( x ) + ∑ i = 0 m a i u i ( x ) ⋅ ∑ i = 0 m a i v i ( x ) + s δ ⋅ ∑ i = 0 m a i u i ( x ) + \beta \cdot \sum_{i=0}^{m} a_i u_i(x) + \sum_{i=0}^{m} a_i u_i(x) \cdot \sum_{i=0}^{m} a_i v_i(x) + s\delta \cdot \sum_{i=0}^{m} a_i u_i(x) +βi=0maiui(x)+i=0maiui(x)i=0maivi(x)+sδi=0maiui(x)
+ r δ β + r δ ∑ i = 0 m a i v i ( x ) + r s δ 2 + r\delta \beta + r\delta \sum_{i=0}^{m} a_i v_i(x) + rs\delta^2 +rδβ+rδi=0maivi(x)+rsδ2

= α ⋅ β + ∑ i = 0 ℓ a i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) + ∑ i = ℓ + 1 m a i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) + h ( t ) ⋅ t ( x ) = \alpha \cdot \beta + \sum_{i=0}^\ell a_i (\beta u_i(x)+\alpha v_i(x)+w_i(x)) + \sum_{i=\ell + 1}^m a_i (\beta u_i(x)+\alpha v_i(x)+w_i(x)) + h(t)\cdot t(x) =αβ+i=0ai(βui(x)+αvi(x)+wi(x))+i=+1mai(βui(x)+αvi(x)+wi(x))+h(t)t(x)

+ α s δ + s δ ⋅ ∑ i = 0 m a i u i ( x ) + r s δ 2 + \alpha s \delta + s\delta \cdot \sum_{i=0}^{m} a_i u_i(x) + r s \delta^2 +αsδ+sδi=0maiui(x)+rsδ2

+ r δ β + r δ ∑ i = 0 m a i v i ( x ) + r s δ 2 + r\delta \beta + r\delta \sum_{i=0}^{m} a_i v_i(x) + r s \delta^2 +rδβ+rδi=0maivi(x)+rsδ2

− r s δ 2 - r s \delta^2 rsδ2

= α ⋅ β + ∑ i = 0 ℓ a i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) + ∑ i = ℓ + 1 m a i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) + h ( t ) ⋅ t ( x ) = \alpha \cdot \beta + \sum_{i=0}^\ell a_i (\beta u_i(x)+\alpha v_i(x)+w_i(x)) + \sum_{i=\ell + 1}^m a_i (\beta u_i(x)+\alpha v_i(x)+w_i(x)) + h(t)\cdot t(x) =αβ+i=0ai(βui(x)+αvi(x)+wi(x))+i=+1mai(βui(x)+αvi(x)+wi(x))+h(t)t(x)

+ A s δ + r B δ − r s δ 2 + A s \delta + r B \delta - r s \delta^2 +Asδ+rBδrsδ2

= α ⋅ β + ∑ i = 0 ℓ a i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) γ ⋅ γ + C ⋅ δ = \alpha \cdot \beta + \cfrac{\sum_{i=0}^\ell a_i (\beta u_i(x)+\alpha v_i(x)+w_i(x))}{\gamma} \cdot \gamma + C \cdot \delta =αβ+γi=0ai(βui(x)+αvi(x)+wi(x))γ+Cδ

可靠性证明 (Soundness):

Groth16算法证明的是statistical knowledge soundness,假设证明者提供的证明和CRS成线性关系。也就是说,证明A可以用如下的表达式表达(A和CRS的各个参数成线性关系):

A = A α α + A β β + A γ γ + A δ δ + A ( x ) + ∑ i = 0 ℓ A i β u i ( x ) + α v i ( x ) + w i ( x ) γ + ∑ i = ℓ + 1 m A i β u i ( x ) + α v i ( x ) + w i ( x ) δ + A h ( x ) t ( x ) δ A = A_\alpha \alpha + A_\beta \beta + A_\gamma \gamma + A_\delta \delta + A(x) + \sum_{i=0}^{\ell} A_i \cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\gamma} + \sum_{i=\ell + 1}^{m} A_i \cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\delta} + A_h(x)\cfrac{t(x)}{\delta} A=Aαα+Aββ+Aγγ+Aδδ+A(x)+i=0Aiγβui(x)+αvi(x)+wi(x)+i=+1mAiδβui(x)+αvi(x)+wi(x)+Ah(x)δt(x)

同理,B/C都可以写成类似的表达:

B = B α α + B β β + B γ γ + B δ δ + B ( x ) + ∑ i = 0 ℓ B i β u i ( x ) + α v i ( x ) + w i ( x ) γ + ∑ i = ℓ + 1 m B i β u i ( x ) + α v i ( x ) + w i ( x ) δ + B h ( x ) t ( x ) δ B = B_\alpha \alpha + B_\beta \beta + B_\gamma \gamma + B_\delta \delta + B(x) + \sum_{i=0}^{\ell} B_i \cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\gamma} + \sum_{i=\ell + 1}^{m} B_i \cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\delta} + B_h(x)\cfrac{t(x)}{\delta} B=Bαα+Bββ+Bγγ+Bδδ+B(x)+i=0Biγβui(x)+αvi(x)+wi(x)+i=+1mBiδβui(x)+αvi(x)+wi(x)+Bh(x)δt(x)

C = C α α + C β β + C γ γ + C δ δ + C ( x ) + ∑ i = 0 ℓ C i β u i ( x ) + α v i ( x ) + w i ( x ) γ + ∑ i = ℓ + 1 m C i β u i ( x ) + α v i ( x ) + w i ( x ) δ + C h ( x ) t ( x ) δ C = C_\alpha \alpha + C_\beta \beta + C_\gamma \gamma + C_\delta \delta + C(x) + \sum_{i=0}^{\ell} C_i \cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\gamma} + \sum_{i=\ell + 1}^{m} C_i \cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\delta} + C_h(x)\cfrac{t(x)}{\delta} C=Cαα+Cββ+Cγγ+Cδδ+C(x)+i=0Ciγβui(x)+αvi(x)+wi(x)+i=+1mCiδβui(x)+αvi(x)+wi(x)+Ch(x)δt(x)

从Schwartz-Zippel 定理,我们可以把A/B/C看作是 α , β , γ , δ , x \alpha, \beta, \gamma, \delta, x α,β,γ,δ,x的多项式。观察 A ⋅ B = α ⋅ β + ∑ i = 0 ℓ a i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) γ ⋅ γ + C ⋅ δ A\cdot B = \alpha \cdot \beta + \cfrac{\sum_{i=0}^\ell a_i (\beta u_i(x)+\alpha v_i(x)+w_i(x))}{\gamma} \cdot \gamma + C \cdot \delta AB=αβ+γi=0ai(βui(x)+αvi(x)+wi(x))γ+Cδ 这个验证等式,发现一些变量的限制条件:

1) A α B α α 2 = 0 A_\alpha B_\alpha \alpha^2 = 0 AαBαα2=0 (等式的右边没有 α 2 因 子 \alpha^2因子 α2)

不失一般性,可以假设 B α = 0 B_\alpha = 0 Bα=0

2) A α B β + A β B α = A α B β = 1 A_\alpha B_\beta + A_\beta B_\alpha = A_\alpha B_\beta = 1 AαBβ+AβBα=AαBβ=1 (等式右边 α β = 1 \alpha \beta = 1 αβ=1

不失一般性,可以假设 A α = B β = 1 A_\alpha = B_\beta = 1 Aα=Bβ=1

3) A β B β = A β = 0 A_\beta B_\beta = A_\beta = 0 AβBβ=Aβ=0(等式的右边没有 β 2 \beta^2 β2因子)

也就是 A β = 0 A_\beta = 0 Aβ=0

在上述三个约束下,A/B的表达式变成:

A = α + A γ γ + A δ δ + A ( x ) + ∑ i = 0 ℓ A i β u i ( x ) + α v i ( x ) + w i ( x ) γ + ∑ i = ℓ + 1 m A i β u i ( x ) + α v i ( x ) + w i ( x ) δ + A h ( x ) t ( x ) δ A = \alpha + A_\gamma \gamma + A_\delta \delta + A(x) + \sum_{i=0}^{\ell} A_i \cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\gamma} + \sum_{i=\ell + 1}^{m} A_i \cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\delta} + A_h(x)\cfrac{t(x)}{\delta} A=α+Aγγ+Aδδ+A(x)+i=0Aiγβui(x)+αvi(x)+wi(x)+i=+1mAiδβui(x)+αvi(x)+wi(x)+Ah(x)δt(x)

B = β + B γ γ + B δ δ + B ( x ) + ∑ i = 0 ℓ B i β u i ( x ) + α v i ( x ) + w i ( x ) γ + ∑ i = ℓ + 1 m B i β u i ( x ) + α v i ( x ) + w i ( x ) δ + B h ( x ) t ( x ) δ B = \beta + B_\gamma \gamma + B_\delta \delta + B(x) + \sum_{i=0}^{\ell} B_i \cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\gamma} + \sum_{i=\ell + 1}^{m} B_i \cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\delta} + B_h(x)\cfrac{t(x)}{\delta} B=β+Bγγ+Bδδ+B(x)+i=0Biγβui(x)+αvi(x)+wi(x)+i=+1mBiδβui(x)+αvi(x)+wi(x)+Bh(x)δt(x)

4)等式的右边没有 1 δ 2 \cfrac{1}{\delta^2} δ21

( ∑ i = ℓ + 1 m A i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) + A h ( x ) t ( x ) ) ( ∑ i = ℓ + 1 m B i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) + A h ( x ) t ( x ) ) = 0 (\sum_{i=\ell+1}^m A_i(\beta u_i(x) + \alpha v_i(x) + w_i(x)) + A_h(x)t(x))(\sum_{i=\ell+1}^m B_i(\beta u_i(x) + \alpha v_i(x) + w_i(x)) + A_h(x)t(x)) = 0 (i=+1mAi(βui(x)+αvi(x)+wi(x))+Ah(x)t(x))(i=+1mBi(βui(x)+αvi(x)+wi(x))+Ah(x)t(x))=0

不失一般性, ∑ i = ℓ + 1 m A i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) + A h ( x ) t ( x ) = 0 \sum_{i=\ell+1}^m A_i(\beta u_i(x) + \alpha v_i(x) + w_i(x)) + A_h(x)t(x) = 0 i=+1mAi(βui(x)+αvi(x)+wi(x))+Ah(x)t(x)=0

5)等式的右边没有 1 γ 2 \cfrac{1}{\gamma^2} γ21

( ∑ i = 0 ℓ A i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) ) ( ∑ i = 0 ℓ B i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) ) = 0 (\sum_{i=0}^\ell A_i(\beta u_i(x) + \alpha v_i(x) + w_i(x)))(\sum_{i=0}^\ell B_i(\beta u_i(x) + \alpha v_i(x) + w_i(x))) = 0 (i=0Ai(βui(x)+αvi(x)+wi(x)))(i=0Bi(βui(x)+αvi(x)+wi(x)))=0

不失一般性, ∑ i = 0 ℓ A i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) = 0 \sum_{i=0}^\ell A_i(\beta u_i(x) + \alpha v_i(x) + w_i(x)) = 0 i=0Ai(βui(x)+αvi(x)+wi(x))=0

6)等式的右边没有 α γ \cfrac{\alpha}{\gamma} γα α δ \cfrac{\alpha}{\delta} δα

α ∑ i = 0 ℓ B i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) γ = 0 \alpha \cfrac{\sum_{i=0}^\ell B_i(\beta u_i(x) + \alpha v_i(x) + w_i(x))}{\gamma} = 0 αγi=0Bi(βui(x)+αvi(x)+wi(x))=0

α ∑ i = ℓ + 1 m B i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) + B h ( x ) t ( x ) δ = 0 \alpha \cfrac{\sum_{i=\ell+1}^m B_i(\beta u_i(x) + \alpha v_i(x) + w_i(x)) + B_h(x)t(x)}{\delta} = 0 αδi=+1mBi(βui(x)+αvi(x)+wi(x))+Bh(x)t(x)=0

所以, ∑ i = 0 ℓ B i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) = 0 , ∑ i = ℓ + 1 m B i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) + B h ( x ) t ( x ) \sum_{i=0}^\ell B_i(\beta u_i(x) + \alpha v_i(x) + w_i(x)) = 0,\sum_{i=\ell+1}^m B_i(\beta u_i(x) + \alpha v_i(x) + w_i(x)) + B_h(x)t(x) i=0Bi(βui(x)+αvi(x)+wi(x))=0i=+1mBi(βui(x)+αvi(x)+wi(x))+Bh(x)t(x)

7)等式的右边没有 β γ \beta \gamma βγ α γ \alpha\gamma αγ

A γ β γ = 0 , B γ α γ = 0 A_\gamma \beta \gamma = 0, B_\gamma \alpha \gamma = 0 Aγβγ=0,Bγαγ=0

所以, A γ = 0 , B γ = 0 A_\gamma =0, B_\gamma = 0 Aγ=0,Bγ=0

在上述七个约束下,A/B的表达式变成:

$A = \alpha + A_\delta \delta + A(x) $

B = β + B δ δ + B ( x ) B = \beta + B_\delta \delta + B(x) B=β+Bδδ+B(x)

再看验证的等式:

A ⋅ B = α ⋅ β + ∑ i = 0 ℓ a i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) γ ⋅ γ + C ⋅ δ A\cdot B = \alpha \cdot \beta + \cfrac{\sum_{i=0}^\ell a_i (\beta u_i(x)+\alpha v_i(x)+w_i(x))}{\gamma} \cdot \gamma + C \cdot \delta AB=αβ+γi=0ai(βui(x)+αvi(x)+wi(x))γ+Cδ

= α ⋅ β + ∑ i = 0 ℓ a i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) + C ⋅ δ = \alpha \cdot \beta + \sum_{i=0}^\ell a_i (\beta u_i(x)+\alpha v_i(x)+w_i(x)) + C \cdot \delta =αβ+i=0ai(βui(x)+αvi(x)+wi(x))+Cδ

观察 C ⋅ δ C \cdot \delta Cδ,因为不存在 δ γ \cfrac{\delta}{\gamma} γδ,所以, ∑ i = 0 ℓ C i β u i ( x ) + α v i ( x ) + w i ( x ) γ = 0 \sum_{i=0}^{\ell} C_i \cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\gamma} = 0 i=0Ciγβui(x)+αvi(x)+wi(x)=0

也就是说, C = C α α + C β β + C γ γ + C δ δ + C ( x ) + ∑ i = ℓ + 1 m C i β u i ( x ) + α v i ( x ) + w i ( x ) δ + C h ( x ) t ( x ) δ C = C_\alpha \alpha + C_\beta \beta + C_\gamma \gamma + C_\delta \delta + C(x) + \sum_{i=\ell + 1}^{m} C_i \cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\delta} + C_h(x)\cfrac{t(x)}{\delta} C=Cαα+Cββ+Cγγ+Cδδ+C(x)+i=+1mCiδβui(x)+αvi(x)+wi(x)+Ch(x)δt(x)

代入验证等式,所以可以推导出:

α B ( x ) = ∑ i = 0 ℓ a i α v i ( x ) + ∑ i = ℓ + 1 m C i α v i ( x ) \alpha B(x) = \sum_{i=0}^\ell a_i \alpha v_i(x) + \sum_{i=\ell+1}^m C_i \alpha v_i(x) αB(x)=i=0aiαvi(x)+i=+1mCiαvi(x)

β A ( x ) = ∑ i = 0 ℓ a i β u i ( x ) + ∑ i = ℓ + 1 m C i β u i ( x ) \beta A(x) = \sum_{i=0}^\ell a_i \beta u_i(x) + \sum_{i=\ell+1}^m C_i \beta u_i(x) βA(x)=i=0aiβui(x)+i=+1mCiβui(x)

如果,假设,对于 i = ℓ + 1 , . . . , m , a i = C i i=\ell+1, ... , m,a_i = C_i i=+1,...,mai=Ci,则

A ( x ) = ∑ i = 0 m a i u i ( x ) A(x) = \sum_{i=0}^m a_i u_i(x) A(x)=i=0maiui(x)

B ( x ) = ∑ i = 0 m a i v i ( x ) B(x) = \sum_{i=0}^m a_i v_i(x) B(x)=i=0maivi(x)

代入A/B,可以获取以下等式:

∑ i = 0 m a i u i ( x ) ⋅ ∑ i = 0 m a i v i ( x ) = ∑ i = 0 m a i w i ( x ) + C h ( x ) t ( x ) \sum_{i=0}^ma_i u_i(x) \cdot \sum_{i=0}^ma_i v_i(x) = \sum_{i=0}^ma_i w_i(x) + C_h(x)t(x) i=0maiui(x)i=0maivi(x)=i=0maiwi(x)+Ch(x)t(x)

在证明和CRS线性关系下,所有能使验证等式成立的情况下, ( a ℓ + 1 , . . . , a m ) = ( C ℓ + 1 , . . . , C m ) (a_{\ell+1}, ... , a_m) = (C_{\ell+1}, ... , C_m) (a+1,...,am)=(C+1,...,Cm)等式必须成立。也就说,能提供正确证明的,肯定知道witness。

QAP的NIZK Arguments
从QAP的NILP可以演化为QAP的NIZK Arguments。也就是说Groth16算法并不是完美的可靠,而是多项式计算情况下可靠。QAP的定义为"Relation": R = ( p , G 1 , G 2 , G T , e , g , h , ℓ , { u i ( X ) , v i ( X ) , w i ( X ) } i = 0 m , t ( X ) ) R=(p, G_1, G_2, G_T, e, g, h, \ell, \{u_i(X), v_i(X), w_i(X)\}_{i=0}^m, t(X)) R=(p,G1,G2,GT,e,g,h,,{ui(X),vi(X),wi(X)}i=0m,t(X))。也就是说,在一个域 Z p Z_p Zp中,statements为 ( a 1 , . . . , a ℓ ) ∈ Z p ℓ (a_1, ..., a_\ell) \in Z_p^\ell (a1,...,a)Zp, witness为 ( a l + 1 , . . . , a m ) ∈ Z p m − ℓ (a_{l+1}, ..., a_m) \in Z_p^{m-\ell} (al+1,...,am)Zpm,并且 a 0 = 1 a_0 = 1 a0=1的情况下,满足如下的等式( t ( X ) t(X) t(X)的阶为n):

∑ i = 0 m a i u i ( X ) ⋅ ∑ i = 0 m a i v i ( X ) = ∑ i = 0 m a i w i ( X ) + h ( X ) t ( X ) \sum_{i=0}^m a_iu_i(X) \cdot \sum_{i=0}^m a_iv_i(X) = \sum_{i=0}^m {a_iw_i(X)}+h(X)t(X) i=0maiui(X)i=0maivi(X)=i=0maiwi(X)+h(X)t(X)

也就是说,三个有限群 G 1 , G 2 , G T G_1, G_2, G_T G1,G2,GT, 对应的生成元分别是 g , h , e ( g , h ) g, h, e(g,h) g,h,e(g,h)。为了方便起见,也为了和论文的表达方式一致, G 1 有 限 群 G_1有限群 G1的计算用 [ y ] 1 = g y [y]_1 = g^y [y]1=gy表示, G 2 有 限 群 G_2有限群 G2的计算用 [ y ] 2 = h y [y]_2 = h^y [y]2=hy表示。

  1. 设置过程:随机选取 α , β , γ , δ , x ← Z p ∗ \alpha, \beta, \gamma, \delta, x \gets Z_p^* α,β,γ,δ,xZp,生成 σ , τ \sigma, \tau σ,τ

    τ = ( α , β , γ , δ , x ) \tau = (\alpha, \beta, \gamma, \delta, x) τ=(α,β,γ,δ,x)

    σ = ( [ σ 1 ] 1 , [ σ 2 ] 2 ) \sigma = ([\sigma_1]_1, [\sigma_2]_2) σ=([σ1]1,[σ2]2)

    σ 1 = ( α , β , δ , { x i } i = 0 n − 1 , { β u i ( x ) + α v i ( x ) + w i ( x ) γ } i = 0 ℓ , { β u i ( x ) + α v i ( x ) + w i ( x ) δ } i = ℓ + 1 m , { x i t ( x ) δ } i = 0 n − 2 ) \sigma_1 = (\alpha, \beta, \delta, \{ x^i \}_{i=0}^{n-1}, \{\cfrac{\beta u_i(x)+\alpha v_i(x) + w_i(x)}{\gamma}\}_{i=0}^{\ell}, \{\cfrac{\beta u_i(x) + \alpha v_i(x) + w_i(x)}{\delta}\}_{i=\ell+1}^{m}, \{\cfrac{x^it(x)}{\delta}\}_{i=0}^{n-2}) σ1=(α,β,δ,{xi}i=0n1,{γβui(x)+αvi(x)+wi(x)}i=0,{δβui(x)+αvi(x)+wi(x)}i=+1m,{δxit(x)}i=0n2)

    σ 2 = ( β , γ , δ , { x i } i = 0 n − 1 ) \sigma_2 = (\beta, \gamma, \delta, \{x^i\}_{i=0}^{n-1}) σ2=(β,γ,δ,{xi}i=0n1)

  2. 证明过程:随机选择两个参数 r 和 s r和s rs,计算 π = Π σ = ( [ A ] 1 , [ C ] 1 , [ B ] 2 ) \pi = \Pi\sigma = ([A]_1, [C]_1, [B]_2) π=Πσ=([A]1,[C]1,[B]2)

    A = α + ∑ i = 0 m a i u i ( x ) + r δ A = \alpha + \sum_{i=0}^{m} a_i u_i(x) + r\delta A=α+i=0maiui(x)+rδ

    B = β + ∑ i = 0 m a i v i ( x ) + s δ B = \beta + \sum_{i=0}^{m} a_i v_i(x) + s\delta B=β+i=0maivi(x)+sδ

    C = ∑ i = ℓ + 1 m a i ( β u i ( x ) + α v i ( x ) + w i ( x ) ) + h ( x ) t ( x ) δ + A s + r B − r s δ C = \cfrac{\sum_{i=\ell+1}^m a_i (\beta u_i(x)+\alpha v_i(x)+w_i(x))+h(x)t(x)}{\delta} + As + r B - r s \delta C=δi=+1mai(βui(x)+αvi(x)+wi(x))+h(x)t(x)+As+rBrsδ

  3. 验证过程:验证如下的等式是否成立。

    [ A ] 1 ⋅ [ B ] 2 = [ α ] 1 ⋅ [ β ] 2 + ∑ i = 0 ℓ a i [ β u i ( x ) + α v i ( x ) + w i ( x ) γ ] 1 ⋅ [ γ ] 2 + [ C ] 1 ⋅ [ δ ] 2 [A]_1\cdot [B]_2 = [\alpha]_1 \cdot [\beta]_2 + \sum_{i=0}^\ell a_i [\cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\gamma}]_1 \cdot [\gamma]_2 + [C]_1 \cdot [\delta]_2 [A]1[B]2=[α]1[β]2+i=0ai[γβui(x)+αvi(x)+wi(x)]1[γ]2+[C]1[δ]2

很容易发现,验证过程的等式也可以用4个配对函数表示:

e ( [ A ] 1 , [ B ] 2 ) = e ( [ α ] 1 , [ β ] 2 ) ⋅ e ( ∑ i = 0 ℓ a i [ β u i ( x ) + α v i ( x ) + w i ( x ) γ ] 1 , [ γ ] 2 ) ⋅ e ( [ C ] 1 , [ δ ] 2 ) e([A]_1, [B]_2) = e([\alpha]_1, [\beta]_2) \cdot e(\sum_{i=0}^\ell a_i [\cfrac{\beta u_i(x)+\alpha v_i(x)+w_i(x)}{\gamma}]_1, [\gamma]_2) \cdot e([C]_1, [\delta]_2) e([A]1,[B]2)=e([α]1,[β]2)e(i=0ai[γβui(x)+αvi(x)+wi(x)]1,[γ]2)e([C]1,[δ]2)

证明过程和QAP的NILP的证明过程类似,不再详细展开。

证明元素的最小个数

论文指出zk-SNARK的最少的证明元素是2个。上述的证明方式是需要提供3个证明元素(A/B/C)。论文进一步说明,如果将电路进行一定方式的改造,使用同样的理论,可以降低证明元素为2个,但是,电路的大小会变的很大。

总结:Groth16算法是Jens Groth在2016年发表的算法。该算法的优点是提供的证明元素个数少(只需要3个),验证等式简单,保证完整性和多项式计算能力下的可靠性。Groth16算法论文同时指出,zk-SNARK算法需要的最少的证明元素为2个。目前Groth16算法已经被ZCash,Filecoin等项目使用。

题外:

最近好多朋友表示对零知识证明的基础知识感兴趣,但是,zk-SNARK相关的技术涉及到比较多的数学公式的推导,比较难理解。我打算有空录个QSP/QAP/Groth16的介绍视频,方便工程开发人员快速的入门和理解。觉得有需要的小伙伴,请留言。

在这里插入图片描述

你可能感兴趣的:(零知识证明)