From 0dc08a97700137073b806a290cd9b4940e6d8ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= Date: Mon, 5 Feb 2024 15:04:16 -0500 Subject: [PATCH] docs: Improve code readability and testing robustness - Improved readability of CurveCycleEquipped function comment in traits module by adding backticks around function name. --- benches/common/supernova/mod.rs | 2 +- src/circuit.rs | 14 ++++---------- src/lib.rs | 20 +++++--------------- src/supernova/mod.rs | 7 ++----- src/supernova/snark.rs | 2 +- src/supernova/test.rs | 23 +++++++++++------------ src/traits/mod.rs | 4 ++-- 7 files changed, 26 insertions(+), 46 deletions(-) diff --git a/benches/common/supernova/mod.rs b/benches/common/supernova/mod.rs index 6deee3622..8ba58dd7f 100644 --- a/benches/common/supernova/mod.rs +++ b/benches/common/supernova/mod.rs @@ -7,7 +7,7 @@ pub mod targets; use anyhow::anyhow; use arecibo::{ supernova::{NonUniformCircuit, StepCircuit, TrivialTestCircuit}, - traits::{CurveCycleEquipped, Engine, Dual}, + traits::{CurveCycleEquipped, Dual, Engine}, }; use bellpepper_core::{num::AllocatedNum, ConstraintSystem, SynthesisError}; use core::marker::PhantomData; diff --git a/src/circuit.rs b/src/circuit.rs index 7a051a763..ebb1c2fe1 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -392,11 +392,8 @@ mod tests { { let tc1 = TrivialCircuit::default(); // Initialize the shape and ck for the primary - let circuit1: NovaAugmentedCircuit< - '_, - Dual, - TrivialCircuit< as Engine>::Base>, - > = NovaAugmentedCircuit::new(primary_params, None, &tc1, ro_consts1.clone()); + let circuit1: NovaAugmentedCircuit<'_, Dual, TrivialCircuit< as Engine>::Base>> = + NovaAugmentedCircuit::new(primary_params, None, &tc1, ro_consts1.clone()); let mut cs: TestShapeCS = TestShapeCS::new(); let _ = circuit1.synthesize(&mut cs); let (shape1, ck1) = cs.r1cs_shape_and_key(&*default_ck_hint()); @@ -425,11 +422,8 @@ mod tests { None, None, ); - let circuit1: NovaAugmentedCircuit< - '_, - Dual, - TrivialCircuit< as Engine>::Base>, - > = NovaAugmentedCircuit::new(primary_params, Some(inputs1), &tc1, ro_consts1); + let circuit1: NovaAugmentedCircuit<'_, Dual, TrivialCircuit< as Engine>::Base>> = + NovaAugmentedCircuit::new(primary_params, Some(inputs1), &tc1, ro_consts1); let _ = circuit1.synthesize(&mut cs1); let (inst1, witness1) = cs1.r1cs_instance_and_witness(&shape1, &ck1).unwrap(); // Make sure that this is satisfiable diff --git a/src/lib.rs b/src/lib.rs index 94abee6d3..d00386fc1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -451,8 +451,7 @@ where let l_w_secondary = w_secondary; let l_u_secondary = u_secondary; let r_W_secondary = RelaxedR1CSWitness::>::default(r1cs_secondary); - let r_U_secondary = - RelaxedR1CSInstance::>::default(&pp.ck_secondary, r1cs_secondary); + let r_U_secondary = RelaxedR1CSInstance::>::default(&pp.ck_secondary, r1cs_secondary); assert!( !(zi_primary.len() != pp.F_arity_primary || zi_secondary.len() != pp.F_arity_secondary), @@ -506,10 +505,7 @@ where /// Create a new `RecursiveSNARK` (or updates the provided `RecursiveSNARK`) /// by executing a step of the incremental computation #[tracing::instrument(skip_all, name = "nova::RecursiveSNARK::prove_step")] - pub fn prove_step< - C1: StepCircuit, - C2: StepCircuit< as Engine>::Scalar>, - >( + pub fn prove_step, C2: StepCircuit< as Engine>::Scalar>>( &mut self, pp: &PublicParams, c_primary: &C1, @@ -552,9 +548,7 @@ where Some(self.zi_primary.clone()), Some(r_U_secondary_i), Some(l_u_secondary_i), - Some(Commitment::>::decompress( - &nifs_secondary.comm_T, - )?), + Some(Commitment::>::decompress(&nifs_secondary.comm_T)?), ); let circuit_primary: NovaAugmentedCircuit<'_, Dual, C1> = NovaAugmentedCircuit::new( @@ -991,8 +985,7 @@ pub fn circuit_digest>( let augmented_circuit_params = NovaAugmentedCircuitParams::new(BN_LIMB_WIDTH, BN_N_LIMBS, true); // ro_consts_circuit are parameterized by G2 because the type alias uses G2::Base = G1::Scalar - let ro_consts_circuit: ROConstantsCircuit> = - ROConstantsCircuit::>::default(); + let ro_consts_circuit: ROConstantsCircuit> = ROConstantsCircuit::>::default(); // Initialize ck for the primary let augmented_circuit: NovaAugmentedCircuit<'_, Dual, C> = @@ -1638,10 +1631,7 @@ mod tests { let (zn_primary, zn_secondary) = res.unwrap(); assert_eq!(zn_primary, vec![::Scalar::ONE]); - assert_eq!( - zn_secondary, - vec![ as Engine>::Scalar::from(5u64)] - ); + assert_eq!(zn_secondary, vec![ as Engine>::Scalar::from(5u64)]); } #[test] diff --git a/src/supernova/mod.rs b/src/supernova/mod.rs index c2d702656..d3dcd0475 100644 --- a/src/supernova/mod.rs +++ b/src/supernova/mod.rs @@ -14,7 +14,7 @@ use crate::{ scalar_as_base, traits::{ commitment::{CommitmentEngineTrait, CommitmentTrait}, - AbsorbInROTrait, CurveCycleEquipped, Engine, ROConstants, ROConstantsCircuit, ROTrait, Dual, + AbsorbInROTrait, CurveCycleEquipped, Dual, Engine, ROConstants, ROConstantsCircuit, ROTrait, }, Commitment, CommitmentKey, R1CSWithArity, }; @@ -717,10 +717,7 @@ where /// executing a step of the incremental computation #[allow(clippy::too_many_arguments)] #[tracing::instrument(skip_all, name = "supernova::RecursiveSNARK::prove_step")] - pub fn prove_step< - C1: StepCircuit, - C2: StepCircuit< as Engine>::Scalar>, - >( + pub fn prove_step, C2: StepCircuit< as Engine>::Scalar>>( &mut self, pp: &PublicParams, c_primary: &C1, diff --git a/src/supernova/snark.rs b/src/supernova/snark.rs index c32babe0f..72b3c62cb 100644 --- a/src/supernova/snark.rs +++ b/src/supernova/snark.rs @@ -6,7 +6,7 @@ use crate::{ r1cs::{R1CSInstance, RelaxedR1CSWitness}, traits::{ snark::{BatchedRelaxedR1CSSNARKTrait, RelaxedR1CSSNARKTrait}, - AbsorbInROTrait, CurveCycleEquipped, Engine, ROTrait, Dual, + AbsorbInROTrait, CurveCycleEquipped, Dual, Engine, ROTrait, }, }; use crate::{errors::NovaError, scalar_as_base, RelaxedR1CSInstance, NIFS}; diff --git a/src/supernova/test.rs b/src/supernova/test.rs index c0d8e3939..6d43ef1e5 100644 --- a/src/supernova/test.rs +++ b/src/supernova/test.rs @@ -496,18 +496,17 @@ fn test_recursive_circuit_with( let zero1 = < as Engine>::Base as Field>::ZERO; let z0 = vec![zero1; arity1]; let mut cs1 = SatisfyingAssignment::::new(); - let inputs1: SuperNovaAugmentedCircuitInputs<'_, Dual> = - SuperNovaAugmentedCircuitInputs::new( - scalar_as_base::(zero1), // pass zero for testing - zero1, - &z0, - None, - None, - None, - None, - Some(zero1), - zero1, - ); + let inputs1: SuperNovaAugmentedCircuitInputs<'_, Dual> = SuperNovaAugmentedCircuitInputs::new( + scalar_as_base::(zero1), // pass zero for testing + zero1, + &z0, + None, + None, + None, + None, + Some(zero1), + zero1, + ); let step_circuit = TrivialTestCircuit::default(); let circuit1: SuperNovaAugmentedCircuit< '_, diff --git a/src/traits/mod.rs b/src/traits/mod.rs index 8f2c46653..1786f734f 100644 --- a/src/traits/mod.rs +++ b/src/traits/mod.rs @@ -57,11 +57,11 @@ pub trait Engine: Clone + Copy + Debug + Send + Sync + Sized + Eq + PartialEq { /// This is a convenience trait to pair engines which fields are in a curve cycle relationship pub trait CurveCycleEquipped: Engine { - /// The secondary Engine of `Self` + /// The secondary `Engine` of `Self` type Secondary: Engine::Scalar, Scalar = ::Base>; } -/// Convenience projection to the Secondary Engine of a CurveCycleEquipped +/// Convenience projection to the secondary `Engine` of a `CurveCycleEquipped` pub type Dual = ::Secondary; /// A helper trait to absorb different objects in RO