diff --git a/poseidon2-starky/benches/poseidon2_starky.rs b/poseidon2-starky/benches/poseidon2_starky.rs index 0a66f18..1af2378 100644 --- a/poseidon2-starky/benches/poseidon2_starky.rs +++ b/poseidon2-starky/benches/poseidon2_starky.rs @@ -36,7 +36,7 @@ fn bench_horizen_poseidon2_starky(c: &mut Criterion) { b.iter_batched( || trace_poly_values.clone(), |trace_poly_values| { - prove::(stark, &config, trace_poly_values, [], &mut timing).unwrap(); + prove::(stark, &config, trace_poly_values, &[], &mut timing).unwrap(); }, criterion::BatchSize::SmallInput, ); diff --git a/poseidon2-starky/benches/poseidon2_starky_plonky2.rs b/poseidon2-starky/benches/poseidon2_starky_plonky2.rs index 5a97be4..e519f32 100644 --- a/poseidon2-starky/benches/poseidon2_starky_plonky2.rs +++ b/poseidon2-starky/benches/poseidon2_starky_plonky2.rs @@ -36,7 +36,7 @@ fn bench_plonky2_poseidon2_starky(c: &mut Criterion) { b.iter_batched( || trace_poly_values.clone(), |trace_poly_values| { - prove::(stark, &config, trace_poly_values, [], &mut timing).unwrap(); + prove::(stark, &config, trace_poly_values, &[], &mut timing).unwrap(); }, criterion::BatchSize::SmallInput, ); diff --git a/poseidon2-starky/src/horizen/stark.rs b/poseidon2-starky/src/horizen/stark.rs index 3645c60..6f618dd 100644 --- a/poseidon2-starky/src/horizen/stark.rs +++ b/poseidon2-starky/src/horizen/stark.rs @@ -10,10 +10,11 @@ use plonky2::field::packed::PackedField; use plonky2::field::polynomial::PolynomialValues; use plonky2::field::types::Field; use plonky2::hash::hash_types::RichField; +use plonky2::iop::ext_target::ExtensionTarget; use plonky2::plonk::circuit_builder::CircuitBuilder; use starky::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer}; +use starky::evaluation_frame::{StarkEvaluationFrame, StarkFrame}; use starky::stark::Stark; -use starky::vars::{StarkEvaluationTargets, StarkEvaluationVars}; use std::marker::PhantomData; use zkhash::fields::goldilocks::FpGoldiLocks; use zkhash::poseidon2::poseidon2_instance_goldilocks::{MAT_DIAG8_M_1, RC8}; @@ -149,19 +150,26 @@ pub struct Poseidon2Stark { pub _f: PhantomData, } +const COLUMNS: usize = NUM_COLS; +const PUBLIC_INPUTS: usize = 0; + impl, const D: usize> Stark for Poseidon2Stark { - const COLUMNS: usize = NUM_COLS; - const PUBLIC_INPUTS: usize = 0; + type EvaluationFrame = StarkFrame + where + FE: FieldExtension, + P: PackedField; + type EvaluationFrameTarget = + StarkFrame, ExtensionTarget, COLUMNS, PUBLIC_INPUTS>; fn eval_packed_generic( &self, - vars: StarkEvaluationVars, + vars: &Self::EvaluationFrame, yield_constr: &mut ConstraintConsumer

, ) where FE: FieldExtension, P: PackedField, { - let lv = vars.local_values; + let lv = vars.get_local_values(); let mut state = matmul_external8_constraints(lv[0..STATE_SIZE].try_into().unwrap()); // first full rounds @@ -219,7 +227,7 @@ impl, const D: usize> Stark for Poseidon2Star fn eval_ext_circuit( &self, _builder: &mut CircuitBuilder, - _vars: StarkEvaluationTargets, + _vars: &Self::EvaluationFrameTarget, _yield_constr: &mut RecursiveConstraintConsumer, ) { unimplemented!() @@ -274,7 +282,7 @@ mod tests { stark, &config, trace_poly_values, - [], + &[], &mut TimingTree::default(), )?; verify_stark_proof(stark, proof, &config) diff --git a/poseidon2-starky/src/plonky2/generation.rs b/poseidon2-starky/src/plonky2/generation.rs index 191e9ff..99b9d74 100644 --- a/poseidon2-starky/src/plonky2/generation.rs +++ b/poseidon2-starky/src/plonky2/generation.rs @@ -145,7 +145,7 @@ pub fn generate_poseidon2_trace(step_rows: &Vec>) -> [Vec>(); let dummy_rows = vec![Row { preimage: preimage.try_into().expect("can't fail"), diff --git a/poseidon2-starky/src/plonky2/stark.rs b/poseidon2-starky/src/plonky2/stark.rs index f504043..8d14156 100644 --- a/poseidon2-starky/src/plonky2/stark.rs +++ b/poseidon2-starky/src/plonky2/stark.rs @@ -9,10 +9,11 @@ use plonky2::field::polynomial::PolynomialValues; use plonky2::field::types::Field; use plonky2::hash::hash_types::RichField; use plonky2::hash::poseidon2::Poseidon2; +use plonky2::iop::ext_target::ExtensionTarget; use plonky2::plonk::circuit_builder::CircuitBuilder; use starky::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer}; +use starky::evaluation_frame::{StarkEvaluationFrame, StarkFrame}; use starky::stark::Stark; -use starky::vars::{StarkEvaluationTargets, StarkEvaluationVars}; use std::fmt::Display; use std::marker::PhantomData; @@ -199,22 +200,30 @@ impl Display for Poseidon2_12Stark { } } +const COLUMNS: usize = NUM_COLS; +const PUBLIC_INPUTS: usize = 0; + impl, const D: usize> Stark for Poseidon2_12Stark { - const COLUMNS: usize = NUM_COLS; - const PUBLIC_INPUTS: usize = 0; + type EvaluationFrame = StarkFrame + where + FE: FieldExtension, + P: PackedField; + type EvaluationFrameTarget = + StarkFrame, ExtensionTarget, COLUMNS, PUBLIC_INPUTS>; fn eval_packed_generic( &self, - vars: StarkEvaluationVars, + vars: &Self::EvaluationFrame, yield_constr: &mut ConstraintConsumer

, ) where FE: FieldExtension, P: PackedField, { - let lv = vars.local_values; + let lv = vars.get_local_values(); // row can be execution or padding. yield_constr.constraint(lv[COL_IS_EXE] * (lv[COL_IS_EXE] - P::ONES)); + #[allow(clippy::range_plus_one)] let mut state: [P; STATE_SIZE] = matmul_external12_constraints( lv[COL_INPUT_START..(COL_INPUT_START + STATE_SIZE)] .try_into() @@ -273,7 +282,7 @@ impl, const D: usize> Stark for Poseidon2_12S fn eval_ext_circuit( &self, _builder: &mut CircuitBuilder, - _vars: StarkEvaluationTargets, + _vars: &Self::EvaluationFrameTarget, _yield_constr: &mut RecursiveConstraintConsumer, ) { unimplemented!() @@ -328,7 +337,7 @@ mod tests { stark, &config, trace_poly_values, - [], + &[], &mut TimingTree::default(), )?; verify_stark_proof(stark, proof, &config)