diff --git a/o1vm/src/pickles/proof.rs b/o1vm/src/pickles/proof.rs index 099484cc25..e3548cdbfe 100644 --- a/o1vm/src/pickles/proof.rs +++ b/o1vm/src/pickles/proof.rs @@ -1,10 +1,10 @@ use kimchi::{curve::KimchiCurve, proof::PointEvaluations}; use poly_commitment::{ipa::OpeningProof, PolyComm}; -use crate::interpreters::mips::column::N_MIPS_SEL_COLS; +use crate::interpreters::mips::{column::N_MIPS_SEL_COLS, witness::SCRATCH_SIZE}; pub struct WitnessColumns { - pub scratch: [G; crate::interpreters::mips::witness::SCRATCH_SIZE], + pub scratch: [G; SCRATCH_SIZE], pub instruction_counter: G, pub error: G, pub selector: S, diff --git a/o1vm/src/pickles/prover.rs b/o1vm/src/pickles/prover.rs index 35870df3cf..2f40787546 100644 --- a/o1vm/src/pickles/prover.rs +++ b/o1vm/src/pickles/prover.rs @@ -1,6 +1,5 @@ use std::array; -use ark_ec::{AffineRepr, Group}; use ark_ff::{One, PrimeField, Zero}; use ark_poly::{univariate::DensePolynomial, Evaluations, Polynomial, Radix2EvaluationDomain as D}; use kimchi::{ @@ -65,7 +64,7 @@ pub fn prove< rng: &mut RNG, ) -> Result, ProverError> where - ::BaseField: PrimeField, + G::BaseField: PrimeField, RNG: RngCore + CryptoRng, { let num_chunks = 1; @@ -76,11 +75,13 @@ where //////////////////////////////////////////////////////////////////////////// // Round 1: Creating and absorbing column commitments //////////////////////////////////////////////////////////////////////////// - type F = DensePolynomial<<::Group as Group>::ScalarField>; debug!("Prover: interpolating all columns, including the selectors"); let ProofInputs { evaluations } = inputs; - let polys: WitnessColumns, [F; N_MIPS_SEL_COLS]> = { + let polys: WitnessColumns< + DensePolynomial, + [DensePolynomial; N_MIPS_SEL_COLS], + > = { let WitnessColumns { scratch, instruction_counter, @@ -91,18 +92,17 @@ where let domain_size = domain.d1.size as usize; // Build the selectors - let selector: [Vec<<::Group as Group>::ScalarField>; N_MIPS_SEL_COLS] = - array::from_fn(|i| { - let mut s_i = Vec::with_capacity(domain_size); - for s in &selector { - s_i.push(if G::ScalarField::from(i as u64) == *s { - G::ScalarField::one() - } else { - G::ScalarField::zero() - }) - } - s_i - }); + let selector: [Vec; N_MIPS_SEL_COLS] = array::from_fn(|i| { + let mut s_i = Vec::with_capacity(domain_size); + for s in &selector { + s_i.push(if G::ScalarField::from(i as u64) == *s { + G::ScalarField::one() + } else { + G::ScalarField::zero() + }) + } + s_i + }); let eval_col = |evals: Vec| { Evaluations::>::from_vec_and_domain(evals, domain.d1) @@ -254,7 +254,6 @@ where // We compute the polynomial t(X) by dividing the constraints polynomial // by the vanishing polynomial, i.e. Z_H(X). let (quotient, rem) = expr_evaluation_interpolated - // FIXME: Should this be d8? .divide_by_vanishing_poly(domain.d1) .unwrap_or_else(fail_final_q_division); // As the constraints must be verified on H, the rest of the division @@ -307,16 +306,12 @@ where } }; // All evaluations at ζ - let zeta_evaluations: WitnessColumns< - <::Group as Group>::ScalarField, - [<::Group as Group>::ScalarField; N_MIPS_SEL_COLS], - > = evals(&zeta); + let zeta_evaluations: WitnessColumns = + evals(&zeta); // All evaluations at ζω - let zeta_omega_evaluations: WitnessColumns< - <::Group as Group>::ScalarField, - [<::Group as Group>::ScalarField; N_MIPS_SEL_COLS], - > = evals(&zeta_omega); + let zeta_omega_evaluations: WitnessColumns = + evals(&zeta_omega); let chunked_quotient = quotient_poly .to_chunked_polynomial(DEGREE_QUOTIENT_POLYNOMIAL as usize, domain.d1.size as usize); diff --git a/o1vm/src/pickles/tests.rs b/o1vm/src/pickles/tests.rs index 422f10bc13..0260e06587 100644 --- a/o1vm/src/pickles/tests.rs +++ b/o1vm/src/pickles/tests.rs @@ -24,6 +24,7 @@ use mina_poseidon::{ use o1_utils::tests::make_test_rng; use poly_commitment::SRS; use strum::{EnumCount, IntoEnumIterator}; + #[test] fn test_regression_constraints_with_selectors() { let constraints = { @@ -75,6 +76,7 @@ fn test_regression_selectors_for_instructions() { fn zero_to_n_minus_one(n: usize) -> Vec { (0..n).map(|i| Fq::from((i) as u64)).collect() } + #[test] fn test_small_circuit() { let domain = EvaluationDomains::::create(8).unwrap(); @@ -111,8 +113,7 @@ fn test_small_circuit() { .unwrap(); let instant_before_verification = Instant::now(); - let verif = - verify::(domain, &srs, &vec![expr.clone()], &proof); + let verif = verify::(domain, &srs, &[expr.clone()], &proof); let instant_after_verification = Instant::now(); debug!( "Verification took: {} ms", diff --git a/o1vm/src/pickles/verifier.rs b/o1vm/src/pickles/verifier.rs index 1c362fdff4..9057a89802 100644 --- a/o1vm/src/pickles/verifier.rs +++ b/o1vm/src/pickles/verifier.rs @@ -1,4 +1,4 @@ -use ark_ec::{AffineRepr, Group}; +use ark_ec::AffineRepr; use ark_ff::{Field, One, PrimeField, Zero}; use rand::thread_rng; @@ -31,23 +31,20 @@ use crate::{interpreters::mips::column::N_MIPS_SEL_COLS, E}; use kimchi_msm::columns::Column; type CommitmentColumns = WitnessColumns, [PolyComm; N_MIPS_SEL_COLS]>; -type EvaluationColumns = WitnessColumns< - <::Group as Group>::ScalarField, - [<::Group as Group>::ScalarField; N_MIPS_SEL_COLS], ->; +type EvaluationColumns = WitnessColumns; struct ColumnEval<'a, G: AffineRepr> { commitment: &'a CommitmentColumns, - zeta_eval: &'a EvaluationColumns, - zeta_omega_eval: &'a EvaluationColumns, + zeta_eval: &'a EvaluationColumns, + zeta_omega_eval: &'a EvaluationColumns, } -impl ColumnEvaluations<::ScalarField> for ColumnEval<'_, G> { +impl ColumnEvaluations for ColumnEval<'_, G> { type Column = Column; fn evaluate( &self, col: Self::Column, - ) -> Result::ScalarField>, ExprError> { + ) -> Result, ExprError> { let ColumnEval { commitment: _, zeta_eval, @@ -72,8 +69,7 @@ pub fn verify< >( domain: EvaluationDomains, srs: & as OpenProof>::SRS, - //FIXME: change vec to array - constraints: &Vec>, + constraints: &[E], proof: &Proof, ) -> bool where @@ -180,7 +176,7 @@ where }; let combined_expr = - Expr::combine_constraints(0..(constraints.len() as u32), constraints.clone()); + Expr::combine_constraints(0..(constraints.len() as u32), constraints.to_vec()); let numerator_zeta = PolishToken::evaluate( combined_expr.to_polish().as_slice(),