Skip to content

Commit

Permalink
Update for plonky2.
Browse files Browse the repository at this point in the history
  • Loading branch information
silathdiir committed Sep 4, 2024
1 parent b15fdff commit c2d9209
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
16 changes: 10 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ anyhow = "1.0.71"
hex = "0.4.3"
bitvec = "1"
rayon = "1.7.0"
plonky2 = {git="https://github.com/InternetMaximalism/plonky2", rev="541e127"}
plonky2_u32={git="https://github.com/InternetMaximalism/plonky2", rev="541e127"}
plonky2_ecdsa={git="https://github.com/InternetMaximalism/plonky2", rev="541e127"}
starky = {git="https://github.com/InternetMaximalism/plonky2", rev="541e127"}
plonky2-bn254={git="https://github.com/qope/plonky2-bn254.git", rev="d616d57"}
starky-bn254={git="http://github.com/qope/starky-bn254", rev="2165be0"}
plonky2 = "0.2.2"
plonky2-bn254 = { git = "https://github.com/Lagrange-Labs/plonky2-bn254", branch = "update-plonky2" }
plonky2_ecdsa = { git = "https://github.com/Lagrange-Labs/plonky2-ecdsa" }
starky = { git = "https://github.com/Lagrange-Labs/plonky2", branch = "starky-bn254-update" }
starky-bn254 = { git = "http://github.com/Lagrange-Labs/starky-bn254", branch = "update-plonky2" }

[patch.crates-io]
plonky2 = { git = "https://github.com/Lagrange-Labs/plonky2", branch = "starky-bn254-update" }
plonky2_field = { git = "https://github.com/Lagrange-Labs/plonky2", branch = "starky-bn254-update" }

3 changes: 1 addition & 2 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
[toolchain]
channel = "nightly-2023-06-15"
nightly
2 changes: 1 addition & 1 deletion src/final_exp_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ mod tests {
use ark_ff::Field;
use ark_std::UniformRand;
use num_bigint::BigUint;
use starky_bn254::utils::biguint_to_bits;
use starky_bn254::utils::utils::biguint_to_bits;

use crate::miller_loop_native::{miller_loop_native, multi_miller_loop_native};
use plonky2_bn254::fields::debug_tools::print_ark_fq;
Expand Down
15 changes: 13 additions & 2 deletions src/final_exp_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ use plonky2::{
};

use plonky2_bn254::fields::{fq12_target::Fq12Target, fq2_target::Fq2Target};
use starky_bn254::{circuits::fq12_exp_u64_circuit, input_target::Fq12ExpU64InputTarget};
use starky_bn254::fields::fq12_u64::{
circuit::{fq12_exp_u64_circuit, Fq12ExpU64InputTarget},
exp_u64::{num_columns, num_public_inputs},
};

use crate::final_exp_native::{frob_coeffs, BN_X};

/// `fq12_exp_u64_circuit` generic parameter
const FQ12_EXP_U64_NUM_IO: usize = 4;

fn frobenius_map<F: RichField + Extendable<D>, const D: usize>(
builder: &mut CircuitBuilder<F, D>,
a: &Fq12Target<F, D>,
Expand Down Expand Up @@ -72,6 +78,8 @@ fn hard_part_BN<
) -> Fq12Target<F, D>
where
<C as GenericConfig<D>>::Hasher: AlgebraicHasher<F>,
[(); num_columns(FQ12_EXP_U64_NUM_IO)]:,
[(); num_public_inputs(FQ12_EXP_U64_NUM_IO)]:,
{
let offset = Fq12Target::constant(builder, Fq12::one());
let exp_val = builder.constant(F::from_canonical_u64(BN_X));
Expand Down Expand Up @@ -138,7 +146,10 @@ where
T0 = T0.mul(builder, &T0);
T0 = T0.mul(builder, &T1);

let exp_outputs2 = fq12_exp_u64_circuit::<F, C, D>(builder, &exp_inputs);
assert!(exp_inputs.len() <= FQ12_EXP_U64_NUM_IO);
// TODO: fix build with `fq12_exp_u64_circuit::<... , FQ12_EXP_U64_NUM_IO>`.
assert_eq!(FQ12_EXP_U64_NUM_IO, 4);
let exp_outputs2 = fq12_exp_u64_circuit::<F, C, D, 4>(builder, &exp_inputs);
exp_outputs
.iter()
.zip(exp_outputs2.iter())
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![feature(generic_const_exprs)]

pub mod final_exp_native;
pub mod final_exp_target;
pub mod miller_loop_native;
Expand Down

0 comments on commit c2d9209

Please sign in to comment.