diff --git a/src/gadgets/arithmetic_extension.rs b/src/gadgets/arithmetic_extension.rs index c800cf8c..9aaaf857 100644 --- a/src/gadgets/arithmetic_extension.rs +++ b/src/gadgets/arithmetic_extension.rs @@ -152,38 +152,17 @@ impl, const D: usize> CircuitBuilder { None } - pub fn arithmetic_many_extension( - &mut self, - const_0: F, - const_1: F, - operands: Vec<[ExtensionTarget; 3]>, - ) -> Vec> { - let mut res = Vec::new(); - for chunk in operands.chunks_exact(2) { - let [fm0, fm1, fa] = chunk[0]; - let [sm0, sm1, sa] = chunk[1]; - let arithm = - self.double_arithmetic_extension(const_0, const_1, fm0, fm1, fa, sm0, sm1, sa); - res.push(arithm.0); - res.push(arithm.1); - } - if operands.len().is_odd() { - let [m0, m1, a] = operands[operands.len() - 1]; - res.push(self.arithmetic_extension(const_0, const_1, m0, m1, a)); - } - - res - } + /// Returns `sum_{(a,b) in vecs} constant * a * b`. pub fn inner_product_extension( &mut self, constant: F, starting_acc: ExtensionTarget, - vecs: Vec<[ExtensionTarget; 2]>, + pairs: Vec<(ExtensionTarget, ExtensionTarget)>, ) -> ExtensionTarget { let mut acc = starting_acc; - for chunk in vecs.chunks_exact(2) { - let [a0, b0] = chunk[0]; - let [a1, b1] = chunk[1]; + for chunk in pairs.chunks_exact(2) { + let (a0, b0) = chunk[0]; + let (a1, b1) = chunk[1]; let gate = self.num_gates(); let first_out = ExtensionTarget::from_range( gate, @@ -193,9 +172,9 @@ impl, const D: usize> CircuitBuilder { .double_arithmetic_extension(constant, F::ONE, a0, b0, acc, a1, b1, first_out) .1; } - if vecs.len().is_odd() { - let n = vecs.len() - 1; - acc = self.arithmetic_extension(constant, F::ONE, vecs[n][0], vecs[n][1], acc); + if pairs.len().is_odd() { + let n = pairs.len() - 1; + acc = self.arithmetic_extension(constant, F::ONE, pairs[n].0, pairs[n].1, acc); } acc } @@ -378,10 +357,10 @@ impl, const D: usize> CircuitBuilder { let mut inner_w = vec![vec![]; D]; for i in 0..D { for j in 0..D - i { - inner[(i + j) % D].push([a.0[i], b.0[j]]); + inner[(i + j) % D].push((a.0[i], b.0[j])); } for j in D - i..D { - inner_w[(i + j) % D].push([a.0[i], b.0[j]]); + inner_w[(i + j) % D].push((a.0[i], b.0[j])); } } let res = inner_w