From 7acdf976c1f8c00a571d7208d243fc9a67430443 Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Thu, 2 Sep 2021 15:59:17 -0700 Subject: [PATCH] fixed fill_switch_gates --- src/plonk/circuit_builder.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/plonk/circuit_builder.rs b/src/plonk/circuit_builder.rs index 7252cebf..7ee8852f 100644 --- a/src/plonk/circuit_builder.rs +++ b/src/plonk/circuit_builder.rs @@ -521,18 +521,22 @@ impl, const D: usize> CircuitBuilder { let zero = self.zero(); for chunk_size in 1..=self.current_switch_gates.len() { - if let Some((gate, gate_index, copy)) = + if let Some((gate, gate_index, mut copy)) = self.current_switch_gates[chunk_size - 1].clone() { - for element in 0..chunk_size { - let wire_first_input = - Target::wire(gate_index, gate.wire_first_input(copy, element)); - let wire_second_input = - Target::wire(gate_index, gate.wire_second_input(copy, element)); - let wire_switch_bool = Target::wire(gate_index, gate.wire_switch_bool(copy)); - self.connect(zero, wire_first_input); - self.connect(zero, wire_second_input); - self.connect(zero, wire_switch_bool); + while copy < gate.num_copies { + for element in 0..chunk_size { + let wire_first_input = + Target::wire(gate_index, gate.wire_first_input(copy, element)); + let wire_second_input = + Target::wire(gate_index, gate.wire_second_input(copy, element)); + let wire_switch_bool = + Target::wire(gate_index, gate.wire_switch_bool(copy)); + self.connect(zero, wire_first_input); + self.connect(zero, wire_second_input); + self.connect(zero, wire_switch_bool); + } + copy += 1; } } } @@ -550,6 +554,7 @@ impl, const D: usize> CircuitBuilder { let start = Instant::now(); self.fill_arithmetic_gates(); + self.fill_switch_gates(); // Hash the public inputs, and route them to a `PublicInputGate` which will enforce that // those hash wires match the claimed public inputs.