diff --git a/src/gadgets/split_base.rs b/src/gadgets/split_base.rs index 0d5c9906..582f9286 100644 --- a/src/gadgets/split_base.rs +++ b/src/gadgets/split_base.rs @@ -32,6 +32,9 @@ impl, const D: usize> CircuitBuilder { bits: impl ExactSizeIterator> + Clone, ) -> Target { let num_bits = bits.len(); + if num_bits == 0 { + return self.zero(); + } debug_assert!( BaseSumGate::<2>::START_LIMBS + num_bits <= self.config.num_routed_wires, "Not enough routed wires." diff --git a/src/util/reducing.rs b/src/util/reducing.rs index 3fc0845c..a729662a 100644 --- a/src/util/reducing.rs +++ b/src/util/reducing.rs @@ -137,12 +137,6 @@ impl ReducingFactorTarget { acc } - /// Reduces a length `n` vector of `ExtensionTarget`s using `n/2` `ArithmeticExtensionGate`s. - /// It does this by batching two steps of Horner's method in each gate. - /// Here's an example with `n=4, alpha=2, D=1`: - /// 1st gate: 2 0 4 4 3 4 11 <- 2*0+4=4, 2*4+3=11 - /// 2nd gate: 2 11 2 24 1 24 49 <- 2*11+2=24, 2*24+1=49 - /// which verifies that `2.reduce([1,2,3,4]) = 49`. pub fn reduce( &mut self, terms: &[ExtensionTarget], // Could probably work with a `DoubleEndedIterator` too. @@ -155,7 +149,7 @@ impl ReducingFactorTarget { self.count += l as u64; let mut terms_vec = terms.to_vec(); - let mut acc = terms_vec.pop().unwrap(); + let mut acc = builder.zero_extension(); terms_vec.reverse(); for x in terms_vec {