Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/supernova/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,16 @@ impl<'a, G: Group, SC: EnforcingStepCircuit<G::Base>> SuperNovaAugmentedCircuit<
) -> Result<Vec<AllocatedRelaxedR1CSInstance<G>>, 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(
Expand All @@ -276,6 +279,7 @@ impl<'a, G: Group, SC: EnforcingStepCircuit<G::Base>> SuperNovaAugmentedCircuit<
self.params.limb_width,
self.params.n_limbs,
)?;

(0..num_augmented_circuits)
.map(|i| {
let i_alloc = alloc_const(
Expand All @@ -287,15 +291,10 @@ impl<'a, G: Group, SC: EnforcingStepCircuit<G::Base>> 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,
)
})
Expand Down
8 changes: 4 additions & 4 deletions src/supernova/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ fn test_recursive_circuit() {
let ro_consts1: ROConstantsCircuit<G2> = PoseidonConstantsCircuit::default();
let ro_consts2: ROConstantsCircuit<G1> = PoseidonConstantsCircuit::default();

test_recursive_circuit_with::<G1, G2>(&params1, &params2, ro_consts1, ro_consts2, 9835, 12028);
test_recursive_circuit_with::<G1, G2>(&params1, &params2, ro_consts1, ro_consts2, 9835, 12026);
}

fn test_pp_digest_with<G1, G2, T1, T2, NC>(non_uniform_circuit: &NC, expected: &str)
Expand Down Expand Up @@ -701,7 +701,7 @@ fn test_supernova_pp_digest() {

test_pp_digest_with::<G1, G2, _, _, _>(
&test_rom,
"232c6c75db09f58a6a5a67311422a937239f67233902f3804ed3484ae9cd2b03",
"4009cc520dac06aaecbe5e9ae9fd0d7a480f6c9bd4bd7c6a858afda055db0b00",
);

let rom = vec![
Expand All @@ -716,7 +716,7 @@ fn test_supernova_pp_digest() {

test_pp_digest_with::<bn256::Point, grumpkin::Point, _, _, _>(
&test_rom_grumpkin,
"5f1f389cffbb535fc6e7114a25ab4d0eed5457e98eb95c8a4720e48b83fc8701",
"057219a08592f69fe96c7bba05f89c5f840edf34d55ec38b51b03fe2fb3b4e00",
);

let rom = vec![
Expand All @@ -731,7 +731,7 @@ fn test_supernova_pp_digest() {

test_pp_digest_with::<secp256k1::Point, secq256k1::Point, _, _, _>(
&test_rom_secp,
"9ee20885d37d921673140bd9bfd6af06408b6d380a1e06f720990ea66d0f1e01",
"305a387d90fc600b8c715f49abf9042b775932b426d8c236c8c9ee5e36259e03",
);
}

Expand Down