Implementation of conditional negation for AllocatedNum.

This commit is contained in:
Sean Bowe
2017-12-22 11:52:13 -07:00
parent 87548f3d1d
commit e1ab3be3cc
2 changed files with 153 additions and 0 deletions
+19
View File
@@ -270,6 +270,25 @@ impl<Var: Copy> Boolean<Var> {
}
}
pub fn lc<E: Engine>(&self, one: Var, coeff: E::Fr) -> LinearCombination<Var, E>
{
match self {
&Boolean::Constant(c) => {
if c {
LinearCombination::<Var, E>::zero() + (coeff, one)
} else {
LinearCombination::<Var, E>::zero()
}
},
&Boolean::Is(ref v) => {
LinearCombination::<Var, E>::zero() + (coeff, v.get_variable())
},
&Boolean::Not(ref v) => {
LinearCombination::<Var, E>::zero() + (coeff, one) - (coeff, v.get_variable())
}
}
}
/// Construct a boolean from a known constant
pub fn constant(b: bool) -> Self {
Boolean::Constant(b)