diff --git a/src/gates/reducing.rs b/src/gates/reducing.rs index 4c750bb9..f85bb3c2 100644 --- a/src/gates/reducing.rs +++ b/src/gates/reducing.rs @@ -77,6 +77,32 @@ impl, const D: usize> Gate for ReducingGate { .collect() } + fn eval_unfiltered_base(&self, vars: EvaluationVarsBase) -> Vec { + let output = vars.get_local_ext(Self::wires_output()); + let alpha = vars.get_local_ext(Self::wires_alpha()); + let old_acc = vars.get_local_ext(Self::wires_old_acc()); + let coeffs = self + .wires_coeffs() + .map(|i| vars.local_wires[i]) + .collect::>(); + let accs = (0..self.num_coeffs) + .map(|i| vars.get_local_ext(self.wires_accs(i))) + .collect::>(); + + let mut constraints = Vec::new(); + let mut acc = old_acc; + for i in 0..self.num_coeffs { + constraints.push(acc * alpha + coeffs[i].into() - accs[i]); + acc = accs[i]; + } + + constraints.push(output - acc); + constraints + .into_iter() + .flat_map(|alg| alg.to_basefield_array()) + .collect() + } + fn eval_unfiltered_recursively( &self, builder: &mut CircuitBuilder,