diff --git a/src/supernova/circuit.rs b/src/supernova/circuit.rs index 21eecd4e..6716d19b 100644 --- a/src/supernova/circuit.rs +++ b/src/supernova/circuit.rs @@ -261,13 +261,16 @@ impl<'a, G: Group, SC: EnforcingStepCircuit> SuperNovaAugmentedCircuit< ) -> Result>, SynthesisError> { let mut cs = cs.namespace(|| "alloc U_i default"); + // Allocate a default relaxed r1cs instance + let default = AllocatedRelaxedR1CSInstance::default( + cs.namespace(|| "Allocate primary U_default".to_string()), + self.params.limb_width, + self.params.n_limbs, + )?; + // The primary circuit just initialize single AllocatedRelaxedR1CSInstance let U_default = if self.params.is_primary_circuit { - vec![AllocatedRelaxedR1CSInstance::default( - cs.namespace(|| "Allocate primary U_default".to_string()), - self.params.limb_width, - self.params.n_limbs, - )?] + vec![default] } else { // The secondary circuit convert the incoming R1CS instance on index which match last_augmented_circuit_index let incoming_r1cs = AllocatedRelaxedR1CSInstance::from_r1cs_instance( @@ -276,6 +279,7 @@ impl<'a, G: Group, SC: EnforcingStepCircuit> SuperNovaAugmentedCircuit< self.params.limb_width, self.params.n_limbs, )?; + (0..num_augmented_circuits) .map(|i| { let i_alloc = alloc_const( @@ -287,15 +291,10 @@ impl<'a, G: Group, SC: EnforcingStepCircuit> SuperNovaAugmentedCircuit< &i_alloc, last_augmented_circuit_index_checked, )?); - let default = &AllocatedRelaxedR1CSInstance::default( - cs.namespace(|| format!("Allocate U_default {:?}", i)), - self.params.limb_width, - self.params.n_limbs, - )?; conditionally_select_alloc_relaxed_r1cs( cs.namespace(|| format!("select on index namespace {:?}", i)), &incoming_r1cs, - default, + &default, &equal_bit, ) }) diff --git a/src/supernova/test.rs b/src/supernova/test.rs index 93c46747..7c367fea 100644 --- a/src/supernova/test.rs +++ b/src/supernova/test.rs @@ -655,7 +655,7 @@ fn test_recursive_circuit() { let ro_consts1: ROConstantsCircuit = PoseidonConstantsCircuit::default(); let ro_consts2: ROConstantsCircuit = PoseidonConstantsCircuit::default(); - test_recursive_circuit_with::(¶ms1, ¶ms2, ro_consts1, ro_consts2, 9835, 12028); + test_recursive_circuit_with::(¶ms1, ¶ms2, ro_consts1, ro_consts2, 9835, 12026); } fn test_pp_digest_with(non_uniform_circuit: &NC, expected: &str) @@ -701,7 +701,7 @@ fn test_supernova_pp_digest() { test_pp_digest_with::( &test_rom, - "232c6c75db09f58a6a5a67311422a937239f67233902f3804ed3484ae9cd2b03", + "4009cc520dac06aaecbe5e9ae9fd0d7a480f6c9bd4bd7c6a858afda055db0b00", ); let rom = vec![ @@ -716,7 +716,7 @@ fn test_supernova_pp_digest() { test_pp_digest_with::( &test_rom_grumpkin, - "5f1f389cffbb535fc6e7114a25ab4d0eed5457e98eb95c8a4720e48b83fc8701", + "057219a08592f69fe96c7bba05f89c5f840edf34d55ec38b51b03fe2fb3b4e00", ); let rom = vec![ @@ -731,7 +731,7 @@ fn test_supernova_pp_digest() { test_pp_digest_with::( &test_rom_secp, - "9ee20885d37d921673140bd9bfd6af06408b6d380a1e06f720990ea66d0f1e01", + "305a387d90fc600b8c715f49abf9042b775932b426d8c236c8c9ee5e36259e03", ); }