Aleo系列,前序博客有:
Aleo采用Proof of Succinct Work共识。
Proof of Succinct Work为SNARK-based Proof of Work算法,旨在激励对SNARKs的硬件加速。
具体为:
Miner将pending交易打包,并计算a valid nonce来解决a Proof of Succinct Work puzzle。
puzzle的difficulty rate会动态调整,以反映Aleo上的miners在每秒贡献的proof数量。
解决该puzzle的miner address将的激励为:base block reward + 该区块所包含的交易的手续费。
Aleo中使用pairing-friendly 曲线来生成和验证proof:
* | Edwards BLS12 | BLS12-377 | Edwards BW6 | BW6-761 |
---|---|---|---|---|
Curve Type | Twisted Edwards | Barreto-Lynn-Scott | Twisted Edwards | Brezing–Weng |
Scalar Field Size | 251 bits | 253 bits | 374 bits | 377 bits |
Base Field Size | 253 bits | 377 bits | 377 bits | 761 bits |
G1 Compressed Size* | 32 bytes | 48 bytes | 48 bytes | 96 bytes |
G2 Compressed Size* | N/A | 96 bytes | N/A | 96 bytes |
相关参数为:
Edwards BLS12:
BLS12-377:
Edwards BW6:
BW6-761:
PoSW为比特币SHA-based difficulty adjusting算法的变种,最关键的不同之处在于:
使得PoSW:
PoSW采用异步模式,假设大多数miners(Provers)是诚实的。
PoSW中对于relation R \mathcal{R} R 的SNARK ( G , P , V ) (G,P,V) (G,P,V) 流程为:
1)已知a set of (valid) transactions T i = t 1 , . . . , t n T_i = { t_1, ..., t_n } Ti=t1,...,tn 和 当前state state i \text{state}_i statei:
NewState ( state i , T i ) ← ( state i + 1 , w i + 1 ) \text{NewState}(\text{state}_i, T_i) \leftarrow (\text{state}_{i+1}, w_{i+1}) NewState(statei,Ti)←(statei+1,wi+1)
其中:
2)Sample a random nonce n n n 并计算:【 C R S CRS CRS为 G G G的public output】
P ( C R S , [ n , state i + 1 ] , w i + 1 ) ← π n P(CRS, [n, \text{state}_{i+1}], w_{i+1}) \leftarrow \pi_n P(CRS,[n,statei+1],wi+1)←πn
3)若 P R F ( π n ) < = d PRF(\pi_n)<= d PRF(πn)<=d,则设置 n i + 1 = n n_{i+1}=n ni+1=n和 π i + 1 = π n \pi_{i+1}=\pi_n πi+1=πn。否则返回步骤2)。【 P R F PRF PRF为a pseudorandom function used to evaluate the difficulty condition。】
d d d为难度系数,借鉴了Bitocoin和其他PoW链,会根据网络hashrate进行动态更新。It is iteratively updated based on the maximal and current targets every fixed number of blocks and guarantees constant block time.
PoSW设计为满足传统PoW guarantees,要求其具有a time-lock puzzle安全属性。
为了实现time-lock,要求PoSW满足:
任何PoW系统的最重要特性是non-batchability,是指:
Aleo采用的是Generic Group Model (GGM),其中miners have access to an oracle O O O performing a given hard computation in the random encoding of some group G G G。计算难度取决于miner访问oracle O O O的次数。
在setup时,定义了 ϵ \epsilon ϵ-amortization resistance 作为 the ratio of oracle queries performed by the optimal algorithm A O ( P , n ) A^O(P,n) AO(P,n) computing n = p o l y ( n ) n=poly(n) n=poly(n) proofs simultaneously versus the algorithm A O ( P , 1 ) A^O(P,1) AO(P,1) computing each n n n proof individually。其中 n n n为proof size, Q u e r i e s ( A O ) Queries(A^O) Queries(AO)为the number of queries A O A^O AO makes to O O O, x i x_i xi为the (randomly sampled) i i i-th problem instance:
ϵ ≤ 1 − Q u e r i e s ( A P , ℓ ( n ) O ( { x i } i = 1 ℓ ( n ) ) ) ∑ i = 1 ℓ ( n ) Q u e r i e s ( A P , 1 O ( x i ) ) . \epsilon \leq 1 - \frac{\mathsf{Queries}(\mathcal{A}^{\mathcal{O}}_{\mathcal{P}, \ell(n)}(\{\mathbf{x_i}\}_{i = 1}^{\ell(n)}))}{\sum_{i = 1}^{\ell(n)} \mathsf{Queries}(\mathcal{A}^{\mathcal{O}}_{\mathcal{P}, 1}(\mathbf{x_i}))}. ϵ≤1−∑i=1ℓ(n)Queries(AP,1O(xi))Queries(AP,ℓ(n)O({xi}i=1ℓ(n))).
ϵ \epsilon ϵ为the advantage that a large miner receives due to the amortizability of the underlying puzzle。若 ϵ = 0 \epsilon=0 ϵ=0,则没有算法可attain speedup from batching and the puzzle is perfectly amortizable。
与其它PoW scheme不同,PoSW底层计算可能solution (a single proof)所需时间要长于其它puzzles。因为NIZK生成proof是计算密集型的,若其与产块时间相当,会影响底层链的安全性。
设置proof生成时间 为 a significant fraction of 产块时间,slow miner可在其finish current attempt之前 hear of a new solution,然后放弃当前其所计算的部分proof,直接开始mine新的区块。这种放弃的部分算力浪费对应为quantization error ϵ Q \epsilon_Q ϵQ:
ϵ Q = 1 − τ / ( e τ − 1 ) \epsilon_Q = 1 - \tau / (e^{\tau} - 1) ϵQ=1−τ/(eτ−1)
其中产块时间normalize为 1 1 1,平均生成proof的时间设置为 τ \tau τ。
注意 τ ← 0 \tau\leftarrow 0 τ←0意味着 ϵ Q ← 0 \epsilon_Q\leftarrow 0 ϵQ←0。即意味着miner放弃的work趋近为0。生成proof的时间 τ p \tau_p τp与产块时间 τ b \tau_b τb之间的ratio r = τ p / τ b r=\tau_p/\tau_b r=τp/τb应最小化。
以上quantum effects将增加the number of observed collisions。若miner未同步,当收到一个区块时,会选择继续完成其当前effort。若所有miner都这么做,将影响整个网络同步。
一个mining round所期待的solution数量为一个随机变量 X ∼ P o ( τ ) X\sim Po(\tau) X∼Po(τ)。
将分叉的概率上线表示为 ϵ F \epsilon_F ϵF:
ϵ F < = ( 1 − P o i s s o n ( 1 , τ ) ) / ( 1 − P o i s s o n ( 0 , τ ) ) < = τ / 2 \epsilon_F <= (1 - Poisson(1, \tau)) / (1 - Poisson(0, \tau)) <= \tau / 2 ϵF<=(1−Poisson(1,τ))/(1−Poisson(0,τ))<=τ/2
其中, f ( q ) = P o s s i o n ( q , τ ) f(q)=Possion(q,\tau) f(q)=Possion(q,τ)为the PDF of X X X。
对于固定的block time,任何对proving time的改进(如硬件加速,或circuit size调整),都将降低分叉概率。
PoSW circuit中的predicate用于验证the inclusion of transactions in a given block。
Aleo中的system state定义为:
其中 G G G为SHA-256, k = 512 k=512 k=512。
Aleo中的system state也可称为“state tree”,其每个leaf为the unique ID of a transaction to be processed,变量state
为tree root。
PoSW circuit取 state tree中的 q < = d q<=d q<=d subtree,然后计算a Merkle tree of depth q q q。 The leaves of the tree are the depth q q q elements of the state tree Tree H ( h ) \text{Tree}_H(h) TreeH(h), instantiated over k k k-bit leaves with a different CRT function H : { 0 , 1 } k → { 0 , 1 } ( k / 2 ) H: \{0, 1\}^k \rightarrow \{0, 1\}^{(k/2)} H:{0,1}k→{0,1}(k/2) as a new PoSW tree Tree H ( q ) \text{Tree}_H(q) TreeH(q). This layout is illustrated in the diagram on the left. For example, for KaTeX parse error: Expected '}', got '_' at position 16: G = \text{BLS12_̲377} we set H H H as the 512-bit Pedersen CRH with output truncated to 256 bits.
对 H H H的circuit implementation将mask the witness variables based on a pseudorandom seed,这将作为predicate statement的一部分。这需要满足non-amortization要求。Aleo中设置 q = 3 q=3 q=3。
k k k-bit Pedersen hash function over G G G CRT hash函数定义为:
H ( G , x ) = ∏ i = 1 k G i x i H(G,x)=\prod_{i=1}^k G_i^{x_i} H(G,x)=∏i=1kGixi
其中 G i G_i Gi为 G G G中的randomly sampled generator, x i x_i xi为input x x x的第 i i i个bit。
该函数的CRT security可reduce为 the hardness of the DLP over group G G G。
k k k-bit symmetric Pedersen hash定义为:
H sym ( H , ρ ) = ∏ i = 1 k H i ( 1 − 2 ⋅ ρ i ) H_{\text{sym}}(H,\rho)=\prod_{i=1}^{k}H_i^{(1-2\cdot \rho_i)} Hsym(H,ρ)=∏i=1kHi(1−2⋅ρi)
定义 ( F p 2 ) k (F_{p^2})^k (Fp2)k内的group variable Q = ( Q x , Q y ) , h i = ( h x i , h y i ) Q=(Q_x,Q_y), h_i=(h^i_x,h^i_y) Q=(Qx,Qy),hi=(hxi,hyi),check如下evaluations:
这需要 k k k Edwards multiplications (6 constraints each),且需要a bit lookup for each of the h i h_i hi in addition to k k k booleanity checks。
具体见PedersenCRHGadget
中的precomputed_base_symmetric_multiscalar_mul
。
k k k-length masked Pedersen hash function over G G G 为 CRT hash function H mask : { 0 , 1 } k × { 0 , 1 } k × G → G H_\text{mask}:\{0,1\}^k\times\{0,1\}^k\times G\rightarrow G Hmask:{0,1}k×{0,1}k×G→G:
H mask G , H ( ρ , x , P ) = P ∗ ∏ i = 1 k ( 1 [ x i ( + ) ρ i = 1 ] G i 2 ∗ x i − 1 H i 2 ∗ ρ i − 1 + 1 [ x i ( + ) ρ i = 0 ] H i 2 ∗ ρ i − 1 ) H_\text{mask}^{G, H}(\rho, x, P) = P * \prod_{i=1}^{k}(1[x_i (+) \rho_i = 1] G_i^{2 * x_i - 1} H_i^{2 * \rho_i - 1} + 1[x_i (+) \rho_i = 0] H_i^{2 * \rho_i - 1}) HmaskG,H(ρ,x,P)=P∗∏i=1k(1[xi(+)ρi=1]Gi2∗xi−1Hi2∗ρi−1+1[xi(+)ρi=0]Hi2∗ρi−1)
其中 x i x_i xi和 ρ i \rho_i ρi分别为 x x x和 ρ \rho ρ的第 i i i个bit,而 G i G_i Gi为randomly sampled generators of G G G, ( + ) (+) (+)为bitwise XOR operation。附加 P P P变量来实现demasking操作。
定义 ( F p 2 ) k (F_{p^2})^k (Fp2)k内的group variable Q = ( Q x , Q y ) , g i = ( g x i , g y i ) Q=(Q_x,Q_y), g_i=(g^i_x,g^i_y) Q=(Qx,Qy),gi=(gxi,gyi) 以及 F p k F_{p}^k Fpk内布尔变量 z z z,执行如下evaluations:
这需要 k k k Edwards multiplications (6 constraints each),且需要a 2 2 2-bit lookup for each of the g i g_i gi (2 constraints each) in addition to k k k booleanity checks。
具体见PedersenCRHGadget
中的precomputed_base_scalar_mul_masked
。
Aleo instantiate a circuit verifying M M M evaluations of H G H^G HG using circuit for H mask G , H H_{\text{mask}}^{G,H} HmaskG,H and H sym H H_{\text{sym}^H} HsymH over G G G。注意,这些变量在 F p F_p Fp内,而 ( z x , z y ) (z_x,z_y) (zx,zy)变量在 F p 2 F_{p^2} Fp2域,可解析为elliptic curve point in G G G。
假设 G G G中的 G i , H i G_i,H_i Gi,Hi已预计算,可作为constant被访问。
1)Inputs:
k k k-length masked evaluation of M M M Pedersen hashes的输入为:
2)Evaluation:
3)Output:
The k / 2 k/2 k/2 length set of variables { o x 1 , ⋯ , o x k } \{o^1_x,\cdots,o^k_x\} {ox1,⋯,oxk} in ( F p ) k (F_p)^k (Fp)k as the truncated outputs。
Aleo中的Pedersen Primitives采用BLS12-377作为底层group,相应的output length(point压缩格式)为 256 + 1 = 257 256+1=257 256+1=257,Aleo 将其truncate为 256 256 256 bits。基于的安全假设为ECDLP,相应的security level 为 λ ∼ = 128 \lambda\sim=128 λ∼=128 bits。
input length k = 512 k=512 k=512 bits。
PoSW tree Tree H ( q ) \text{Tree}_H(q) TreeH(q)的叶子为:subroots of the state tree’s q q q-depth nodes。
PoSW tree Tree H ( q ) \text{Tree}_H(q) TreeH(q)使用 k k k-bit Pedersen hash gadget 和 seed ρ \rho ρ 来计算root state i \text{state}_i statei。
seed 参数 ρ = P R F ( s t a t e i ∣ ∣ n ) \rho=PRF(state_i||n) ρ=PRF(statei∣∣n)为伪随机函数 P R F PRF PRF的输出,输入为nonce n n n 和 tree root。
在每个Predicate 生成seed的流程为:
1)已知输入:nonce n ∈ { 0 , 1 } 256 n\in \{0,1\}^{256} n∈{0,1}256 和 stae i ∈ { 0 , 1 } 256 \text{stae}_i\in \{0,1\}^{256} staei∈{0,1}256,输出 ρ 0 ∈ { 0 , 1 } 256 \rho_0\in \{0,1\}^{256} ρ0∈{0,1}256 as ρ 0 = B L A K E ( n ∣ ∣ state i ) \rho_0=BLAKE(n||\text{state}_i) ρ0=BLAKE(n∣∣statei),其中 ∣ ∣ || ∣∣表示string拼接。
2)若 ρ 0 \rho_0 ρ0的第 i i i个bit ρ 0 , i \rho_{0,i} ρ0,i为 0 0 0或 1 1 1,设置 ρ \rho ρ的第 ( 2 i − 1 ) (2i-1) (2i−1)或第 2 i 2i 2i个bit分别为 10 10 10或 01 01 01。使得 ρ ∈ { 0 , 1 } 512 \rho\in\{0,1\}^{512} ρ∈{0,1}512具有constant Hamming distance 256 256 256。
这些都是在circuit之外完成的。且需要input format for every valid instance。
a valid statement ϕ = < state i , n > ∈ { 0 , 1 } 512 \phi=<\text{state}_i,n>\in\{0,1\}^{512} ϕ=<statei,n>∈{0,1}512 为 a subset of F p 512 F_p^{512} Fp512,其中:
1) state i ∈ { 0 , 1 } 256 \text{state}_i\in\{0,1\}^{256} statei∈{0,1}256 为bitwise representation of the PoSW root node of the updated state variable。
2) n ∈ { 0 , 1 } 256 n\in\{0,1\}^{256} n∈{0,1}256 为the bitwise representation of the nonce。
以上statement的witness w w w包含:
对于root state i \text{state}_i statei和 Tree H ( q ) \text{Tree}_H(q) TreeH(q)的所有内部nodes,运行a computation of the H H H gadget with the node value as output and its children as inputs。
PoSW circuit会验证 Tree H ( q ) \text{Tree}_H(q) TreeH(q) 正确生成的。需要的计算量为 2 q − 1 + 1 2^{q-1}+1 2q−1+1 instances of H H H。
PoSW共识中的mining算法为:modular exponentiation over some group G G G。
以 R R R来表示代表PoSW circuit的relation,NIZK ( G , P , V ) (G,P,V) (G,P,V),生成common reference string C R S = G ( R ) CRS=G(R) CRS=G(R)。
兴趣点在于为 P P P定义一种算法,该算法具有a size S S S precomputation string that minimizes the number of multiplications performed in G G G。
PoSW将PoW process reduce为 the hardness of exponentiation,需要计算 q q q instances of exponentiating k k k random indices x i , j x_{i,j} xi,j in Z p Z_p Zp, ( i , j ) ∈ [ q ] × [ k ] (i,j)\in[q]\times [k] (i,j)∈[q]×[k] for prime p p p of size n = l o g ( p ) n=log(p) n=log(p) by some random bases G i G_i Gi in G G G:
MultiExp ( G 1 , . . . , G k , x 1 , . . . , x q ) = ( ∏ i = 1.. k G i x 1 , i , . . . , ∏ i = 1.. k G i x q , i ) \text{MultiExp}({G_1, ..., G_k}, {x_1, ..., x_q}) = (∏_{i = 1..k} G_i^{x_{1,i}}, ..., ∏_{i = 1..k} G_i^{x_{q,i}}) MultiExp(G1,...,Gk,x1,...,xq)=(∏i=1..kGix1,i,...,∏i=1..kGixq,i)
算法 A = ( A 1 , A 2 ) A=(A_1,A_2) A=(A1,A2)分为2个阶段:
对于每个bases G i G_i Gi,计算 S / k S/k S/k exponents,并将其存入precomputation string中。这些exponents为the radix decomposition bases for Z p Z_p Zp at the maximal permissible depth c c c。
平均来说,每个index最多需要 n / ( 3 + l o g ( S ) − l o g ( k ) − l o g ( n ) ) n/(3+log(S)-log(k)-log(n)) n/(3+log(S)−log(k)−log(n))次multiplications for a total of q ∗ k ∗ n / ( l o g ( S ) − l o g ( k ) − l o g ( n ) ) q*k*n/(log(S)-log(k)-log(n)) q∗k∗n/(log(S)−log(k)−log(n))。这意味着the size of the precomputation string s s s grows exponentially with a linear improvement in proving time。
对于具有 S = k ∗ ( n / c ) ∗ ( 2 c − 1 ) S=k*(n/c)*(2^c-1) S=k∗(n/c)∗(2c−1)个group elements的precomputation table,每个exponentiation平均计算量为 n / c n/c n/c次multiplication。但是,某些point a maximal c ∗ c^* c∗ is obtained that balances the communication cost of sending more precomputed elements with the cost of performing additional multiplications。因此,可假设miners work at around the level, and look at the security it implies。
Aleo评估了不同values of c ∈ N + c\in {N_+} c∈N+的proof生成时间。在constant block frequency场景下,可用于project what the minimal table size S S S is for a predicate involving k k k exponentiations to achieve sufficiently low quantization error and collision probability。
We fix S S S and k k k and investigate proof generation times for fixed table size. Proving times in the GM17 and Marlin provers alongside the corresponding quantization error and collision probabilities are provided below for a single-threaded desktop machine. Security is with respect to 1 minute blocks and a circuit with k ≈ 2 13 k\approx 2^{13} k≈213 exponentiations per proof.
Proof System | Proof Generation Time (s) | Quantization Error (%) | Collision Probability (%) |
---|---|---|---|
Marlin | 4.65 | 3.82 | 3.87 |
GM17 | 0.91 | 0.758 | 0.76 |
采用硬件加速的miner的proof生成时间将大幅缩短,因此,更多更快的miner将有助于降低quantization error和collision probabilities。也有助于网络更安全的运行。
Aleo的PoSW中的proof system采用的Marlin架构。Marlin架构与non-interactive Random Oracle setting下的属性一致。
simulation-extractable (SE) proof system 具有 a unique encoding for every valid instance-witness pair ⟨ ϕ , w ⟩ \langle \phi, w\rangle ⟨ϕ,w⟩。即意味着valid proofs cannot be rerandomized without explicit knowledge of a different witness for ϕ \phi ϕ。否则an adversarial prover would be able to change the encoding of a proof after computation until it satisfies difficulty, which would violate the non-amortization requirement。
A non-amortizable prover should reduce in difficulty to a problem known (or postulated) to be non-batchable (or ‘hard’) on average。
由于当前大多数proof system采用的都是Kate commitment。因此Aleo中致力于 reduce proof computation to the problem of multi-exponentiation of a set of given (random) bases G i i = 1 m ∈ G m {G_i}_{i = 1}^m \in \mathbb{G}^m Gii=1m∈Gm by a set of random indices x i i = 1 m ∈ Z p m {x_i}_{i =1}^m \in \mathbb{Z}_p^m xii=1m∈Zpm。此时,hardness is measured in the number of queries to a multiplication oracle O m \mathcal{O}_m Om in the given group’s encoding。
尽管该问题在unbounded space下并 non-amortizable的,但是,miners具有fixed size precomputation string,可认为其是non-amortizable的。
predicate的选择对于确保以上security也至关重要。
R \mathcal{R} R relation应满足如下属性:
We set the desirable error bounds for quantization and forking error to 3 % 3\% 3% and 1.5 % 1.5\% 1.5% respectively. For a protocol with 1 1 1-minute block times, this implies that average proof generation times need to be upper bounded by τ = 1.8 ≈ 2 \tau = 1.8 \approx 2 τ=1.8≈2 seconds.
PoSW circuit支持并行化 in each of the bases that need to be exponentiated。即意味着使用并行硬件可降低proving time,也意味着更高的chain security。但是带来的问题是需要能支持large parallel computing instances的larger miners。
若底层circuit computation为inherently sequential的,则可实现Verifiable Delay Function(VDF)。
Recursion computation可将PoSW circuit转换为sequential computation。将circuit切分为sequential proofs that ‘pass’ an intermediate set of witnesses through many sub-circuit:
每个仅需运行一小部分计算。
通过recursion,每个proof都是下一proof的输入,让subcircuit足够小,将保证最终生成的proof为几乎sequential。
尽管当前的设计倾向于non-parallelizabilit,这将带来high efficiency costs due to the requirement for recursive computation。
但是,需要设计a parallelizable instance,使得可开发相应的硬件,来提供有意义的security guarantee(low collision probability due to lower proof generation times)。
随着硬件和密码学优化,recursive composition就足够了,整个协议可简单过渡为a state where the underlying proof generation is inherently sequential。
[1] Aloe Proof of Succinct Work
[2] Incentivized Testnet Announcement
[3] Aleo 共识
[4] Aleo Mining Process
[5] Aleo PoSW并行化