gsnark中的证明方案及曲线

1. 引言

gsnark由ConsenSys团队开发及维护。
开源代码见:

gsnark当前支持2种证明方案:

这2种证明方案可基于以下6种曲线实现,通过ID来选择:

  • BN254(已用于Ethereum 1.x,以太坊将其预编译为altbn128)
    在这里插入图片描述

  • BLS12-381(已用于Ethereum 2.0、ZCash Sapling、Algorand、Dfinity、Chia、Filecoin)

  • BLS12-377(BLS12-377/BW6-761,已用于Celo、Aleo、EY)

  • BLS24-315

  • BW6-633

  • BW6-761

gnark-crypto对这些曲线做了对比和bench

2. Groth16 VS PlonK

Groth16PlonK
trusted[^1] setupcircuit-specificuniversal ⋆ ⋆ \star\star
proof length ⋆ ⋆ ⋆ \star\star\star ⋆ \star
prover work ⋆ ⋆ \star\star ⋆ \star
verifier work ⋆ ⋆ \star\star ⋆ \star

当需要为同一电路(如某单一逻辑计算)生成很多证明 且 关注高性能 时,Groth16是最佳选择;当需要处理不同的电路(如不同的任意的业务逻辑) 且 要有相对快的性能 时,PlonK为最佳选择。

2.1 Groth16

Groth16为circuit-specific preprocessing general-purpose zk-SNARK construction。Groth16具有:

  • constant size proof
  • appealing verifier time

已成为事实上的标准广泛用于多个区块链项目。

Groth16的缺陷在于:

  • 其需要a circuit-specific trusted setup for its preprocessing phase。

推荐看:

使用Groth16的项目有:

  • ZCash
  • Loopring
  • Hermez
  • Celo
  • Filecoin

3. PlonK

PlonK为universal preprocessing general-purpose zk-SNARK construction。

PlonK证明方案具有:

  • 可更新的 preprocessing phase
  • short and constant verification time

PlonK相比于Groth16的缺陷在于:

  • 生成proof更大且更慢

推荐看:

使用PlonK的项目有:

  • Aztec
  • ZKSync
  • Dusk

根据PlonK所选择的多项式承诺方案的不同,可将PlonK分为:

也可根据Prover和Verifier之间的权衡来划分为:

  • “fast-prover-but-slow-verifier” PlonK
  • “slow-prover-but-fast-verifier” PlonK

还有一些不同的PlonK优化方案:

4. 椭圆曲线选型

Groth16和PlonK(基于KZG方案)都需要基于某椭圆曲线实例化。
gsnark支持6种椭圆曲线:

  • BN254(已用于Ethereum 1.x)
  • BLS12-381(已用于Ethereum 2.0、ZCash Sapling、Algorand、Dfinity、Chia、Filecoin)
  • BLS12-377(BLS12-377/BW6-761,已用于Celo、Aleo、EY)
  • BLS24-315
  • BW6-633
  • BW6-761

这些曲线都基于某有限域 F p \mathbb{F}_p Fp定义,具有的方程式形式为:
y 2 = x b 3 y^2=x^3_b y2=xb3,其中 b ∈ F p b\in\mathbb{F}_p bFp

Groth16和PlonK(基于KZG方案)要求这些曲线需具有:

  • 为满足proof soundness,需具有安全性
  • 为满足proof verification,需为pairing-friendly
  • 为高效生成proof,需具有a highly 2-adic subgroup order

4.1 BN254和BLS12-381曲线

对于Ethereum 1.x主网应用,其仅支持BN254曲线。其它曲线的EIP有,但当前未集成:

对于Ethereum 2.0应用,其使用的是BLS12-381曲线。

对于平台无关的应用程序,需在性能(BN254)和 安全性(BLS12-381)之间进行权衡。推荐使用BLS12-381,因其更安全,尽管慢于BN254但实际上仍足够快。

4.2 BLS12-377和BW6-761曲线

对于需要one-layer proof composition(a proof of proofs)的应用来说,不可使用BN254或BLS12-381,因其在该应用场景下效率太低。

使用one-layer proof composition的应用有:

  • ZEXE
  • Celo
  • Aelo
  • Zecale

事实上,这样的应用要求椭圆曲线对 ( E 1 , E 2 ) (E_1,E_2) (E1,E2)

  • 为满足proof soundness,需是安全的
  • 为满足proof verification,需是pairing-friendly的
  • 为高效生成proof,需具有a highly 2-adic subgroup order【由于 E 1 E_1 E1也必须有 a highly 2-adic field characteristic,因此不能将BLS12-381曲线不可用作 E 1 E_1 E1。】
  • 为高效实现proof composition, E 2 E_2 E2具有a subgroup order equal to E 1 E_1 E1’s field characteristic。

BLS12-377和BW6-761曲线可满足以上条件,且具有快速实现。

4.3 BLS24-315和BW6-633曲线

Groth16中,椭圆曲线操作发生在3个不同的群中:

  • G 1 G_1 G1
  • G 2 G_2 G2
  • G T G_T GT

而PlonK(with KZG)操作仅发生在 G 1 G_1 G1 G T G_T GT中。

BN254\BLS12-381\BLS12-377曲线对这3个群都进行了优化,而BLS24-315仅对 G 1 G_1 G1具有更好的优化 且 对 G T G_T GT的优化仍具有竞争优势。此外,BLS24-315与BW6-633结合可enable PlonK one-layer proof composition efficiently。

总之,(BLS24-315, BW6-633)曲线对为:

  • 为满足proof soundness,是安全的
  • 为满足proof verification,是pairing-friendly的
  • 针对KZG-based SNARKs进行了优化(如,PlonK)
  • 为高效生成proof,具有highly 2-adic subgroup order
  • 为高效实现proof compostion,BW6-633具有a subgroup order等于BLS24-315的field characteristic。

参考资料

[1] Prove schemes and curves

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值