Skip to content

第 5 课 补充讲义

现代 SNARK 由两个部分组成:信息论交互式预言机证明 (IOP) [1]; 和一个兼容的密码承诺方案,它将 IOP“编译”成一个论证系统 [5]。 本讲义介绍几种常用的承诺方案。

IOP 是“信息论的”,因为即使针对 计算无界 的证明者和验证者,它也能提供可靠性和零知识保证。 为了使这成为可能,证明系统做出了“预言机访问”的理想化假设:换句话说,验证者只能通过随机查询访问证明者的消息。

承诺方案使用密码原语(例如单向函数)实例化此预言机访问:因此,由此产生的论证系统仅对于 计算有界 的证明者和验证者而言是安全的。 为了实现 简洁 的论证系统,所选择的承诺方案必须提供相对于被证明的计算而言较低的通信复杂性。

图 1:k 轮交互式预言机证明系统。 在第i轮中:验证者V发送消息mi给证明者P; 然后,P 回复消息 fiV 可以在本轮和所有后续轮次中查询(通过随机访问)。 在 k 轮交互之后,V 要么接受要么拒绝。

英文原文

Modern SNARKs consist of two components: an information-theoretic interactive oracle proof (IOP) [1]; and a compatible cryptographic commitment scheme, which "compiles" the IOP into an argument system [5]. This note introduces several commonly used commitment schemes.

An IOP is "information-theoretic" in that it provides soundness and zero-knowledge guarantees even when the prover and verifier are computationally unbounded. To make this possible, the proof system makes the idealised assumption of "oracle access": in other words, the verifier can only access the prover's messages through random queries.

The commitment scheme instantiates this oracle access using cryptographic primitives (e.g. a one-way function): as a consequence, the resulting argument system is only secure with respect to a computationally bounded prover and/or verifier. To realise a succinct argument system, the chosen commitment scheme must provide low communication complexity relative to the computation being proven.

Figure 1: A k-round interactive oracle proof system. In the i-th round: the verifier V sends a message mi to the prover P; then, P replies with a message fi, which V can query (via random access) in this and all later rounds. After the k rounds of interaction, V either accepts or rejects.

正式定义

定义 1.1(承诺方案)。 承诺方案是 PPT 算法的元组 Γ= (Setup, Commit, Open),其中:

  • Setup(1λ)pp 采用安全参数 λ(一元)并生成公共参数 pp

  • Commit(pp;m)(C;r) 获取秘密消息 m 并输出公开承诺 C 和(可选)秘密打开提示 r(可能为随机数)。

  • Open(pp,C;m,r)b{0,1} 利用打开提示 r,验证承诺 C 对消息 m 的打开。

承诺方案 Γ 具有绑定性,如果对所有 PPT 对手 A 而言:

Pr[ppSetup(1λ)b0=b10m0m1:(C,m0,m1,r0,r1)A(pp)b0Open(pp,C,m0,r0)b1Open(pp,C,m1,r1)]neg(λ)

通俗来说,这意味着如果没有对手可以生成某个不同的消息 m1 的有效打开并与消息 m0 相对应,则说明消息 m0 与有效承诺 C 具有绑定性。

承诺方案 Γ 具有隐藏性,如果对于任何多项式时间对手 A 而言:

|Pr[ppSetup(1λ)(m0,m1,st)A(pp)b0=b:b${0,1}(Cb;rb)Commit(pp;mb)bA(pp,st,Cb)]1/2|=negl(λ)

通俗来说,如果在承诺方案中,没有人能够“逆向工程”以确定到底是哪一条消息被承诺了,那么该承诺具有隐藏性。

回忆一下:“上锁的盒子”。 [第3讲:“数学基础构件”]

在汉密尔顿回路示例中,我们使用抗碰撞的哈希函数来构建我们的承诺方案:

  • r{0,1}256 是输入到哈希函数的随机采样密钥。

  • Commit: hash(m;r)=h

  • Open: 检查 h=?hash(m;r).

英文原文

Definition 1.1 (Commitment scheme). A commitment scheme is a tuple Γ= (Setup, Commit, Open) of PPT algorithms where:

  • Setup(1λ)pp takes security parameter λ (in unary) and generates public parameters pp;

  • Commit (pp;m)(C;r) takes a secret message m and outputs a public commitment C and (optionally) a secret opening hint r (which might or might not be the randomness used in the computation).

  • Open (pp,C;m,r)b{0,1} verifies the opening of the commitment C to the message m provided with the opening hint r.

A commitment scheme Γ is binding if for all PPT adversaries A :

Pr[ppSetup(1λ)b0=b10m0m1:(C,m0,m1,r0,r1)A(pp)b0Open(pp,C,m0,r0)b1Open(pp,C,m1,r1)]neg(λ)

Informally, this states that a valid commitment C to a message m0 is binding if no adversary can produce a valid opening to some different message m1.

A commitment scheme Γ is hiding if for any polynomial-time adversary A :

Pr[ppSetup(1λ)(m0,m1,st)A(pp)b0=b:b${0,1}(Cb;rb)Commit(pp;mb)bA(pp,st,Cb)]1/2∣=negl(λ)

Informally, this states that if a commitment is hiding if an adversary cannot "reverse-engineer" which of their messages was committed to.

Recall: "locked boxes". [Lecture 3: "Mathematical Building Blocks"]

In the Hamilton cycle example, we use a collision-resistant hash function to construct our commitment scheme:

  • r{0,1}256 is a randomly sampled secret key that is input to the hash function.

  • Commit: hash (m;r)=h.

  • Open : check h=?hash(m;r).

构造 Constructions

向量承诺 Vector commitment scheme

针对消息集 M 的向量承诺方案[2],即针对向量 m=(m1,,mk)Mk 的承诺方案。向量承诺的主要安全性质是 位置绑定

定义 2.1(位置绑定)。对于任何 PPT 敌手 A 来说,向量承诺方案 Γ位置绑定的,如果:

Pr[ Open (pp,C,m,i)1 Open (pp,C,m,i)pp$Setup(1λ)mmA(pp)(c,m,m,i)]negl(λ)

通俗来说,没有任何敌手可以在同一个位置上用两个不同的值打开 C

向量 Pedersen 承诺。Pedersen 承诺[9]是一个在消息空间 Fq 上具有绑定性和隐藏性的承诺方案。对于一个秘密消息 mZq

  • Pedersen.Setup (1λ,q)pp:pp=G,HG,其中 G 是一个阶为 q

  • Pedersen.Commit (pp;m)(C;r):C=[m]G+[r]H,其中 rZq 是一个秘密随机值。

  • Pedersen.Open (pp,C;m,r){0,1}: 证明者 P 揭示 mr,验证者 V 检查 C=?[m]G+[r]H

需要注意的是,Pedersen 承诺具有加法同态性:

Commit(m,r)+Commit(m,r)=[m]G+[r]H+[m]G+[r]H=[m+m]G+[r+r]H=Commit(m+m,r+r).

练习

证明 Pedersen 承诺方案是具有隐藏性和绑定性的。

请注意,在 G 中,找到一个给定基 G 的群元素 P 的离散对数一般是困难的。换句话说,即难以找到 x 使得 P=[x]G

  • 隐藏性:在给定承诺 C 的情况下,每个值 m 是否均等地有可能成为 C 对应的隐藏值?

  • 绑定性:证明者是否能够找到 m,m,mm,使得 C= Pedersen.Commit (pp;m)C= Pedersen.Commit (pp;m)

我们可以将 Pedersen 承诺方案扩展到消息空间 Fqk 中的向量以得到 VectorPedersen。对于一个消息 m=(m0,,mk1)

  • VectorPedersen.Setup (1λ,q,k)pp:pp=(G0,,Gk1),HG,其中 G 是一个阶为 q 的群。

  • VectorPedersen.Commit (pp;m)(C;r):C=[r]H+i=0k1[mi]Gi,其中 rZq 是一个秘密随机值。

  • VectorPedersen.Open (pp,C;m,r){0,1}: 证明者 P 揭示 mr,验证者 V 检查 C=?[r]H+i=0k1[mi]Gi

练习

证明 VectorPedersen 是具有加法同态性,即

 VectorPedersen.Commit (pp;m)+ VectorPedersen.Commit (pp;m)= VectorPedersen.Commit (pp;m+m).

Merkle 树。一个常用的构建向量承诺的解决方案是 Merkle 树 [8]。它被用于像 Git、Cassandra 和 Bitcoin 这样的分布式系统中用于汇总数据集。Merkle 树也具有隐藏性和可提取性,这些安全特性使它成为在随机预言机模型中将 IOP 编译为非交互式证明的理想选择 [1]。

图 2:Merkle 树的每个内部节点都是其两个子节点的哈希值。

  • Merkle.Commit (pp;m)C:对于 m 中的每个 mi,计算哈希值 hi=Hash(mi)。计算 Merkle 树的内部节点 hij=Hash(hi,hj)。输出 C=root=h1q

  • Merkle.Open (pp,C,m,i)b{0,1}

    • a) 证明者 P 计算从 hi 到根节点的内部节点路径,并得到证据 π=(mi,path)

    • b) 验证者 V 检查根节点是否可以通过将 mi 和路径一起计算哈希得到。

英文原文

A vector commitment scheme [2] for the message space M is a commitment scheme for a vector m=(m1,,mk)Mk. The main security property for a vector commitment is position binding:

Definition 2.1 (Position binding). A vector commitment scheme Γ is position binding if for any PPT adversary A :

Pr[ Open (pp,C,m,i)1 Open (pp,C,m,i)pp$Setup(1λ)mmA(pp)(c,m,m,i)]negl(λ)

Informally, this states that no adversary can open C to two different values at the same position.

Vector Pedersen commitment. The Pedersen commitment [9] is a binding and hiding commitment scheme for the message space Fq. For a secret message mZq :

  • Pedersen.Setup (1λ,q)pp:pp=G,HG, where G is a cryptographic group of order q.

  • Pedersen.Commit (pp;m)(C;r):C=[m]G+[r]H, where rZq is a random secret.

  • Pedersen.Open (pp,C;m,r){0,1}: the prover P reveals m and r, and the verifier V checks C=?[m]G+[r]H

Note that the Pedersen commitment is additively homomorphic:

Commit(m,r)+Commit(m,r)=[m]G+[r]H+[m]G+[r]H=[m+m]G+[r+r]H=Commit(m+m,r+r).

Exercise. Convince yourself that the Pedersen commitment scheme is hiding and binding.

Note that a cryptographic group G is a group where the problem of finding a discrete logarithm of a group element P to a given base G is hard in general. In other words, it is hard to find x such that P=[x]G.

  • hiding: given a commitment C, is every value m equally likely to be the value committed in C?

  • binding: can a prover find m,m,mm such that C= Pedersen.Commit (pp;m)C= Pedersen.Commit