diff --git a/src/gadgets/permutation.rs b/src/gadgets/permutation.rs index 06c9c711..f21712e6 100644 --- a/src/gadgets/permutation.rs +++ b/src/gadgets/permutation.rs @@ -323,6 +323,7 @@ fn route( scan_index[side], false, ); + scan_index[side] += 1; } } } diff --git a/src/gates/switch.rs b/src/gates/switch.rs index bb9553ad..7f172944 100644 --- a/src/gates/switch.rs +++ b/src/gates/switch.rs @@ -57,6 +57,7 @@ impl, const D: usize, const CHUNK_SIZE: usize> SwitchGate usize { + debug_assert!(copy < num_copies); num_copies * (4 * CHUNK_SIZE) + copy } } @@ -213,7 +214,7 @@ impl, const D: usize, const CHUNK_SIZE: usize> SimpleGenerator< SwitchGate::::wire_second_input(self.copy, e), )); deps.push(local_target( - SwitchGate::::wire_switch_bool(self.copy, e), + SwitchGate::::wire_switch_bool(self.gate.num_copies, self.copy), )); } @@ -228,15 +229,13 @@ impl, const D: usize, const CHUNK_SIZE: usize> SimpleGenerator< let get_local_wire = |input| witness.get_wire(local_wire(input)); - let first_output_wire = local_wire(SwitchGate::::wire_first_output( - self.gate.num_copies, - self.copy, - )); - let second_output_wire = local_wire(SwitchGate::::wire_second_output( - self.gate.num_copies, - self.copy, - )); for e in 0..CHUNK_SIZE { + let first_output_wire = local_wire(SwitchGate::::wire_first_output( + self.copy, e, + )); + let second_output_wire = local_wire(SwitchGate::::wire_second_output( + self.copy, e, + )); let first_input = get_local_wire(SwitchGate::::wire_first_input( self.copy, e, )); @@ -244,7 +243,8 @@ impl, const D: usize, const CHUNK_SIZE: usize> SimpleGenerator< self.copy, e, )); let switch_bool = get_local_wire(SwitchGate::::wire_switch_bool( - self.copy, e, + self.gate.num_copies, + self.copy, )); let (first_output, second_output) = if switch_bool == F::ZERO {