PLONK + PLOOKUP

1. 引言

在区块链网络中,交易经年不断积累,因此区块链的存储量不断无限增长。在Dusk Network中,自举时间线性增长,且受零知识证明验证计算量的限制。在适当的时候,这意味着自举可能需要几天甚至几周的时间。

这就是为什么我们正在研究一个全新的自举过程,使加入网络的新节点能够快速与最新状态同步。使用此过程,新节点不需要验证单个交易,这将导致自举时间为分钟/小时,而不是天/周。

为此,Dusk Network中设计了一个过程,使client能将相应交易证明的计算委托给某server,而不暴露相应的secret key。整个委托过程,使得我们能拥有超轻的类似Metamask的钱包,同时能使用协议所提供的所有功能。在具体实现过程中,将设定多个常量,如:

  • length of the epoch
  • length of the bid/stake lock-up time

Dusk-network团队在PLOOKUP的实现上取得了重大进展,可将现有的gadgets与PLOOKUP集成,减少gadgets中门的数量。同时,Dusk-network团队也将致力于实现新的gadgets,这种新的gadgets必须依赖于PLOOKUP。

PLOOKUP的主要价值在于:

  • 可加速现有circuit的proving time;
  • 为线下的附加创新特性提供了基础,如recursive proof verification。

PLONK+PLOOKUP用于circuit证明,底层关键技术点涉及有:

  • 1)PLONK的核心技术为:grand product check

  • 2)PLOOKUP的核心技术为:multiset-equality check

  • 3)circuit证明中常用到:permutation check

  • 4)PLOOKUP中引入了:Table lookup

接下来将介绍这些底层关键技术之间的关系。

2. Grand product check VS Multiset-equality check

PLONK的核心技术为:

  • grand product check

所谓grand product check,是指:

  • public info:commitments to polynomials f , g f,g f,g over a finite field F \mathbb{F} F,及 a subset H = { x 1 , ⋯   , x n } ⊂ F H=\{x_1,\cdots,x_n\}\subset \mathbb{F} H={x1,,xn}F
  • private info:多项式 f , g f,g f,g
  • 待证明relation: ∏ i ∈ [ n ] a i = ∏ i ∈ [ n ] b i \prod_{i\in[n]}a_i=\prod_{i\in[n]}b_i i[n]ai=i[n]bi,其中 a i = f ( x i ) , b i = g ( x i ) a_i=f(x_i),b_i=g(x_i) ai=f(xi),bi=g(xi)

在PLONK论文中指出,当 H H H为a multiplicative subgroup时,可高效实现相应证明。

此文讨论的长为 n n n的vector a ⃗ \vec{a} a ,在协议的实际实现中,均为Prover会对多项式 f f f进行commit,其中 f ( x i ) = a i f(x_i)=a_i f(xi)=ai

PLOOKUP的核心技术为:

  • multiset-equality check

借助少量的randomness,可将grand product check 转换为更强大的primitive——the multiset equality check:

  • 已知两个vector a ⃗ = ( a 1 , ⋯   , a n ) , b ⃗ = ( b 1 , ⋯   , b n ) \vec{a}=(a_1,\cdots,a_n),\vec{b}=(b_1,\cdots,b_n) a =(a1,,an),b =(b1,,bn),check两者是否具有相同的元素,计算相应的重复值,顺序可以不对应。

( 1 , 1 , 2 , 3 ) (1,1,2,3) (1,1,2,3) ( 2 , 1 , 1 , 3 ) (2,1,1,3) (2,1,1,3) 是multiset-equal的,但是与 ( 1 , 2 , 3 , 3 ) (1,2,3,3) (1,2,3,3) ( 1 , 1 , 2 , 4 ) (1,1,2,4) (1,1,2,4)都不是 multiset-equal的。

2.1 由 multiset-equality check 到 grand product check

Verifier发送随机值 γ ∈ F \gamma\in\mathbb{F} γF,然后run the grand product check on the randomly shifted vectors a ⃗ ′ = a ⃗ + γ , b ⃗ ′ = b ⃗ + γ \vec{a}'=\vec{a}+\gamma,\vec{b}'=\vec{b}+\gamma a =a +γ,b =b +γ(即对所有元素都加 γ \gamma γ。)

这样,就可将multiset-equality check转换为 如下grand product check:
∏ i ∈ [ n ] ( a i + γ ) = ∏ i ∈ [ n ] ( b i + γ ) \prod_{i\in[n]}(a_i+\gamma)=\prod_{i\in[n]}(b_i+\gamma) i[n](ai+γ)=i[n](bi+γ)

3. Permutation check VS Multiset check

Permutation是指:

  • public info:permutation σ : [ n ] → [ n ] \sigma:[n]\rightarrow [n] σ:[n][n]
  • private info: a ⃗ , b ⃗ \vec{a},\vec{b} a ,b
  • 待证明relation: b ⃗ = σ ( a ⃗ ) \vec{b}=\sigma(\vec{a}) b =σ(a ),即对于每一个 i i i,有 b i = a σ ( i ) b_i=a_{\sigma(i)} bi=aσ(i)

关于为何permutation checks为SNARKs的核心组成,查看PLONK及其它SNARK论文便可知。

3.1 由 permutation check 到 multiset check

观察以下vectors of pairis:
( ( a i , i ) ) i ∈ [ n ] ((a_i,i))_{i\in[n]} ((ai,i))i[n] ( b i , σ ( i ) ) i ∈ [ n ] (b_i, \sigma(i))_{i\in[n]} (bi,σ(i))i[n]

当且仅当 b ⃗ = σ ( a ⃗ ) \vec{b}=\sigma(\vec{a}) b =σ(a )时,以上两者为multiset-equal的。

但是,我们希望可reduce为multiset check on vectors of elements,而不是vectors of pairs。为此,引入随机值 β \beta β,定义新的vector a ⃗ ′ , b ⃗ ′ \vec{a}',\vec{b}' a ,b 为:
a i ′ = a i + β ⋅ i , b i ′ = b i + β ⋅ σ ( i ) a_i'=a_i+\beta\cdot i,b_i'=b_i+\beta\cdot \sigma(i) ai=ai+βi,bi=bi+βσ(i)

若以上vectors of pairs为 not multiset equal的,则大概率 a ⃗ ′ \vec{a}' a b ⃗ ′ \vec{b}' b 也不是multiset equal的。
因此,仅需对 a ⃗ ′ \vec{a}' a b ⃗ ′ \vec{b}' b 做multiset check就足够了。

3.2 由 permutation check 到 grand product check

在Stephanie Bayer和Jens Groth 2012年论文《Efficient Zero-Knowledge Argument for Correctness of a Shuffle》中,首次实现了 由permutation check 到 grand product check 的reduction,详细可参看系列博客:

  • Efficient Zero-Knowledge Argument for Correctness of a Shuffle学习笔记(1)
  • Efficient Zero-Knowledge Argument for Correctness of a Shuffle学习笔记(2)
  • Efficient Zero-Knowledge Argument for Correctness of a Shuffle学习笔记(3)

4. Table lookup VS Multiset check

table lookup 操作是 zk-SNARK实现中的一个非常有用的操作。

以XOR举例,假设有3个vectors of field elements a ⃗ = ( a 1 , ⋯   , a n ) , b ⃗ = ( b 1 , ⋯   , b n ) , c ⃗ = ( c 1 , ⋯   , c n ) \vec{a}=(a_1,\cdots,a_n),\vec{b}=(b_1,\cdots,b_n),\vec{c}=(c_1,\cdots,c_n) a =(a1,,an),b =(b1,,bn),c =(c1,,cn),想要check:
对于每一个 i ∈ [ n ] i\in[n] i[n] a i , b i , c i a_i,b_i,c_i ai,bi,ci均为8-bit string,且 c i = a i ⊕ b i c_i=a_i\oplus b_i ci=aibi,其中 ⊕ \oplus 为bitwise XOR。

传统的SNARK方案需要很多arithmetic constraints:
需要对于每一组tuple ( a i , b i , c i ) (a_i,b_i,c_i) (ai,bi,ci)分解为二进制位表示,然后再进行bitwise XOR。

而借助Lookup table,相应的解决方案变为:

  • 1)预计算XOR操作对应的truth table T T T T T T的长度为: 2 8 ∗ 2 8 = 2 16 2^8*2^8=2^{16} 2828=216,包含了3个向量 ( T 1 , T 2 , T 3 ) (T_1,T_2,T_3) (T1,T2,T3)之间的关系。【可将 T T T看成是矩阵,其每行元素为tuple ( T 1 , T 2 , T 3 ) (T_1,T_2,T_3) (T1,T2,T3),共有 2 16 2^{16} 216行,且其中 ( T 1 , i , T 2 , i , T 3 , i ) (T_{1,i},T_{2,i},T_{3,i}) (T1,i,T2,i,T3,i) 遍历所有可能的输入/输出组合。】相应的结构体设计可为:
/// Construct a Generic lookup table over a bi-variate function
pub struct Generic(HashMap<(Fr, Fr), Fr>); //以两个输入组合为Key,以输出结果为value

【注意,在SNARK上下文中, a ⃗ , b ⃗ , c ⃗ \vec{a},\vec{b},\vec{c} a ,b ,c 通常对应的是witness polynomials for which only for some i i i's we wish to check a XOR relation。
具体实现可参见PLOOKUP论文section 4.1节的方法:
借助“selectors” 来combine different tables and gates。【借助selectors j j j,实际实现的就是按不同的门类型(不同的逻辑操作)统一归类。】
详细也可参看博客 PLOOKUP 中 “6. 扩展为多个多项式 f 1 , ⋯   , f w ∈ F < n [ X ] f_1,\cdots,f_w\in\mathbb{F}_{f1,,fwF<n[X]同一位置元素 对应 特定 lookup tables 关系证明”。
其中的 j j j即为相应的selectors。

注意,在plookup论文中,selector j j j 被定义为public的,但是在实际做circuit证明时,selector j j j 应为private的。实际实现的规则,可参看ultra-plonk论文。(源自 Plonk cafe的 Strategies for integrating plookup with PLONK 中的讨论。)

  • 2)Reduce tuples to single elements
    为了证明每一个tuple ( a i , b i , c i ) (a_i,b_i,c_i) (ai,bi,ci) 对应为 T T T中的某一行:
    借助randomness来reduce checking tuples to checking single elements。引入random α \alpha α,构建vector f i = a i + α ⋅ b i + α 2 ⋅ c i f_i=a_i+\alpha\cdot b_i+\alpha^2 \cdot c_i fi=ai+αbi+α2ci for each i ∈ [ n ] i\in[n] i[n]。类似的,也为truth table T T T构建相应的压缩版本 t t t,其中 t i = T 1 , i + α ⋅ T 2 , i + α 2 ⋅ T 3 , i t_i=T_{1,i}+\alpha\cdot T_{2,i}+\alpha^2\cdot T_{3,i} ti=T1,i+αT2,i+α2T3,i
    根据Schwartz-Zippel Lemma可知,若某tuple ( a i , b i , c i ) (a_i,b_i,c_i) (ai,bi,ci)不在 T T T中,则大概率 f i f_i fi不是 t t t中的元素。

  • 3)plookup protocol中的sort and compare differences【reduce为2个multiset check】
    至此,问题转换为了:
    check that every element of f f f is an element of t t t
    将其表示为 f ⊂ t f\subset t ft
    在plookup protocol中,可将其reduce为 one multiset equality check,reduce的核心思想在于:
    若有2个vector的sorted version,且两者的第一个元素是一样的,则有:they contain the same distinct elements if and only if they contain the same sequence of non-zero differences between adjacent elements。
    举个例子:有 f = ( 2 , 2 , 1 , 1 , 5 ) , t = ( 1 , 2 , 5 ) f=(2,2,1,1,5),t=(1,2,5) f=(2,2,1,1,5),t=(1,2,5),Prover构建 s = ( f , t ) s=(f,t) s=(f,t) sorted by t t t,此处有 s = ( 1 , 1 , 1 , 2 , 2 , 2 , 5 , 5 ) s=(1,1,1,2,2,2,5,5) s=(1,1,1,2,2,2,5,5)。【注意,sorted by t t t操作可保证 elements in s s s in the same order they appear in t t t。】
    s , t s,t s,t对应的difference vector为: s ′ = ( 0 , 0 , 1 , 0 , 0 , 3 , 0 ) , t ′ = ( 1 , 3 ) s'=(0,0,1,0,0,3,0),t'=(1,3) s=(0,0,1,0,0,3,0),t=(1,3)
    由此可知,若 f ⊂ t f\subset t ft,则 s ′ s' s中的非零元素与 t ′ t' t中的非零元素一一对应。
    t ′ t' t后面附加 ∣ f ∣ |f| f个零,表示为 t ′ ′ = ( 1 , 3 , 0 , 0 , 0 , 0 , 0 ) t''=(1,3,0,0,0,0,0) t=(1,3,0,0,0,0,0)
    此时可简单reduce为2个multiset check:
    <1> s s s ( f , t ) (f,t) (f,t)之间的multiset check;【可说明 f ⊂ s f\subset s fs,以及 t ⊂ s t\subset s ts。】
    <2> s ′ s' s t ′ ′ t'' t之间的multiset check。
    条件<1>可说明 t ⊂ s t\subset s ts,若 s s s中包含a value outside of t t t,则意味着 s s s中有more than ∣ t ∣ |t| t distinct values。但是,条件<2>可说明 s ′ s' s有 at most ∣ t ∣ − 1 |t|-1 t1 non-zeros。因此,若条件<1>和条件<2>都满足,可说明 s s s有 at most ∣ t ∣ |t| t distinct values,从而可说明 s ⊂ t s\subset t st。由 f ⊂ s , s ⊂ t f\subset s,s\subset t fs,st,从而有 f ⊂ t f\subset t ft

  • 4)借助randomness,实现效率更高的版本【reduce为仅需1个multiset check】
    Verifier选择random β \beta β
    s , t s,t s,t对应的randomized difference vectors s ′ , t ′ s',t' s,t为: s i ′ = s i + β s i + 1 , t i ′ = t i + β t i + 1 s_i'=s_i+\beta s_{i+1},t_i'=t_i+\beta t_{i+1} si=si+βsi+1,ti=ti+βti+1
    此时可reduce为一个multiset check:即 s ′ s' s ( ( 1 + β ) f , t ′ ) ((1+\beta)f,t') ((1+β)f,t)之间的multiset check。
    为了更便于理解,可将每个元素看成是formal polynomial in β \beta β,而不是field elements。从而可知, s ′ s' s中的元素为degree one polynomial s i + s i + 1 ⋅ β s_i+s_{i+1}\cdot \beta si+si+1β
    a) 若 s i ≠ s i + 1 s_i\neq s_{i+1} si=si+1,则说明 s i + s i + 1 ⋅ β s_i+s_{i+1}\cdot \beta si+si+1β应在 t ′ t' t中,与某 t j + t j + 1 ⋅ β t_j+t_{j+1}\cdot \beta tj+tj+1β相同。从而说明 s ⊂ t s\subset t st
    b) 每一个 f i + f i ⋅ β f_i+f_i\cdot \beta fi+fiβ 必须与 s ′ s' s中的某值相同,即对应某 s j = s j + 1 s_{j}=s_{j+1} sj=sj+1。从而说明 f ⊂ s f\subset s fs
    根据a) 和 b) ,从而证明了 f ⊂ t f\subset t ft
    根据Schwartz-Zippel Lemma可知,这些comparisons between formal polynomials in β \beta β with high probability will not differ from the comparisons from the comparisons of the actual elements for the random choice of β \beta β

5. Plonk和Plookup异同点

Plonk和Plookup的共性是,均为:

  • argument that two sequences are related by a permutation

但是,Plonk和Plookup使用sequence的方式不同:

  • Plonk使用长为 n n n的sequence来表示最多有 n n n个门和相应的input/output wires。
  • Plookup使用长为 n + d n+d n+d的sequence来表示 d d d queries to a lookup table with n n n rows。

Plonk和Plookup中均使用了:

  • a (different) sequence of length n n n as part of their grand product argument.

Plonk为:

  • a SNARK (Succinct Non-interactive Argument of Knowledge)。
  • 可验证computation done by an arithmetic circuit。
  • 针对circuit C C C,witness x x x,构建Plonk proof证明 C ( x ) = y C(x)=y C(x)=y

Plookup为:

  • a SNARK component。
  • 通过构建特定函数的lookup table,可实现某些类型circuit的高效构建,从而降低circuit的复杂度,使得该SNARK的复杂度仅取决于the size of the function’s domain。

5.1 Hash proof + Plookup

Hash函数是可利用plookup来实现circuit简化的一个很棒的例子:

  • 可简化电路;
  • 可缩短Prover time;
  • 可缩短Verifier time;
  • 可减少proof size。

在computer架构下,大多数被认为安全的Hash函数运算都是快速的;其中的某些在软件实现上也运算很快。但是无论哪种情况,这些Hash函数都是基于binary strings来执行的。当encode为约256-bit的field elements时,存在以下问题:

  • encode效率低下(需用很大的field element数值来表示很小的string值)。
  • 需要使用大量的门来表示(以XOR为例,本可以加法和乘法mod p就能表示,当若以arithmetic circuit形式来表示时将非常复杂)

5.2 recursive SNARK without cycles + Plookup

借助Plookup,即使曲线不具备cycles属性,也将支持arithmetic over different fields运算,从而实现recursive SNARK。

SNARK中所使用到的大多数曲线,都是定义在域 Z p \mathbb{Z}_p Zp中的,其中每个point可表示为:
P = ( x , y ) P=(x,y) P=(x,y),其中 x , y ∈ Z p x,y\in\mathbb{Z}_p x,yZp

point P P P具有的order为 q q q,即将相应的scalar field表示为 Z q \mathbb{Z}_q Zq

在构建arithmetic circuit SNARK时,加法门和乘法门都是基于scalar field Z q \mathbb{Z}_q Zq来运算的,即 m o d    q \mod q modq。其中 p , q p,q p,q为不同的素数。

因此,使用不具有cycles属性的曲线来构建recursive SNARK的难点在于:

  • 仅根据addition and multiplication m o d    q \mod q modq来表达相应的addition and multiplication m o d    p \mod p modp。【如,仅根据addition and multiplication m o d    7 \mod 7 mod7,无法定义addition m o d    5 \mod 5 mod5。】

参考资料

[1] Plonk cafe的 Strategies for integrating plookup with PLONK
[2] Dmitry Khovratovich的hackmd笔记 Plonk and PLookup
[3] metastate的 On PLONK and plookup
[4] dusk network的 Audit Plookup Branch #358
[5] tezosagora的 On PLONK and plookup SNARKs
[6] aztec的研究论文系列
[7] Dusk的开发月报
[8] hackmd的 Multiset checks in PLONK and Plookup

你可能感兴趣的:(零知识证明,区块链)