Simplify implementation of addmany.
This commit is contained in:
parent
b16f4abc75
commit
8cc319f79e
|
@ -367,6 +367,13 @@ pub enum Boolean {
|
|||
}
|
||||
|
||||
impl Boolean {
|
||||
pub fn is_constant(&self) -> bool {
|
||||
match *self {
|
||||
Boolean::Constant(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enforce_equal<E, CS>(
|
||||
mut cs: CS,
|
||||
a: &Self,
|
||||
|
|
|
@ -418,25 +418,9 @@ impl UInt32 {
|
|||
// the linear combination
|
||||
let mut coeff = E::Fr::one();
|
||||
for bit in &op.bits {
|
||||
match bit {
|
||||
&Boolean::Is(ref bit) => {
|
||||
all_constants = false;
|
||||
lc = lc + &bit.lc(CS::one(), coeff);
|
||||
|
||||
// Add coeff * bit
|
||||
lc = lc + (coeff, bit.get_variable());
|
||||
},
|
||||
&Boolean::Not(ref bit) => {
|
||||
all_constants = false;
|
||||
|
||||
// Add coeff * (1 - bit) = coeff * ONE - coeff * bit
|
||||
lc = lc + (coeff, CS::one()) - (coeff, bit.get_variable());
|
||||
},
|
||||
&Boolean::Constant(bit) => {
|
||||
if bit {
|
||||
lc = lc + (coeff, CS::one());
|
||||
}
|
||||
}
|
||||
}
|
||||
all_constants &= bit.is_constant();
|
||||
|
||||
coeff.double();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue