From f98d974c8eed6c9668e5434d849d39630f0d03af Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Tue, 18 Jun 2024 18:53:52 +0200 Subject: [PATCH 1/2] IVC/Test: use the correct number of challenges for the IVC circuit --- ivc/src/ivc/mod.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ivc/src/ivc/mod.rs b/ivc/src/ivc/mod.rs index ff00aaa1df..3d35c719b7 100644 --- a/ivc/src/ivc/mod.rs +++ b/ivc/src/ivc/mod.rs @@ -20,7 +20,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 +42,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< From b038f44e88f0be0aa7d610a64bdee6601834537f Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Tue, 18 Jun 2024 19:26:25 +0200 Subject: [PATCH 2/2] IVC: add regression tests regarding constraints in the IVC circuit --- ivc/src/ivc/mod.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/ivc/src/ivc/mod.rs b/ivc/src/ivc/mod.rs index 3d35c719b7..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}, @@ -142,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);