Skip to content

第 7 课 补充讲义

算术化是将计算编码为代数约束满足问题的过程。这将检验其正确性的复杂性降低到少量概率代数检查。在证明系统中,算术化的选择会影响IOP的选择范围(见图1)。

图1:证明系统的组成部分。请回顾第5讲(承诺方案)中,承诺方案可用于将交互式预言机证明(IOP)编译成证明系统。

英文原文

Arithmetisation is the encoding of a computation as an algebraic constraint satisfaction problem. This reduces the complexity of verifying its correctness to a few probabilistic algebraic checks. In a proof system, the choice of arithmetisation limits the corresponding range of IOPs that can be used to check it (see Figure 1).

Figure 1: The components of a proof system. Recall from Lecture 3 (Commitment Schemes) that a commitment scheme can be used to compile an interactive oracle proof (IOP) into a proof system.

二次算术程序 (QAPs)

二次算术程序(Quadratic Arithmetic Program,QAP) [9] 是一种将语句转换为多项式上二次方程组的方式。它们可以通过线性交互式证明(LIPs)[10],代数IOPs [6],多线性IOPs ([14],[15]) 进行检验。任何具有乘性复杂度n的电路都可以转换为一个 n次多项式的QAP。

定义1.1. 二次算术程序(QAP)

一个度数为 d 、大小为 m 的二次算术程序Q由多项式 {Lj(X)},{Rj(X)},{Oj(X)},j[0,,m1] 和一个目标多项式T(X):=(Xi)i=0d1 组成。当赋值(1,x1,,xm1)满足 Q时,

T(X)P(X),P(X):=L(X)R(X)O(X)

其中 L(X):=j=0m1xjLj(X),R(X):=j=0m1xjRj(X),O(X):=j=0m1xjOj(X)

英文原文

The Quadratic Arithmetic Program (QAP) [9] is a way to translate statements into a system of quadratic equations over polynomials. They can be checked by linear interactive proofs (LIPs) [10], algebraic IOPs [6], multilinear IOPs ([14], [15]). Any circuit with multiplicative complexity n can be translated to a QAP over degree- n polynomials.

Definition 1.1. [Quadratic Arithmetic Program (QAP)]

A Quadratic Arithmetic Program Q of degree d and size m consists of polynomials {Lj(X)},{Rj(X)},{Oj(X)},j[0,,m1], and a target polynomial T(X):=(Xi)0=1d1 of degree d. An assignment (1,x1,,xm1) satisfies Q if

T(X)P(X),P(X):=L(X)R(X)O(X)

where L(X):=j=0m1xjLj(X),R(X):=j=0m1xjRj(X),O(X):=j=0m1xjOj(X).

一阶约束系统 (R1CS)

算术电路可以用简化形式的一阶约束系统(R1CS)表示,而R1CS则可以转换为QAP。

参数系统算术化信息理论协议密码编译器
Groth16 [10]R1CS线性交互证明 (LIP)双线性配对
Marlin [6]R1CS代数全息证明 (AHP)改进的KZG承诺
Spartan [15]R1CS变体的sumcheck协议SPARK
Dory [14]R1CS多线性IOP双线性配对
Nova [13]放宽的R1CS多线性IOP多线性PCS

表1:使用R1CS算术化的证明系统的示例。

在第二讲(Circom 1)中,我们看到了IsZero电路,它检查给定值是否为零的声明。让我们将IsZero转换为一个R1CS电路,然后将其转换为QAP。

c
template IsZero(){
    signal input in;
    signal output out;

    signal inv;

    inv <−− in != 0 ? 1 / in : 0;

    out <== −in * inv + 1;
    in * out === 0;
}
template IsZero(){
    signal input in;
    signal output out;

    signal inv;

    inv <−− in != 0 ? 1 / in : 0;

    out <== −in * inv + 1;
    in * out === 0;
}

代码1:从comparators.circom中获取的IsZero电路。

circom的IsZero程序可以“展平”为四个约束条件,每个都采用 左侧 o 右侧 = output 的形式:

w1(1)=w2w2w3=w4w4+1=w5w1w5=w6

在算术电路表示中(左图),每个约束条件对应于一个加法或乘法门。

证明人声称知道一些合法的赋值 x=(x1,x2,x3,x4,x5,x6),使得当将每个值 ai 赋给对应的线路 wi,并且 w6=0 时,电路是满足的。对于每个门 gi,我们创建三个线路向量 li,ri,oi,其中包含门中每个变量 wj 的系数。线路向量还包括一个常数项 w0

g0:w1(1)=w2|w0w1w2w3w4w5w6l0=(0100000)r0=(1000000)o0=(0010000),g1:w2w3=w4|w0w1w2w3w4w5w6l1=(0010000)r1=(0001000)o1=(0000100),g2:w4+1=w5(w4+1)1=w5|w0w1w2w3w4w5w6l2=(1000100)r2=(1000000)o2=(0000010),g3:w1w5=w6|w0w1w2w3w4w5w6l3=(0100000)r3=(0000010)o3=(0000001).

现在,我们将每个左边的li线向量收集到矩阵L=(l0,l1,l2,l3)中,对于右边的ri线向量同样如此,而输出oi向量也是如此:R=(r0,r1,r2,r3)O=(o0,o1,o2,o3)

L=w0w1w2w3w4w5w6(0100000001000010001000100000)l0l1l2l3,R=w0w1w2w3w4w5w6(1000000000100010000000000010)r0r1r2r3,O=w0w1w2w3w4w5w6(0010000000010000000100000001)o0o1o2o3.

矩阵L,R,O和见证向量x=(1,x1,x2,x3,x4,x5,x6)一起构成了IsZero电路的R1CS形式。满足条件的向量x可以实现方程Lx+RxOx=0

英文原文

Arithmetic circuits can be expressed a simplified form known as Rank-1 Constraint System (R1CS), which can in turn be transformed into a QAP.

Argument systemArithmetizationInformation-theoretic protocolCryptographic compiler
Groth16 [10]R1CSlinear interactive proof (LIP)bilinear pairings
Marlin [6]R1CSalgebraic holographic proof (AHP)adapted KZG commitment
Spartan [15]R1CSvariant of sumcheck protocolSPARK
Dory [14]R1CSmultilinear IOPbilinear pairings
Nova [13]Relaxed R1CSmultilinear IOPmultilinear PCS

Table 1: Examples of proof systems which make use of R1CS arithmetisation.

In Lecture 2 (Circom 1), we saw the Is Zero circuit, which checks a claim about whether a given value is zero. Let's convert Is eero into an R1CS circuit, and then transform it into a QAP.

c
template IsZero(){
    signal input in;
    signal output out;

    signal inv;

    inv <−− in != 0 ? 1 / in : 0;

    out <== −in * inv + 1;
    in * out === 0;
}
template IsZero(){
    signal input in;
    signal output out;

    signal inv;

    inv <−− in != 0 ? 1 / in : 0;

    out <== −in * inv + 1;
    in * out === 0;
}

Listing 1: The Iszero circuit, taken from comparators. circom in circomlib.

The circom Iszero program can be "flattened" into four constraints, each of the form left o right = output:

w1(1)=w2w2w3=w4w4+1=w5w1w5=w6

In the arithmetic circuit representation (left), each of these constraints corresponds to an addition or multiplication gate.

The prover is claiming to know some legal assignment x=(x1,x2,x3,x4,x5,x6), so that when each value ai is assigned to corresponding wire wi, and w6=0, the circuit is satisfied. For each gate gi, we create three wire vectors li,ri,oi, containing the coefficients of each variable wj at the gate. The wire vectors also include a constant term w0 :

g0:w1(1)=w2|w0w1w2w3w4w5w6l0=(0100000)r0=(1000000)o0=(0010000),g1:w2w3=w4|w0w1w2w3w4w5w6l1=(0010000)r1=(0001000)o1=(0000100),g2:w4+1=w5(w4+1)1=w5|w0w1w2w3w4w5w6l2=(1000100)r2=(1000000)o2=(0000010),g3:w1w5=w6|w0w1w2w3w4w5w6l3=(0100000)r3=(0000010)o3=(0000001),

Now, we collect each of the left li wire vectors into a matrix L=(l0,l1,l2,l3), and likewise for the right R=(r0,r1,r2,r3) and output O=(o0,o1,o2,o3) vectors:

L=w0w1w2w3w4w5w6(0100000001000010001000100000)l0l1l2l3,R=w0w1w2w3w4w5w6(1000000000100010000000000010)r0r1r2r3,O=w0w1w2w3w4w5w6(0010000000010000000100000001)o0o1o2o3.

The L,R,O matrices, along with our witness vector x=(1,x1,x2,x3,x4,x5,x6), gives the