Plonky代码解析

本文解析了Plonky代码库中涉及的arkworks-rs曲线、Halo论文中的椭圆曲线及Pallas/Vesta曲线,介绍了Curve模块的关键运算如加法、多点运算和scalar multiplication。同时概述了Plonky中的PublicInputGate和Gate前缀树,以及Gate配置参数。

1. 引言

前序博客为:

针对的代码库为:

2. curve

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

其中:
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];
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值