diff --git a/src/gates/switch.rs b/src/gates/switch.rs index 721ce032..f06ae7a9 100644 --- a/src/gates/switch.rs +++ b/src/gates/switch.rs @@ -67,7 +67,7 @@ impl, const D: usize, const CHUNK_SIZE: usize> Gate for SwitchGate { fn id(&self) -> String { - format!("{:?}", self, D) + format!("{:?}", self, D, CHUNK_SIZE) } fn eval_unfiltered(&self, vars: EvaluationVars) -> Vec { @@ -75,6 +75,7 @@ impl, const D: usize, const CHUNK_SIZE: usize> Gate for c in 0..self.num_copies { let switch_bool = vars.local_wires[self.wire_switch_bool(c)]; + let not_switch = F::Extension::ONE - switch_bool; for e in 0..CHUNK_SIZE { let first_input = vars.local_wires[self.wire_first_input(c, e)]; @@ -84,9 +85,9 @@ impl, const D: usize, const CHUNK_SIZE: usize> Gate constraints.push(switch_bool * (first_input - second_output)); constraints.push(switch_bool * (second_input - first_output)); - constraints.push((F::Extension::ONE - switch_bool) * (first_input - first_output)); + constraints.push(not_switch * (first_input - first_output)); constraints - .push((F::Extension::ONE - switch_bool) * (second_input - second_output)); + .push(not_switch * (second_input - second_output)); } } @@ -98,6 +99,7 @@ impl, const D: usize, const CHUNK_SIZE: usize> Gate for c in 0..self.num_copies { let switch_bool = vars.local_wires[self.wire_switch_bool(c)]; + let not_switch = F::ONE - switch_bool; for e in 0..CHUNK_SIZE { let first_input = vars.local_wires[self.wire_first_input(c, e)]; @@ -107,8 +109,8 @@ impl, const D: usize, const CHUNK_SIZE: usize> Gate constraints.push(switch_bool * (first_input - second_output)); constraints.push(switch_bool * (second_input - first_output)); - constraints.push((F::ONE - switch_bool) * (first_input - first_output)); - constraints.push((F::ONE - switch_bool) * (second_input - second_output)); + constraints.push(not_switch * (first_input - first_output)); + constraints.push(not_switch * (second_input - second_output)); } }