您当前的位置: 首页 > 

mutourend

暂无认证

  • 1浏览

    0关注

    661博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Plonky代码解析

mutourend 发布时间:2021-10-11 12:25:32 ,浏览量:1

1. 引言

前序博客为:

  • Plonky = Plonk + Halo + Rescue

针对的代码库为:

  • https://github.com/mir-protocol/plonky
2. curve

Plonky代码库src/curve中支持了以下curves:【src/field中定义了相应的base和scalar field参数。】

  • 1)arkworks-rs的bls12-377 curve
  • 2)Halo论文早期的Tweedledee和Tweedledum cycle curves,详细可参见 Halo中的elliptic curve cycle
  • 3)ZCash halo2方案最终采用的Pallas和Vesta cycle curves,详细可参见 The Pasta Curves for Halo 2 and Beyond

其中: 1)src/curve/curve_adds.rs:定义了Projective和Affine坐标系下的2 point加法运算,最终加法结果以Projective坐标系表示。 2)src/curve/curve_summations.rs:定义了Affine坐标系下的多point加法运算 以及 多point batch inverse运算,最终结果以Projective坐标系表示。 3)src/curve/curve_multiplication.rs:scalar与Projective point点乘运算。 4)src/curve/curve_msm.rs:Plonky中的proving time主要由multi-scalar multiplication占据,Plonky中的multi-scalar multiplication实现采用 Yao算法 的一种变种。其性能要优于Pippinger算法,特别是对于包含variable-base MSM的IPA reduction场景。 5)src/curve/curve.rs:定义了Curve和HaloCurve trait。为Projective point和Affine point实现了基本的“等于、负数、double”等运算。

3. gate

Plonky中支持的gate前缀为:

//! For reference, here is our gate prefix tree:
//!
//! ```text
//! 101001 PublicInputGate
//! 101000 CurveAddGate
//! 10111* CurveDblGate
//! 11**** CurveEndoGate
//! 1000** Base4SumGate
//! 101010 BufferGate
//! 10110* ConstantGate
//! 1001** ArithmeticGate
//! 00**** RescueStepAGate
//! 01**** RescueStepBGate
//! ```
//!
//! The `*`s above represent constants which are not used in the gate prefix, and are thus available
//! for gate configuration.

Plonky中定义的参数为:

b(crate) const NUM_WIRES: usize = 9;
pub(crate) const NUM_ROUTED_WIRES: usize = 6;
pub(crate) const NUM_ADVICE_WIRES: usize = NUM_WIRES - NUM_ROUTED_WIRES;
pub(crate) const NUM_CONSTANTS: usize = 6; 
pub(crate) const GRID_WIDTH: usize = 65;
// This is currently dominated by Base4SumGate. It has degree-4n constraints, and its prefix is 4
// bits long, so its filtered constraints are degree-8n. Dividing by Z_H makes t degree-7n.
pub(crate) const QUOTIENT_POLYNOMIAL_DEGREE_MULTIPLIER: usize = 7;

3.1 PublicInputGate

Public Input Gate的PREFIX为:

const PREFIX: &'static [bool] = &[true, false, true, false, false, true];
关注
打赏
1664532908
查看更多评论
立即登录/注册

微信扫码登录

0.0428s