diff --git a/o1vm/src/pickles/mod.rs b/o1vm/src/pickles/mod.rs index 701bd402ef..4c02ef87c1 100644 --- a/o1vm/src/pickles/mod.rs +++ b/o1vm/src/pickles/mod.rs @@ -16,5 +16,21 @@ pub mod column_env; pub mod proof; pub mod prover; +/// Maximum degree of the constraints. +/// It does include the additional degree induced by the multiplication of the +/// selectors. +pub const MAXIMUM_DEGREE_CONSTRAINTS: u64 = 6; + +/// Degree of the quotient polynomial. We do evaluate all polynomials on d8 +/// (because of the value of [MAXIMUM_DEGREE_CONSTRAINTS]), and therefore, we do +/// have a degree 7 for the quotient polynomial. +/// Used to keep track of the number of chunks we do have when we commit to the +/// quotient polynomial. +pub const DEGREE_QUOTIENT_POLYNOMIAL: u64 = 7; + +/// Total number of constraints for all instructions, including the constraints +/// added for the selectors. +pub const TOTAL_NUMBER_OF_CONSTRAINTS: usize = 463; + #[cfg(test)] mod tests; diff --git a/o1vm/src/pickles/prover.rs b/o1vm/src/pickles/prover.rs index 11b89eac0b..b4788dda46 100644 --- a/o1vm/src/pickles/prover.rs +++ b/o1vm/src/pickles/prover.rs @@ -26,6 +26,7 @@ use rayon::iter::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterato use super::{ column_env::ColumnEnvironment, proof::{Proof, ProofInputs, WitnessColumns}, + DEGREE_QUOTIENT_POLYNOMIAL, }; use crate::{interpreters::mips::column::N_MIPS_SEL_COLS, E}; use thiserror::Error; @@ -257,7 +258,9 @@ where quotient }; - let _t_comm = srs.commit_non_hiding("ient_poly, 7); + let t_comm = srs.commit_non_hiding("ient_poly, DEGREE_QUOTIENT_POLYNOMIAL as usize); + + absorb_commitment(&mut fq_sponge, &t_comm); //////////////////////////////////////////////////////////////////////////// // Round 3: Evaluations at ζ and ζω @@ -303,6 +306,10 @@ where let mut fr_sponge = EFrSponge::new(G::sponge_params()); fr_sponge.absorb(&fq_sponge.digest()); + // Quotient poly evals + let quotient_zeta_eval = quotient_poly.evaluate(&zeta); + let quotient_zeta_omega_eval = quotient_poly.evaluate(&zeta_omega); + for (zeta_eval, zeta_omega_eval) in zeta_evaluations .scratch .iter() @@ -323,6 +330,8 @@ where fr_sponge.absorb(zeta_eval); fr_sponge.absorb(zeta_omega_eval); } + fr_sponge.absorb("ient_zeta_eval); + fr_sponge.absorb("ient_zeta_omega_eval); //////////////////////////////////////////////////////////////////////////// // Round 4: Opening proof w/o linearization polynomial @@ -333,6 +342,8 @@ where polynomials.push(polys.instruction_counter); polynomials.push(polys.error); polynomials.extend(polys.selector); + polynomials.push(quotient_poly); + let polynomials: Vec<_> = polynomials .iter() .map(|poly| { diff --git a/o1vm/src/pickles/tests.rs b/o1vm/src/pickles/tests.rs index 4fe2f479e9..cfe2f127c4 100644 --- a/o1vm/src/pickles/tests.rs +++ b/o1vm/src/pickles/tests.rs @@ -1,5 +1,8 @@ -use crate::interpreters::mips::{ - constraints as mips_constraints, interpreter, interpreter::InterpreterEnv, Instruction, +use crate::{ + interpreters::mips::{ + constraints as mips_constraints, interpreter, interpreter::InterpreterEnv, Instruction, + }, + pickles::{MAXIMUM_DEGREE_CONSTRAINTS, TOTAL_NUMBER_OF_CONSTRAINTS}, }; use interpreter::{ITypeInstruction, JTypeInstruction, RTypeInstruction}; use kimchi_msm::expr::E; @@ -28,12 +31,10 @@ fn test_regression_constraints_with_selectors() { constraints }; - // Total number of constraints - assert_eq!(constraints.len(), 463); + assert_eq!(constraints.len(), TOTAL_NUMBER_OF_CONSTRAINTS); - // Check highest degree let max_degree = constraints.iter().map(|c| c.degree(1, 0)).max().unwrap(); - assert_eq!(max_degree, 6); + assert_eq!(max_degree, MAXIMUM_DEGREE_CONSTRAINTS); } #[test]