From 70a4d77114fc8104a842ce259e3f075ad2e5841c Mon Sep 17 00:00:00 2001 From: arnaucube Date: Thu, 3 Oct 2024 11:22:33 +0200 Subject: [PATCH] rm .instances() since it's not needed --- examples/circom_full_flow.rs | 3 +- examples/external_inputs.rs | 4 +-- examples/multi_inputs.rs | 4 +-- examples/noir_full_flow.rs | 3 +- examples/noname_full_flow.rs | 3 +- examples/sha256.rs | 4 +-- folding-schemes/src/folding/hypernova/mod.rs | 35 ------------------- folding-schemes/src/folding/mod.rs | 4 ++- folding-schemes/src/folding/nova/mod.rs | 30 ++-------------- .../src/folding/protogalaxy/mod.rs | 13 ------- folding-schemes/src/lib.rs | 10 ------ 11 files changed, 15 insertions(+), 98 deletions(-) diff --git a/examples/circom_full_flow.rs b/examples/circom_full_flow.rs index 554ecd7b..dccf0d8e 100644 --- a/examples/circom_full_flow.rs +++ b/examples/circom_full_flow.rs @@ -89,7 +89,8 @@ fn main() { let mut nova = N::init(&nova_params, f_circuit.clone(), z_0).unwrap(); // prepare the Decider prover & verifier params - let (decider_pp, decider_vp) = D::preprocess(&mut rng, nova_params, nova.clone()).unwrap(); + let (decider_pp, decider_vp) = + D::preprocess(&mut rng, nova_params.clone(), nova.clone()).unwrap(); // run n steps of the folding iteration for (i, external_inputs_at_step) in external_inputs.iter().enumerate() { diff --git a/examples/external_inputs.rs b/examples/external_inputs.rs index a55982df..f4a6af1f 100644 --- a/examples/external_inputs.rs +++ b/examples/external_inputs.rs @@ -207,10 +207,8 @@ fn main() { folding_scheme.state() ); - let (running_instance, incoming_instance, cyclefold_instance) = folding_scheme.instances(); - println!("Run the Nova's IVC verifier"); - let ivc_proof = nova.ivc_proof(); + let ivc_proof = folding_scheme.ivc_proof(); N::verify( nova_params.1, // Nova's verifier params ivc_proof, diff --git a/examples/multi_inputs.rs b/examples/multi_inputs.rs index 9517f2ad..a337c894 100644 --- a/examples/multi_inputs.rs +++ b/examples/multi_inputs.rs @@ -154,10 +154,8 @@ fn main() { println!("Nova::prove_step {}: {:?}", i, start.elapsed()); } - let (running_instance, incoming_instance, cyclefold_instance) = folding_scheme.instances(); - println!("Run the Nova's IVC verifier"); - let ivc_proof = nova.ivc_proof(); + let ivc_proof = folding_scheme.ivc_proof(); N::verify( nova_params.1, // Nova's verifier params ivc_proof, diff --git a/examples/noir_full_flow.rs b/examples/noir_full_flow.rs index a4c7c894..64531098 100644 --- a/examples/noir_full_flow.rs +++ b/examples/noir_full_flow.rs @@ -79,7 +79,8 @@ fn main() { let mut nova = N::init(&nova_params, f_circuit.clone(), z_0).unwrap(); // prepare the Decider prover & verifier params - let (decider_pp, decider_vp) = D::preprocess(&mut rng, nova_params, nova.clone()).unwrap(); + let (decider_pp, decider_vp) = + D::preprocess(&mut rng, nova_params.clone(), nova.clone()).unwrap(); // run n steps of the folding iteration for i in 0..5 { diff --git a/examples/noname_full_flow.rs b/examples/noname_full_flow.rs index 996d6227..00dccbfb 100644 --- a/examples/noname_full_flow.rs +++ b/examples/noname_full_flow.rs @@ -89,7 +89,8 @@ fn main() { let mut nova = N::init(&nova_params, f_circuit.clone(), z_0).unwrap(); // prepare the Decider prover & verifier params - let (decider_pp, decider_vp) = D::preprocess(&mut rng, nova_params, nova.clone()).unwrap(); + let (decider_pp, decider_vp) = + D::preprocess(&mut rng, nova_params.clone(), nova.clone()).unwrap(); // run n steps of the folding iteration for (i, external_inputs_at_step) in external_inputs.iter().enumerate() { diff --git a/examples/sha256.rs b/examples/sha256.rs index de555e03..d974d650 100644 --- a/examples/sha256.rs +++ b/examples/sha256.rs @@ -138,10 +138,8 @@ fn main() { println!("Nova::prove_step {}: {:?}", i, start.elapsed()); } - let (running_instance, incoming_instance, cyclefold_instance) = folding_scheme.instances(); - println!("Run the Nova's IVC verifier"); - let ivc_proof = nova.ivc_proof(); + let ivc_proof = folding_scheme.ivc_proof(); N::verify( nova_params.1, // Nova's verifier params ivc_proof, diff --git a/folding-schemes/src/folding/hypernova/mod.rs b/folding-schemes/src/folding/hypernova/mod.rs index 76698a85..239f8691 100644 --- a/folding-schemes/src/folding/hypernova/mod.rs +++ b/folding-schemes/src/folding/hypernova/mod.rs @@ -991,20 +991,6 @@ where self.z_i.clone() } - fn instances( - &self, - ) -> ( - Self::RunningInstance, - Self::IncomingInstance, - Self::CFInstance, - ) { - ( - (self.U_i.clone(), self.W_i.clone()), - (self.u_i.clone(), self.w_i.clone()), - (self.cf_U_i.clone(), self.cf_W_i.clone()), - ) - } - fn ivc_proof(&self) -> Self::IVCProof { Self::IVCProof { i: self.i, @@ -1168,18 +1154,6 @@ mod tests { >( poseidon_config: PoseidonConfig, F_circuit: CubicFCircuit, - ) -> ( - HyperNova, CS1, CS2, 2, 3, H>, - ( - ProverParams, - VerifierParams, - ), - (LCCCS, Witness), - (CCCS, Witness), - ( - CycleFoldCommittedInstance, - CycleFoldWitness, - ), ) { let mut rng = ark_std::test_rng(); @@ -1239,14 +1213,5 @@ mod tests { ivc_proof, ) .unwrap(); - - let (running_instance, incoming_instance, cyclefold_instance) = hypernova.instances(); - ( - hypernova, - hypernova_params, - running_instance, - incoming_instance, - cyclefold_instance, - ) } } diff --git a/folding-schemes/src/folding/mod.rs b/folding-schemes/src/folding/mod.rs index e66a3994..369de725 100644 --- a/folding-schemes/src/folding/mod.rs +++ b/folding-schemes/src/folding/mod.rs @@ -25,8 +25,10 @@ pub mod tests { use crate::Error; use crate::FoldingScheme; + /// tests the IVC proofs and its serializers for the 3 implemented IVCs: Nova, HyperNova and + /// ProtoGalaxy. #[test] - fn test_serialize_ivc() { + fn test_serialize_ivc_nova_hypernova_protogalaxy() { let poseidon_config = poseidon_canonical_config::(); type FC = CubicFCircuit; let f_circuit = FC::new(()).unwrap(); diff --git a/folding-schemes/src/folding/nova/mod.rs b/folding-schemes/src/folding/nova/mod.rs index d1500c2c..9c99d1da 100644 --- a/folding-schemes/src/folding/nova/mod.rs +++ b/folding-schemes/src/folding/nova/mod.rs @@ -344,15 +344,6 @@ where CS2: CommitmentScheme, { fn check(&self) -> Result<(), ark_serialize::SerializationError> { - self.poseidon_config.full_rounds.check()?; - self.poseidon_config.partial_rounds.check()?; - self.poseidon_config.alpha.check()?; - self.poseidon_config.ark.check()?; - self.poseidon_config.mds.check()?; - self.poseidon_config.rate.check()?; - self.poseidon_config.capacity.check()?; - self.r1cs.check()?; - self.cf_r1cs.check()?; self.cs_vp.check()?; self.cf_cs_vp.check()?; Ok(()) @@ -370,7 +361,6 @@ where mut writer: W, compress: ark_serialize::Compress, ) -> Result<(), ark_serialize::SerializationError> { - self.cs_vp.serialize_with_mode(&mut writer, compress)?; self.cs_vp.serialize_with_mode(&mut writer, compress)?; self.cf_cs_vp.serialize_with_mode(&mut writer, compress) } @@ -411,13 +401,13 @@ where // to serialize them, saving significant space in the VerifierParams serialized size. // main circuit R1CS: - let f_circuit = FC::new(fcircuit_params).or(Err(SerializationError::InvalidData))?; + let f_circuit = FC::new(fcircuit_params).map_err(|_| SerializationError::InvalidData)?; let cs = ConstraintSystem::::new_ref(); let augmented_F_circuit = AugmentedFCircuit::::empty(&poseidon_config, f_circuit.clone()); augmented_F_circuit .generate_constraints(cs.clone()) - .or(Err(SerializationError::InvalidData))?; + .map_err(|_| SerializationError::InvalidData)?; cs.finalize(); let cs = cs.into_inner().ok_or(SerializationError::InvalidData)?; let r1cs = extract_r1cs::(&cs); @@ -427,7 +417,7 @@ where let cf_circuit = NovaCycleFoldCircuit::::empty(); cf_circuit .generate_constraints(cs2.clone()) - .or(Err(SerializationError::InvalidData))?; + .map_err(|_| SerializationError::InvalidData)?; cs2.finalize(); let cs2 = cs2.into_inner().ok_or(SerializationError::InvalidData)?; let cf_r1cs = extract_r1cs::(&cs2); @@ -933,20 +923,6 @@ where self.z_i.clone() } - fn instances( - &self, - ) -> ( - Self::RunningInstance, - Self::IncomingInstance, - Self::CFInstance, - ) { - ( - (self.U_i.clone(), self.W_i.clone()), - (self.u_i.clone(), self.w_i.clone()), - (self.cf_U_i.clone(), self.cf_W_i.clone()), - ) - } - fn ivc_proof(&self) -> Self::IVCProof { Self::IVCProof { i: self.i, diff --git a/folding-schemes/src/folding/protogalaxy/mod.rs b/folding-schemes/src/folding/protogalaxy/mod.rs index d12c9041..fcbd3cd1 100644 --- a/folding-schemes/src/folding/protogalaxy/mod.rs +++ b/folding-schemes/src/folding/protogalaxy/mod.rs @@ -917,19 +917,6 @@ where fn state(&self) -> Vec { self.z_i.clone() } - fn instances( - &self, - ) -> ( - Self::RunningInstance, - Self::IncomingInstance, - Self::CFInstance, - ) { - ( - (self.U_i.clone(), self.W_i.clone()), - (self.u_i.clone(), self.w_i.clone()), - (self.cf_U_i.clone(), self.cf_W_i.clone()), - ) - } fn ivc_proof(&self) -> Self::IVCProof { Self::IVCProof { diff --git a/folding-schemes/src/lib.rs b/folding-schemes/src/lib.rs index 6909cd8b..e959dd2e 100644 --- a/folding-schemes/src/lib.rs +++ b/folding-schemes/src/lib.rs @@ -154,16 +154,6 @@ where /// returns the state at the current step fn state(&self) -> Vec; - /// returns the instances at the current step, in the following order: - /// (running_instance, incoming_instance, cyclefold_instance) - fn instances( - &self, - ) -> ( - Self::RunningInstance, - Self::IncomingInstance, - Self::CFInstance, - ); - /// returns the last IVC state proof, which can be verified in the `verify` method fn ivc_proof(&self) -> Self::IVCProof;