Arithmetic circuit

对于只有加法门和乘法门的arithmetic circuit,可将其理解为是“一系列的乘法门+一系列表示gate输入输出关系的linear consistency equations”。

一个 arithmetic circuit 可理解为是一个有向无环图,其中每个顶点称为gate。in-degree为0的gate为circuit的输入,可表示为 a i a_i ai或者a constant field element。其它的gate可标示为 + + + × \times ×

对于 fan-in 2 circuits,其所有 + + +门和 × \times ×门均具有 in-degree 2。

任何可表述为有向无环图的circuit均可转换为:
“一系列的乘法门+一系列表示gate输入输出关系的linear consistency equations”。

  • 首先,需要将arithmetic circuit A A A 中的加法门和常量乘法门替换为:
    bilinear consistency equations on the inputs and outputs of the remaining gates
    从而保证这些equations的satisfiability与原始circuit的satisfiability等同。
    假设 B B B A A A的sub-circuit, B B B中包含了一个乘法门之前的所有wires和gates。 B B B m m m 个input wires和 n n n 个output wires。这 m m m 个inputs可以单位向量表示 e ⃗ i = ( 0 , ⋯   , 1 , ⋯   , 0 ) \vec{e}_i=(0,\cdots,1,\cdots,0) e i=(0,,1,,0),其中 i ∈ [ 1 , m ] , ∣ e ⃗ i ∣ = m i\in[1,m],|\vec{e}_i|=m i[1,m],e i=m
    – 对于每个加法门,其input表示为 x ⃗ , y ⃗ \vec{x},\vec{y} x ,y ,其output表示为 x ⃗ + y ⃗ \vec{x}+\vec{y} x +y
    – 对于每个常量乘法门,其input表示为 x ⃗ \vec{x} x 和常量 c c c,其output表示为 c x ⃗ c\vec{x} cx
    以此执行, B B B n n n个output均可以length为 m m m的向量来表示linear combinations of the inputs。
    最多需要 m ∣ B ∣ m|B| mB 个arithmetic operations。注意, B B B的所有output均为linear combinations of the inputs,所以 B B B可表示为具有 n ( 2 m − 1 ) n(2m-1) n(2m1) 个 fan-in 2 gates,使得consistency equations可直接从circuit description中获取。
    注意,形如 ∑ i = 1 m a i x i \sum_{i=1}^{m}a_ix_i i=1maixi的linear combination,可由 m m m个常量乘法门和 m − 1 m-1 m1 个加法门组成。

  • 其次,将 B B B的gates 从 A A A 中移除,同时移除 any multiplication gates whose inputs are the inputs of the new circuit。

  • 重复以上过程,知道找出所有的consistency equations。repeat the process of finding consistency equations until we have considered the whole of A A A

注意,circuit A A A的第一个(input)和最后一个(output)sub-circuit需要增加额外操作。
以 output sub-circuit为例(input sub-circuit类似):

  • 假设 B B B为the output sub-circuit,其 m m m个input表示为 a ⃗ = ( a 1 , ⋯   , a m ) T \vec{a}=(a_1,\cdots,a_m)^T a =(a1,,am)T n n n个output表示为 b ⃗ = ( b 1 , ⋯   , b n ) T \vec{b}=(b_1,\cdots,b_n)^T b =(b1,,bn)T
    其中,每个output b i b_i bi均可表示为 ∑ j = 1 m q i j a j + p i \sum_{j=1}^{m}q_{ij}a_j+p_i j=1mqijaj+pi,所有的可表示为:
    b ⃗ = Q a ⃗ + p ⃗ \vec{b}=\mathbf{Q}\vec{a}+\vec{p} b =Qa +p
    其中 Q \mathbf{Q} Q n × m n\times m n×m矩阵, p ⃗ \vec{p} p 为size为 n n n的列向量。
    假设矩阵 Q \mathbf{Q} Q的rank为 r r r,则可将 Q \mathbf{Q} Q reduce 为 row echelon form R \mathbf{R} R,可表示为:
    b ⃗ ′ ′ = R a ⃗ \vec{b}''=\mathbf{R}\vec{a} b =Ra

附注:

  • 所谓matrix rank是指:通过行列式转换,非零行的数量。matrix的rank最大可能值为 m i n ( m , n ) min(m,n) min(m,n)
  • 所谓row echelon form matrix是指:通过行列式转换,将矩阵左下角的所有元素均表示为0的过程。
    Arithmetic circuit_第1张图片

参考资料:
[1] How to Reduce a Matrix to Row Echelon Form
[2] Bootle和Groth等人2016年论文《Efficient Zero-Knowledge Arguments for Arithmetic Circuits in the Discrete Log Setting》
[3] matrix rank

你可能感兴趣的:(基础理论)