From d509f03b1bb0eb5d6525016d59e0f2e65ea34573 Mon Sep 17 00:00:00 2001 From: wborgeaud Date: Fri, 23 Jul 2021 18:32:59 +0200 Subject: [PATCH] Implement `eval_unfiltered_base` --- src/gates/reducing.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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,