restructure for clarity, remove debug print statements
@@ -485,13 +485,9 @@ pub trait BundleGadgets: Fancy {
let mut opt_carry = None;
let mut max_carry = 0;
- for i in 0..n {
- println!("modulus {}", xs[0].moduli()[i]);
-
+ for i in 0..n-1 {
// all the ith digits, in one vec
let ds = xs.iter().map(|x| x.wires()[i].clone()).collect_vec();
-
- if i < n-1 {
// compute the carry
let q = xs[0].moduli()[i];
// max_carry currently contains the max carry from the previous iteration
@@ -517,18 +513,14 @@ pub trait BundleGadgets: Fancy {
xs[0].moduli()[i+1] // we will be adding the carry to the MSB
};
- println!("next mod: {}", next_mod);
-
let tt = (0..=max_val).map(|i| (i / q) % next_mod).collect_vec();
opt_carry = Some(self.proj(ix, &sum_with_carry, next_mod, Some(tt)));
- } else {
- // compute the msb
- let digit_sum = self.add_many(&ds);
- return opt_carry.as_ref().map_or(digit_sum.clone(), |d| self.add(&digit_sum, &d));
- }
}
- unreachable!()
+ // compute the msb
+ let ds = xs.iter().map(|x| x.wires()[n-1].clone()).collect_vec();
+ let digit_sum = self.add_many(&ds);
+ opt_carry.as_ref().map_or(digit_sum.clone(), |d| self.add(&digit_sum, &d))
}
////////////////////////////////////////////////////////////////////////////////
