1. 引言
最早在2014年论文 “Scalable Zero Knowledge via Cycles of Elliptic Curves” (BCTV14) 中提出将cycle of curves用于IVC(Incremental Verifiable Computation)中,以提升递归证明的工作效率。
2. 何为cycles of curves?
令
E
p
E_p
Ep为elliptic curve over finite field
F
p
\mathbb{F}_p
Fp,其中
p
p
p为prime,将其表示为
E
p
/
F
p
E_p/\mathbb{F}_p
Ep/Fp。
group of points of
E
p
E_p
Ep over
F
p
\mathbb{F}_p
Fp,具有order
q
=
#
E
(
F
p
)
q=\#E(\mathbb{F}_p)
q=#E(Fp),将
F
p
\mathbb{F}_p
Fp称为base field,
F
q
\mathbb{F}_q
Fq称为scalar field。
Halo2将instantiate proof system over the elliptic curve E p / F p E_p/\mathbb{F}_p Ep/Fp,需prove statements about F q \mathbb{F}_q Fq-arithmetic circuit satisfiability。
QA:
curve为
E
p
E_p
Ep over
F
p
\mathbb{F}_p
Fp,为何其arithmetic circuit为基于
F
q
\mathbb{F}_q
Fq而不是
F
p
\mathbb{F}_p
Fp的呢?
因为proof system通常是基于encodings of the scalars in the circuit(或更准确的说,commitments to polynomials whose coefficients are scalars)。这些scalars是基于
F
q
\mathbb{F}_q
Fq的,而其encodings或commitments则是elliptic curve point in
E
p
/
F
p
E_p/\mathbb{F}_p
Ep/Fp。
但是,大多数Verifier的arithmetic computations是基于base field F p \mathbb{F}_p Fp的,因此可高效表示为an F p \mathbb{F}_p Fp-arithmetic circuit。
QA:
为何说Verifier的计算主要是基于
F
p
\mathbb{F}_p
Fp的呢?
因为Halo2中Verifier实际需使用circuit的output information来运行group operations。类似point doubling和point addition的group operations,都是arithmetic in
F
p
\mathbb{F}_p
Fp,因为这些point的坐标值都是in
F
p
\mathbb{F}_p
Fp的。
构建另一条scalar field为 F p \mathbb{F}_p Fp曲线的主要目的是:【证明“Verifier的计算”为non-native arithmetic,借助cycles of curves,其对应为另一曲线 的native arithmetic。】
- 具有an
F
p
\mathbb{F}_p
Fp-arithmetic circuit,可高效verify proofs from the first curve。
此外,若第二条曲线的base field为 E q / F q E_q/\mathbb{F}_q Eq/Fq,则将generate proofs that could be efficiently verified in the first curve’s F q \mathbb{F}_q Fq-arithmetic circuit。换句话说,可instantiate a second proof system over E q F q E_q\mathbb{F}_q EqFq,从而形成a 2-cycle with the first:
3. cycles of curves现状
当前知名的cycles of elliptic curves 有:
- 1)Secp_256k1/Secq_256k1。【详情见Spartan-ECDSA:最快的浏览器内 ZK secp256k1 ECDSA中的“附录:Secp256k1/Secq256k1曲线cycle”。】
- 2)FFT-friendly cycles of curves,如Pasta(Pallas/Vesta)。【详情见:Halo2学习笔记——背景资料之Elliptic curves(5) 和 Mina中的Pasta(Pallas和Vesta)曲线。】
- BN254/Grumpkin。【详细参数见Aztec Yellow Paper(包含了BN254 pairing和cycle曲线定义)。】
这些曲线的开源代码实现见:
- https://github.com/deevashwer/curves(Rust语言。实现了Pallas/Vesta、BN254/Grumpkin、Secp_256k1/Secq_256k1等曲线。)
当前cycles of curves在递归证明领域的应用现状为:
- 1)Mina基于Pasta(Pallas/Vesta)曲线构建递归证明。
- 2)ZCash Halo2基于Pasta(Pallas/Vesta)曲线构建递归证明。
- 3)微软Nova/SuperNova基于Pasta(Pallas/Vesta)曲线构建Folding scheme。
- 4)Spartan-ECDSA基于" Nova Folding scheme+Spartan+Secp_256k1/Secq_256k1曲线"构建 ECDSA group membership证明。
- 5)Aztec基于BN254/Grumpkin曲线构建Aztec 2.0(以太坊的多资产private rollup)。
但是,基于cycles of curves来构建约束系统,除带来复杂性问题(如需验证2个proof而不是1个proof)之外,还可能带来安全漏洞,以Nova/SuperNova为例:【详细见Nova早期代码实现中cycles of curves的攻击问题:David Wong博客 The zero-knowledge attack of the year might just have happened, or how Nova got broken】
4. cycles of curves并非必选项
为解决递归证明中,“证明验证proof”中的non-native arithmetic问题,在保证安全性的前提下并提升效率,有如下关键策略:
-
1)Lookup arguments:另一个减少non-native运算的重要策略为:引入基于foreign field椭圆曲线运算的大型lookup table。该方法将执行非原生椭圆曲线运算的问题转化为执行原生椭圆曲线运算,从而降低了任务的复杂性。
-
2)Weak prover-strong prover:该策略是在不泄露信息的情况下,将尽可能多的计算由 weak prover 推迟到给 stronger prover,从而最大限度地减少weak prover上的计算负载。即在weak机器上fold,在服务器端做non-native繁重计算。
-
3)Range checks:该方法只是简单地确保正在处理的数字不会超过scalar域的素数值。若将这些数字限制在一定范围内,可像使用整数一样使用它们。
-
4)Bignum techniques:在很多情况下,正在处理的数字确实会超过scalar域的素数值。这时可将这些数字切分为“limbs”,并对每个limb做range check验证。可做大量这样的range check,并使用相关技术来忽略“high limbs”。
- 如zkSync的Franklin-crypto递归证明中采用的RNS算法。
-
5)Cycles of curves:
-
6)借助super-singular curves 或 其它椭圆曲线:如CPerezz19在(Intro to ZK Day) Elliptic Curve explorations - Catching up with Goldilocks & FRI 中提及的。
Supersingular椭圆曲线的scalar field与base field相等,即 F p = F q \mathbb{F}_p=\mathbb{F}_q Fp=Fq,即意味着,Supersingular椭圆曲线 cycle to 自身:- 不存在错误的域运算。
- 可使用cycle的两端用于实际计算。
但是embedding degree如果过低,会存在MOV攻击问题。如2005年Alfred Menezes An Introduction to Pairing-Based Cryptography论文中所指出:“自20世纪90年代初起,已达成共识,具有low embedding degree的elliptic curve不适合用于discrete log protocols中。但是,low embedding degree的elliptic curve在高效实现pairing-based protocols中至关重要。”
参考资料
[1] Nova: Recursive Zero-Knowledge Arguments from Folding Schemes学习笔记
[2] 基于cycle of curves的Nova证明系统(1)
[3] 基于cycle of curves的Nova证明系统(2)
[4] Cycles of curves: what are they and do we need them?
[5] Non-native field arithmetic with TurboPlonk, Plookup, etc
[6] Aztec emulated field and group operations
[7] The lookup singularity - how zero-knowledge proofs can be made simpler and easier to review
[8] Goblin Plonk:lazy recursive proof composition
[9] Accumulating IM transcripts across recursive proofs
[10] 大模数运算之中国余数定理 Modular Arithmetic CRT: How do modulo with very big numbers
[11] Aztec Yellow Paper(包含了BN254 pairing和cycle曲线定义)
[12] RNS(Residue number system)
[13] Halo2学习笔记——背景资料之Elliptic curves(5)
附录A BN254曲线 及其 配套的twisted second paring曲线
BN254曲线的group size(即Scalar field size)约为
2
254
2^{254}
2254,Base field size也约为
2
254
2^{254}
2254。安全性约为110 bits。
BN254曲线方程式为:
E
:
Y
2
=
X
3
+
3
E: Y^2=X^3+3
E:Y2=X3+3
具体参数为:
- Base field
F
p
\mathbb{F}_p
Fp为素数:
p = 21888242871839275222246405745257275088696311157297823662689037894645226208583 = 0 x 30644 e 72 e 131 a 029 b 85045 b 68181585 d 97816 a 916871 c a 8 d 3 c 208 c 16 d 87 c f d 47 p=21888242871839275222246405745257275088696311157297823662689037894645226208583=0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47 p=21888242871839275222246405745257275088696311157297823662689037894645226208583=0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47(size约为 2 254 2^{254} 2254) - Group
G
1
=
E
/
F
p
\mathbb{G}_1=E/\mathbb{F}_p
G1=E/Fp(即Scalar field size)为prime order:
r = 21888242871839275222246405745257275088548364400416034343698204186575808495617 = 0 x 30644 e 72 e 131 a 029 b 85045 b 68181585 d 2833 e 84879 b 9709143 e 1 f 593 f 0000001 r=21888242871839275222246405745257275088548364400416034343698204186575808495617=0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001 r=21888242871839275222246405745257275088548364400416034343698204186575808495617=0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001(size约为 2 254 2^{254} 2254) - Generator为: P 1 = ( 1 , 2 ) ∈ G 1 P_1=(1,2)\in\mathbb{G}_1 P1=(1,2)∈G1
- 有 2 253 < r < p < 2 254 2^{253}<r<p<2^{254} 2253<r<p<2254。
与BN254曲线配套的twisted second paring曲线的构建思路为:
base field size取
2
254
×
2
2^{254\times 2}
2254×2,subgroup size(即scalar field size)约为
2
254
2^{254}
2254。为
F
q
\mathbb{F}_{q}
Fq的degree-2 field extension:
F
q
2
=
F
q
[
X
]
/
(
X
2
+
1
)
\mathbb{F}_{q^2}=\mathbb{F}_q[X]/(X^2+1)
Fq2=Fq[X]/(X2+1),其中
(
X
2
+
1
)
(X^2+1)
(X2+1)为由
f
(
X
)
=
X
2
+
1
f(X)=X^2+1
f(X)=X2+1生成的ideal——其根为
±
i
\pm i
±i。
与BN254曲线配套的twisted second paring曲线方程式为:
E
:
Y
2
=
X
3
+
3
(
i
+
9
)
E: Y^2=X^3+\frac{3}{(i+9)}
E:Y2=X3+(i+9)3
具体参数为:
- base field 为
F
p
2
\mathbb{F}_{p^2}
Fp2:【base field size约为
2
254
×
2
2^{254\times 2}
2254×2】
p = 21888242871839275222246405745257275088696311157297823662689037894645226208583 = 0 x 30644 e 72 e 131 a 029 b 85045 b 68181585 d 97816 a 916871 c a 8 d 3 c 208 c 16 d 87 c f d 47 p=21888242871839275222246405745257275088696311157297823662689037894645226208583=0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47 p=21888242871839275222246405745257275088696311157297823662689037894645226208583=0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47 - Group
G
2
=
\mathbb{G}_2=
G2= subgroup of
E
/
F
p
2
E/\mathbb{F}_{p^2}
E/Fp2,具有与
G
1
\mathbb{G}_1
G1相同的prime order
r
r
r:【size约为
2
254
2^{254}
2254】
r = 21888242871839275222246405745257275088548364400416034343698204186575808495617 = 0 x 30644 e 72 e 131 a 029 b 85045 b 68181585 d 2833 e 84879 b 9709143 e 1 f 593 f 0000001 r=21888242871839275222246405745257275088548364400416034343698204186575808495617=0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001 r=21888242871839275222246405745257275088548364400416034343698204186575808495617=0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001 - Generator为: P 2 = 11559732032986387107991004021392285783925812861821192530917403151452391805634 ∗ i + 10857046999023057135944570762232829481370756359578518086990519993285655852781 , 4082367875863433681332203403145435568316851327593401208105741076214120093531 ∗ i + 8495653923123431417604973247489272438418190587263600148770280649306958101930 ) ∈ G 2 P_2= 11559732032986387107991004021392285783925812861821192530917403151452391805634∗i +10857046999023057135944570762232829481370756359578518086990519993285655852781, 4082367875863433681332203403145435568316851327593401208105741076214120093531 ∗ i + 8495653923123431417604973247489272438418190587263600148770280649306958101930)\in \mathbb{G}_2 P2=11559732032986387107991004021392285783925812861821192530917403151452391805634∗i+10857046999023057135944570762232829481370756359578518086990519993285655852781,4082367875863433681332203403145435568316851327593401208105741076214120093531∗i+8495653923123431417604973247489272438418190587263600148770280649306958101930)∈G2
二者采用以太坊原生的Ate pairing,具有的bilinear map为:
ϵ
:
G
1
×
G
2
→
G
T
\epsilon: \mathbb{G}_1\times \mathbb{G}_2\rightarrow \mathbb{G}_T
ϵ:G1×G2→GT
其中
G
T
\mathbb{G}_T
GT为
F
q
\mathbb{F}_q
Fq的degree-12 field extension。
附录B BN254曲线的curve cycle——Grumpkin
BN254曲线的curve cycle——Grumpkin的base field size 等于 BN254曲线的scalar field size,其scalar field size 等于 BN254曲线的base field size。
Grumpkin曲线方程式为:
E
:
Y
2
=
X
3
−
17
E: Y^2=X^3-17
E:Y2=X3−17
具体参数为:
- Group
G
\mathbb{G}
G的order为:
p = 21888242871839275222246405745257275088696311157297823662689037894645226208583 = 0 x 30644 e 72 e 131 a 029 b 85045 b 68181585 d 97816 a 916871 c a 8 d 3 c 208 c 16 d 87 c f d 47 p=21888242871839275222246405745257275088696311157297823662689037894645226208583=0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47 p=21888242871839275222246405745257275088696311157297823662689037894645226208583=0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47 - Base field
F
r
F_r
Fr为:
r = 21888242871839275222246405745257275088548364400416034343698204186575808495617 = 0 x 30644 e 72 e 131 a 029 b 85045 b 68181585 d 2833 e 84879 b 9709143 e 1 f 593 f 0000001 r=21888242871839275222246405745257275088548364400416034343698204186575808495617=0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001 r=21888242871839275222246405745257275088548364400416034343698204186575808495617=0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001