diff --git a/ivc/src/ivc/mod.rs b/ivc/src/ivc/mod.rs index ff00aaa1df..4dbd8e7f84 100644 --- a/ivc/src/ivc/mod.rs +++ b/ivc/src/ivc/mod.rs @@ -10,8 +10,16 @@ pub const LIMB_BITSIZE_XLARGE: usize = 150; /// The biggest packing format, 2 limbs. pub const N_LIMBS_XLARGE: usize = 2; +/// Number of additional columns that a reduction to degree 2 will +/// require. +// This value has been generated using a fake folding config like in +// [folding::tests::test_quadraticization] +pub const N_ADDITIONAL_WIT_COL_QUAD: usize = 48; + #[cfg(test)] mod tests { + use std::collections::HashMap; + use crate::{ ivc::{ columns::{IVCColumn, IVC_NB_TOTAL_FIXED_SELECTORS, N_BLOCKS}, @@ -20,7 +28,10 @@ mod tests { lookups::IVCLookupTable, }, poseidon_8_56_5_3_2::{ - bn254::{PoseidonBN254Parameters, STATE_SIZE as IVC_POSEIDON_STATE_SIZE}, + bn254::{ + PoseidonBN254Parameters, NB_CONSTRAINTS as IVC_POSEIDON_NB_CONSTRAINTS, + STATE_SIZE as IVC_POSEIDON_STATE_SIZE, + }, interpreter::PoseidonParams, }, }; @@ -39,8 +50,13 @@ mod tests { // Total number of columns in IVC and Application circuits. pub const TEST_N_COL_TOTAL: usize = IVCColumn::N_COL + 50; - // Absolutely no idea. - pub const TEST_N_CHALS: usize = 200; + + // Number of challenges in the IVC circuit. + // It is the maximum number of constraints per row. + // We do suppose it is Poseidon which has the highest number of constraints + // for now. + pub const TEST_N_CHALS: usize = IVC_POSEIDON_NB_CONSTRAINTS; + pub const TEST_DOMAIN_SIZE: usize = 1 << 15; type IVCWitnessBuilderEnvRaw = WitnessBuilderEnv< @@ -134,6 +150,30 @@ mod tests { ); } + #[test] + fn test_regression_ivc_constraints() { + let mut constraint_env = ConstraintBuilderEnv::>::create(); + constrain_ivc::(&mut constraint_env); + let constraints = constraint_env.get_relation_constraints(); + + let mut constraints_degrees = HashMap::new(); + + // Regression testing for the number of constraints and their degree + { + // Hashes are not included for now. + assert_eq!(constraints.len(), 55); + constraints.iter().for_each(|c| { + let degree = c.degree(1, 0); + *constraints_degrees.entry(degree).or_insert(0) += 1; + }); + + assert_eq!(constraints_degrees.get(&1), None); + assert_eq!(constraints_degrees.get(&2), Some(&29)); + assert_eq!(constraints_degrees.get(&3), Some(&5)); + assert_eq!(constraints_degrees.get(&4), Some(&21)); + } + } + #[test] fn test_completeness_ivc() { let mut rng = o1_utils::tests::make_test_rng(None);