Proof Systems for General Statements about Discrete Logarithms 学习笔记

Jan Camenisch和Markus Stadler 1997年论文《Proof Systems for General Statements about Discrete Logarithms》。

1. 背景知识

  • Monotone Boolean function定义:
    Proof Systems for General Statements about Discrete Logarithms 学习笔记
    Proof Systems for General Statements about Discrete Logarithms 学习笔记

  • Concatenation of tuples:
    Proof Systems for General Statements about Discrete Logarithms 学习笔记

  • Modified Cartesian Product:
    Proof Systems for General Statements about Discrete Logarithms 学习笔记

  • Knowledge specification set:
    Proof Systems for General Statements about Discrete Logarithms 学习笔记
    Proof Systems for General Statements about Discrete Logarithms 学习笔记

2. 一些例子

2.1 Prove knowledge of discrete logarithm y=gxy=g^x (Schnorr signature for message (g,y)(g,y))

博客 基于Sigma protocol实现的零知识证明protocol集锦 中1.2节类似:
Witness:xx
Instance:yygg
Relation:y=gxy=g^x

具体实现思路为:

  • 1)Prover:Prover生成随机数vRZqv\in_R \mathbb{Z}_q,创建commitment t=gvt=g^v;Prover将g,t,yg,t,y作为hash函数输入计算challenge c(=Hash(g,y,t))c(=Hash(g,y,t));Prover计算response r=vcx(mod  q)r=v-c*x(\mod q)。Prover将(c,r)(c,r)发送给Verifier。

Verifier根据收到的(c,r)(c,r),假设gr=yctg^r=y^{-c}*t'成立,计算t(=gryc)t'(=g^r*y^c),利用g,y,tg,y,t'作为相同hash函数的输入,计算c=hash(g,y,t)c'=hash(g,y,t'),验证c=cc=c'是否成立即可。

2.2 Prove knowledge of two discrete logarithms satisfy a linear equation

Witness:x1,x2x_1,x_2
Instance:g1,y1,g2,y2,a1,a2,bg_1,y_1,g_2,y_2,a_1,a_2,b
Relation:y1=gx1 Λ y2=gx2 Λ a1x1+a2x2=b(mod  q)y_1=g^{x_1} \ \Lambda\ y_2=g^{x_2}\ \Lambda \ a_1x_1+a_2x_2=b(\mod q)
用knowledge specification set表示的Relation为:K=(DL(g1,y1)DL(g2,y2))LE((a1,a2),b)K=(DL(g_1,y_1)\otimes DL(g_2,y_2))\cap LE((a_1,a_2),b)

具体实现为:

  • 1)Prover:Prover生成满足a1v1+a2v2=0(mod  q)a_1v_1+a_2v_2=0(\mod q)的随机数v1v2v_1和v_2【数学描述为(v1,v2)R{(u1,u2)Zqa1u1+a2u2=0(mod  q)}(v_1,v_2)\in_R\{(u_1,u_2)\in\mathbb{Z}_q|a_1u_1+a_2u_2=0(\mod q)\}】,创建commitment t1=g1v1,t2=g2v2t_1=g_1^{v_1},t_2=g_2^{v_2};Prover将g1,y1,g2,y2,a1,a2,b,t1,t2g_1,y_1,g_2,y_2,a_1,a_2,b,t_1,t_2作为hash函数输入计算challenge c(=Hash(g1,y1,g2,y2,a1,a2,b,t1,t2))c(=Hash(g_1,y_1,g_2,y_2,a_1,a_2,b,t_1,t_2));Prover计算response r1=v1cx1(mod  q),r2=v2cx2(mod  q)r_1=v_1-c*x_1(\mod q),r_2=v_2-c*x_2(\mod q)。Prover将(c,r1,r2)(c,r_1,r_2)发送给Verifier。

Verifier根据收到的(c,r1,r2)(c,r_1,r_2),假设gr=yctg^r=y^{-c}*t'成立,计算t1(=g1r1y1c),t2(=g2r2y2c)t_1'(=g_1^{r_1}*y_1^c),t_2'(=g_2^{r_2}*y_2^c),利用g1,y1,g2,y2,a1,a2,b,t1,t2g_1,y_1,g_2,y_2,a_1,a_2,b,t_1',t_2'作为相同hash函数的输入,计算c=hash(g1,y1,g2,y2,a1,a2,b,t1,t2)(mod  q)c'=hash(g_1,y_1,g_2,y_2,a_1,a_2,b,t_1',t_2')(\mod q),验证c=cc=c'是否成立以及a1r2+a2r2=cb(mod  q)a_1r_2+a_2r_2=-cb(\mod q)是否成立即可。

2.3 OR proof

博客 基于Sigma protocol实现的零知识证明protocol集锦 中2.3节类似:
Witness:x1x_1 OR x2x_2
Instance:g1,y1,g2,y2g_1,y_1,g_2,y_2
Relation:y1=g1x1y_1=g_1^{x_1} OR y2=g2x2y_2=g_2^{x_2}

假设Prover知道x1x_1(<1>),而不知道x2x_2(<2>)。
详细实现为:
1)Prover:

  • 生成用于证明<1>随机数v1v_1,构建第1个commitment t1=g1v1t_1=g_1^{v_1}
  • 生成用于证明<2>的challenge c2c_2和随机response r2r_2,(由于Prover由于不知道bb,只能随机生成,采用 博客 基于Sigma protocol实现的零知识证明protocol集锦 1.2.2节中的方式来伪造证明)计算t2=y2c2gr2t_2=y_2^{c_2}*g^{r_2}
  • 计算hash值c=Hash(g1,y1,g2,y2,t1,t2)c=Hash(g_1,y_1,g_2,y_2,t_1,t_2),计算用于证明<1>的challenge c1=cc2c_1=c-c_2
  • 计算用于证明<1>的response r1=v1c1x1r_1=v_1-c_1*x_1
  • 发送((c1,r1),(c2,r2))((c_1,r_1),(c_2,r_2)) 给Verifier。

2)Verifier:
根据收到的proof ((c1,r1),(c2,r2))((c_1,r_1),(c_2,r_2)),计算t1=g1r1y1c1,t2=g2r2y2c2t_1'=g_1^{r_1}y_1^{c_1},t_2'=g_2^{r_2}y_2^{c_2},同时验证c1+c2=H(g1,y1,g2,y2,t1,t2)(mod  q)c_1+c_2=H(g_1,y_1,g_2,y_2,t_1',t_2')(\mod q)是否成立即可。

The reason why this works is that the prover is “allowed to forge” one of the two proofs since he can choose the corresponding challenge before the commitment is computed; the other challenge is then determined by the hash function. The verifier, however, cannot decide which challenge was chosen and therefore obtains no information about which discrete loarithms the prover knows.

3 prove knowledge of an element of an arbitrary knowledge specification set

即构建an element of an aribitrary knowledge specification set。 OR证明的generalization。

3.1 Transformation and Tree-Representation:

Proof Systems for General Statements about Discrete Logarithms 学习笔记
Proof Systems for General Statements about Discrete Logarithms 学习笔记
Proof Systems for General Statements about Discrete Logarithms 学习笔记
Proof Systems for General Statements about Discrete Logarithms 学习笔记

3.2 Constructing a proof for FF

FF为knowledge specification,可表示为F~=i=1mF~i\tilde{F}=\bigcup_{i=1}^{m}\tilde{F}_i,其中F~i\tilde{F}_i中没有任何形式的\cup操作。
假设Prover知道an element KFK \in F,则意味着存在an index αF~α\alpha\in\tilde{F}_{\alpha}KK为a tuple of elements of Zq\mathbb{Z}_q

证明方式如下:
1)Commitment:
(a)设置wˉα=0\bar{w}_{\alpha}=0,对于iαi\neq \alpha,则选择随机数wˉiRZq\bar{w}_i\in_R\mathbb{Z}_q。构建Wˉ=(wˉ1,,wˉm)\bar{W}=(\bar{w}_1,\cdots,\bar{w}_m)。【wˉi\bar{w}_{i}是对整个tree F~i\tilde{F}_i全局的,当wˉi0\bar{w}_i\neq 0意味着是提前预测了challenge伪造了证明,仅对wˉi=0\bar{w}_i=0的tree是知道witness的正确证明。
(b)选择满足EW=WˉE|_{W=\bar{W}}的random tuple Vˉ=(vˉ1.0,1,,vˉm.0,.)\bar{V}=(\bar{v}_{1.0\cdots,1,\cdots},\bar{v}_{m.0\cdots,.})
(c)为forest F~\tilde{F}的每一个node nn配置commitment TnT_n

  • nn为a leaf of type DL(g,y)DL(g,y) in the tree F~i\tilde{F}_i,则:
    Tn=(ywˉigvˉn)T_n=(y^{\bar{w}_i}g^{\bar{v}_n})
  • nn为 a leaf ot type REP((g1,,gk),y)REP((g_1,\cdots,g_k),y) in the tree F~i\tilde{F}_i,则:
    Tn=(ywˉij=1kgjvˉn,j)T_n=(y^{\bar{w}_i}\prod_{j=1}^{k}g_j^{\bar{v}_{n,j}})
  • nn为a leaf of type LE((a1,,ak),b)LE((a_1,\cdots,a_k),b),则:
    TnT_n为empty tuple ()()
  • nn\otimes\cap的inner node,则:
    Tn=Tn0Tn1T_n=T_{n||0}\circ T_{n||1}

所有的Commitment TT表示为:
T=T1.0Tm.0T=T_{1.0}\circ\cdots\circ T_{m.0}

2)Challenge:
The challenge C=(c1,,cm)C=(c_1,\cdots,c_m),计算规则为:
ci={H(F~,T)j=1mwˉj(mod  q)for i=αwˉiotherwisec_i=\left\{\begin{matrix} H(\tilde{F},T)-\sum_{j=1}^{m}\bar{w}_j(\mod q)& \text{for }i=\alpha\\ \bar{w}_i & \text{otherwise} \end{matrix}\right.

3)Response:
Given KF~αK\in\tilde{F}_{\alpha},the prover can construct a tuple XX满足以下条件:(the components of XX are labeled in the same way as the components of VV

  • xn,j=0x_{n,j}=0 for all indices jj if the leaf nn is notnotin the tree F~α\tilde{F}_{\alpha}
  • nn为a leaf of the type DLDL或者REPREP in FαF_{\alpha},则 sub-tuple (xn,1,,xn,k)(x_{n,1},\cdots,x_{n,k})为 an element of the set defined by the type of the leaf。
  • Xα.0X_{\alpha.0}应使Eα.0wα=1E_{\alpha.0}|_{w_{\alpha}=-1}成立,其中Xα.0X_{\alpha.0}是对应sub-tuple Vα.0V_{\alpha.0}的sub-tuple。

所有的response R=(r1.0,1,,rm.0,.)R=(r_{1.0\cdots,1,\cdots},r_{m.0\cdots,.})定义为:
rn,j=vˉn,jcαxn,j(mod  q)r_{n,j}=\bar{v}_{n,j}-c_{\alpha}x_{n,j}(\mod q)
for all leaves nn and all indices jj

The proof of knowledge 为pair (C,R)(\vec{C},\vec{R})

3.3 Verifying a proof

The verification of a proof (C,R)(\vec{C},\vec{R}) 主要分两步:
1)重构commitment:

  • nn为a leaf of type DL(g,y)DL(g,y) in the tree F~i\tilde{F}_i,则:
    Tn=(ycigrn)T_n'=(y^{c_i}g^{r_n})
  • nn为a leaf ot type REP((g1,,gk),y)REP((g_1,\cdots,g_k),y) in the tree F~i\tilde{F}_i,则:
    Tn=(ycij=1kgjrn,j)T_n'=(y^{c_i}\prod_{j=1}^{k}g_j^{r_{n,j}})
  • nn为a leaf of type LE((a1,,ak),b)LE((a_1,\cdots,a_k),b),则:
    TnT_n'为empty tuple ()()
  • nn\otimes\cap的inner node,则:
    Tn=Tn0Tn1T_n'=T_{n||0}'\circ T_{n||1}'

2)Verifying the challenge and the response by:

  • 验证H(F~,T)=i=1mci(mod  q)H(\tilde{F},T')=\sum_{i=1}^{m}c_i(\mod q)成立。
  • 验证R\vec{R}使得EW=CE|_{W=C}成立。

3.4 举例

Witness:x1,x2,x3x_1,x_2,x_3
Instance:h,z,g1,g2,y,a1,a2,a3,bh,z,g_1,g_2,y,a_1,a_2,a_3,b
Relation:(z=hx1,y=g1x2g2x3)(z=h^{x_1},y=g_1^{x_2}g_2^{x_3}) 使得b=a1x1+a2x2+a3x3(mod  q)b=a_1x_1+a_2x_2+a_3x_3(\mod q)成立 或 使得 b=a1x2+a2x3+a3x1(mod  q)b=a_1x_2+a_2x_3+a_3x_1(\mod q)成立。
用knowledge specification set表示的Relation为:F=((DL(h,z)REP((g1,g2),y))(REP((g1,g2),y)DL(h,z)))LE((a1,a2,a3),b)F=((DL(h,z)\otimes REP((g_1,g_2),y))\cup(REP((g_1,g_2),y)\otimes DL(h,z)))\cap LE((a_1,a_2,a_3),b)

进一步表示为:F~=((DL(h,z)REP((g1,g2),y))LE((a1,a2,a3),b)(REP((g1,g2),y)DL(h,z))LE((a1,a2,a3),b)=F~1F~2\tilde{F}=((DL(h,z)\otimes REP((g_1,g_2),y))\cap LE((a_1,a_2,a_3),b)\cup(REP((g_1,g_2),y)\otimes DL(h,z))\cap LE((a_1,a_2,a_3),b)=\tilde{F}_1\cup\tilde{F}_2
可以具体表示为如下图示:
Proof Systems for General Statements about Discrete Logarithms 学习笔记

接下来,Prover需要构建the lists of variables VnV_n 和 the set of equations EnE_n for each node。
对tree F~1\tilde{F}_1有:

  • node 1.0001.000V1.000=(v1.000,1)V_{1.000}=(v_{1.000,1})
    E1.000=E_{1.000}=\emptyset
  • node 1.0011.001V1.001=(v1.001,1,v1.001,2)V_{1.001}=(v_{1.001,1},v_{1.001,2})
    E1.001=E_{1.001}=\emptyset
  • node 1.001.00V1.00=V1.000V1.001=(v1.000,1,v1.001,1,v1.001,2)V_{1.00}=V_{1.000}\circ V_{1.001}=(v_{1.000,1},v_{1.001,1},v_{1.001,2})
    E1.00=E1.000E1.001=E_{1.00}=E_{1.000}\cup E_{1.001}=\emptyset
  • node 1.011.01V1.01=(v1.01,1,v1.01,2,v1.01,3)V_{1.01}=(v_{1.01,1},v_{1.01,2},v_{1.01,3})
    E1.01={a1v1.01,1+a2v1.01,2+a3v1.01,3=w1b}E_{1.01}=\{a_1v_{1.01,1}+a_2v_{1.01,2}+a_3v_{1.01,3}=-w_1b\}
  • node 1.01.0V1.0=(v1.000,1,v1.001,1,v1.001,2,v1.01,1,v1.01,2,v1.01,3)V_{1.0}=(v_{1.000,1},v_{1.001,1},v_{1.001,2},v_{1.01,1},v_{1.01,2},v_{1.01,3})
    E1.0={v1.01,1=v1.000,1,v1.01,2=v1.001,1,v1.01,3=v1.001,2,a1v1.01,1+a2v1.01,2+a3v1.01,3=w1b}E_{1.0}=\{v_{1.01,1}=v_{1.000,1},v_{1.01,2}=v_{1.001,1},v_{1.01,3}=v_{1.001,2},a_1v_{1.01,1}+a_2v_{1.01,2}+a_3v_{1.01,3}=-w_1b\}

对tree F~2\tilde{F}_2有:

  • node 2.0002.000V2.000=(v2.000,1,v2.000,2)V_{2.000}=(v_{2.000,1},v_{2.000,2})
    E2.000=E_{2.000}=\emptyset
  • node 2.0012.001V2.001=(v2.001,1)V_{2.001}=(v_{2.001,1})
    E2.001=E_{2.001}=\emptyset
  • node 2.002.00V2.00=V2.000V2.001=(v2.000,1,v2.000,2,v2.001,1)V_{2.00}=V_{2.000}\circ V_{2.001}=(v_{2.000,1},v_{2.000,2},v_{2.001,1})
    E2.00=E2.000E2.001=E_{2.00}=E_{2.000}\cup E_{2.001}=\emptyset
  • node 2.012.01V2.01=(v2.01,1,v2.01,2,v2.01,3)V_{2.01}=(v_{2.01,1},v_{2.01,2},v_{2.01,3})
    E2.01={a1v2.01,1+a2v2.01,2+a3v2.01,3=w2b}E_{2.01}=\{a_1v_{2.01,1}+a_2v_{2.01,2}+a_3v_{2.01,3}=-w_2b\}
  • node 2.02.0V2.0=(v2.000,1,v2.000,2,v2.001,1,v2.01,1,v2.01,2,v2.01,3)V_{2.0}=(v_{2.000,1},v_{2.000,2},v_{2.001,1},v_{2.01,1},v_{2.01,2},v_{2.01,3})
    E2.0={v2.01,1=v2.000,1,v2.01,2=v2.000,2,v2.01,3=v2.001,1,a1v2.01,1+a2v2.01,2+a3v2.01,3=w2b}E_{2.0}=\{v_{2.01,1}=v_{2.000,1},v_{2.01,2}=v_{2.000,2},v_{2.01,3}=v_{2.001,1},a_1v_{2.01,1}+a_2v_{2.01,2}+a_3v_{2.01,3}=-w_2b\}

最后:
E1.0E_{1.0}E2.0E_{2.0}进行merge后,得到:
E={v1.01,1=v1.000,1,v1.01,2=v1.001,1,v1.01,3=v1.001,2,a1v1.01,1+a2v1.01,2+a3v1.01,3=w1b,v2.01,1=v2.000,1,v2.01,2=v2.000,2,v2.01,3=v2.001,1,a1v2.01,1+a2v2.01,2+a3v2.01,3=w2b}E=\{v_{1.01,1}=v_{1.000,1},v_{1.01,2}=v_{1.001,1},v_{1.01,3}=v_{1.001,2},a_1v_{1.01,1}+a_2v_{1.01,2}+a_3v_{1.01,3}=-w_1b,v_{2.01,1}=v_{2.000,1},v_{2.01,2}=v_{2.000,2},v_{2.01,3}=v_{2.001,1},a_1v_{2.01,1}+a_2v_{2.01,2}+a_3v_{2.01,3}=-w_2b\}
V=V1.0V2.0=(v1.000,1,v1.001,1,v1.001,2,v1.01,1,v1.01,2,v1.01,3,v2.000,1,v2.000,2,v2.001,1,v2.01,1,v2.01,2,v2.01,3)=(vˉ1,vˉ2,vˉ3,vˉ1,vˉ2,vˉ3,vˉ4,vˉ5,vˉ6,vˉ4,vˉ5,vˉ6)V=V_{1.0}\circ V_{2.0}=(v_{1.000,1},v_{1.001,1},v_{1.001,2},v_{1.01,1},v_{1.01,2},v_{1.01,3},v_{2.000,1},v_{2.000,2},v_{2.001,1},v_{2.01,1},v_{2.01,2},v_{2.01,3})=(\bar{v}_1,\bar{v}_2,\bar{v}_3,\bar{v}_1,\bar{v}_2,\bar{v}_3,\bar{v}_4,\bar{v}_5,\bar{v}_6,\bar{v}_4,\bar{v}_5,\bar{v}_6)
W=(w1,w2)W=(w_1,w_2)

1)Prover构建proof的方式可为:

  • 随机选择Wˉ=(wˉ1,wˉ2)=(0,w)wRZq\bar{W}=(\bar{w}_1,\bar{w}_2)=(0,w),其中w\in_R\mathbb{Z}_q;【即此时选择α=1\alpha=1
  • 随机选择a random tuple VˉRZq12\bar{V}\in_R\mathbb{Z}_q^{12}使得满足EW=WˉE|_{W=\bar{W}}成立即可。即随机选择vˉ1,,vˉ6Zq\bar{v}_1,\cdots,\bar{v}_6\in \mathbb{Z}_q,使得a1vˉ1+a2vˉ2+a3vˉ3=0(mod  q)a_1\bar{v}_1+a_2\bar{v}_2+a_3\bar{v}_3=0(\mod q)a1vˉ4+a2vˉ5+a3vˉ6=wb(mod  q)a_1\bar{v}_4+a_2\bar{v}_5+a_3\bar{v}_6=-wb(\mod q)均成立。设置V=(vˉ1,vˉ2,vˉ3,vˉ1,vˉ2,vˉ3,vˉ4,vˉ5,vˉ6,vˉ4,vˉ5,vˉ6)V=(\bar{v}_1,\bar{v}_2,\bar{v}_3,\bar{v}_1,\bar{v}_2,\bar{v}_3,\bar{v}_4,\bar{v}_5,\bar{v}_6,\bar{v}_4,\bar{v}_5,\bar{v}_6)
  • 构建commitment:T=T1.0T2.0=(hvˉ1,g1vˉ2g2vˉ3,zwhvˉ4,ywg1vˉ5g2vˉ6)T=T_{1.0}\circ T_{2.0}=(h^{\bar{v}_1},g_1^{\bar{v}_2}g_2^{\bar{v}_3},z^wh^{\bar{v}_4},y^wg_1^{\bar{v}_5}g_2^{\bar{v}_6})
    Proof Systems for General Statements about Discrete Logarithms 学习笔记
  • 计算challenge:C=(c1,c2)=(H(F~,T)w(mod  q),w)C=(c_1,c_2)=(H(\tilde{F},T)-w(\mod q),w)
  • 计算response:构建list X=(x1,x2,x3,x1,x2,x3,0,0,0,0,0,0)X=(x_1,x_2,x_3,x_1,x_2,x_3,0,0,0,0,0,0)【针对此处α=1\alpha=1】,计算response RR中的ri,j,lr_{i,j,l}(所有方程式都是modulo qq):
    Proof Systems for General Statements about Discrete Logarithms 学习笔记

在整个proof内容即为(C,R)(C,R)

2)Verifier验证proof (C,R)(C,R) 的过程为:

  • 重构commitment:T=T1.0T2.0T'=T_{1.0}'\circ T_{2.0}'
    Proof Systems for General Statements about Discrete Logarithms 学习笔记
  • check challenge和equations of EW=CE|_{W=C}(均为modulo qq运算):
    Proof Systems for General Statements about Discrete Logarithms 学习笔记

注意以上算法未做优化。
Proof Systems for General Statements about Discrete Logarithms 学习笔记

参考资料:
[1] Monotone Boolean function
[2] 博客 基于Sigma protocol实现的零知识证明protocol集锦