Switch to stable cargo formatting options

This commit is contained in:
Pratyush Mishra
2020-04-07 16:11:56 -07:00
parent 456f30a849
commit 33a9da08f8
40 changed files with 402 additions and 408 deletions

View File

@@ -13,7 +13,7 @@ problem_files=()
# collect ill-formatted files # collect ill-formatted files
for file in $(git diff --name-only --cached); do for file in $(git diff --name-only --cached); do
if [ ${file: -3} == ".rs" ]; then if [ ${file: -3} == ".rs" ]; then
rustfmt +nightly --check $file &>/dev/null rustfmt +stable --check $file &>/dev/null
if [ $? != 0 ]; then if [ $? != 0 ]; then
problem_files+=($file) problem_files+=($file)
fi fi
@@ -27,7 +27,7 @@ else
# reformat the files that need it and re-stage them. # reformat the files that need it and re-stage them.
printf "[pre_commit] the following files were rustfmt'd before commit: \n" printf "[pre_commit] the following files were rustfmt'd before commit: \n"
for file in ${problem_files[@]}; do for file in ${problem_files[@]}; do
rustfmt $file rustfmt +stable $file
git add $file git add $file
printf "\033[0;32m $file\033[0m \n" printf "\033[0;32m $file\033[0m \n"
done done

View File

@@ -248,7 +248,7 @@ impl core::fmt::Display for MerkleTreeError {
let msg = match self { let msg = match self {
MerkleTreeError::IncorrectLeafIndex(index) => { MerkleTreeError::IncorrectLeafIndex(index) => {
format!("incorrect leaf index: {}", index) format!("incorrect leaf index: {}", index)
}, }
MerkleTreeError::IncorrectPathLength(len) => format!("incorrect path length: {}", len), MerkleTreeError::IncorrectPathLength(len) => format!("incorrect path length: {}", len),
}; };
write!(f, "{}", msg) write!(f, "{}", msg)

View File

@@ -664,14 +664,14 @@ mod test {
match b { match b {
Boolean::Is(b) => { Boolean::Is(b) => {
assert!(s.next().unwrap() == b.get_value().unwrap()); assert!(s.next().unwrap() == b.get_value().unwrap());
}, }
Boolean::Not(b) => { Boolean::Not(b) => {
assert!(s.next().unwrap() != b.get_value().unwrap()); assert!(s.next().unwrap() != b.get_value().unwrap());
}, }
Boolean::Constant(b) => { Boolean::Constant(b) => {
assert!(input_len == 0); assert!(input_len == 0);
assert!(s.next().unwrap() == b); assert!(s.next().unwrap() == b);
}, }
} }
} }
} }

View File

@@ -400,11 +400,11 @@ impl Boolean {
} else { } else {
LinearCombination::<ConstraintF>::zero() LinearCombination::<ConstraintF>::zero()
} }
}, }
Boolean::Is(ref v) => (coeff, v.get_variable()).into(), Boolean::Is(ref v) => (coeff, v.get_variable()).into(),
Boolean::Not(ref v) => { Boolean::Not(ref v) => {
LinearCombination::<ConstraintF>::zero() + (coeff, one) - (coeff, v.get_variable()) LinearCombination::<ConstraintF>::zero() + (coeff, one) - (coeff, v.get_variable())
}, }
} }
} }
@@ -458,12 +458,12 @@ impl Boolean {
(is @ &Boolean::Is(_), not @ &Boolean::Not(_)) (is @ &Boolean::Is(_), not @ &Boolean::Not(_))
| (not @ &Boolean::Not(_), is @ &Boolean::Is(_)) => { | (not @ &Boolean::Not(_), is @ &Boolean::Is(_)) => {
Ok(Boolean::xor(cs, is, &not.not())?.not()) Ok(Boolean::xor(cs, is, &not.not())?.not())
}, }
// a XOR b = (NOT a) XOR (NOT b) // a XOR b = (NOT a) XOR (NOT b)
(&Boolean::Is(ref a), &Boolean::Is(ref b)) (&Boolean::Is(ref a), &Boolean::Is(ref b))
| (&Boolean::Not(ref a), &Boolean::Not(ref b)) => { | (&Boolean::Not(ref a), &Boolean::Not(ref b)) => {
Ok(Boolean::Is(AllocatedBit::xor(cs, a, b)?)) Ok(Boolean::Is(AllocatedBit::xor(cs, a, b)?))
}, }
} }
} }
@@ -477,16 +477,16 @@ impl Boolean {
(&Boolean::Constant(false), x) | (x, &Boolean::Constant(false)) => Ok(*x), (&Boolean::Constant(false), x) | (x, &Boolean::Constant(false)) => Ok(*x),
(&Boolean::Constant(true), _) | (_, &Boolean::Constant(true)) => { (&Boolean::Constant(true), _) | (_, &Boolean::Constant(true)) => {
Ok(Boolean::Constant(true)) Ok(Boolean::Constant(true))
}, }
// a OR b = NOT ((NOT a) AND b) // a OR b = NOT ((NOT a) AND b)
(a @ &Boolean::Is(_), b @ &Boolean::Not(_)) (a @ &Boolean::Is(_), b @ &Boolean::Not(_))
| (b @ &Boolean::Not(_), a @ &Boolean::Is(_)) | (b @ &Boolean::Not(_), a @ &Boolean::Is(_))
| (b @ &Boolean::Not(_), a @ &Boolean::Not(_)) => { | (b @ &Boolean::Not(_), a @ &Boolean::Not(_)) => {
Ok(Boolean::and(cs, &a.not(), &b.not())?.not()) Ok(Boolean::and(cs, &a.not(), &b.not())?.not())
}, }
(&Boolean::Is(ref a), &Boolean::Is(ref b)) => { (&Boolean::Is(ref a), &Boolean::Is(ref b)) => {
AllocatedBit::or(cs, a, b).map(Boolean::from) AllocatedBit::or(cs, a, b).map(Boolean::from)
}, }
} }
} }
@@ -504,22 +504,22 @@ impl Boolean {
// false AND x is always false // false AND x is always false
(&Boolean::Constant(false), _) | (_, &Boolean::Constant(false)) => { (&Boolean::Constant(false), _) | (_, &Boolean::Constant(false)) => {
Ok(Boolean::Constant(false)) Ok(Boolean::Constant(false))
}, }
// true AND x is always x // true AND x is always x
(&Boolean::Constant(true), x) | (x, &Boolean::Constant(true)) => Ok(*x), (&Boolean::Constant(true), x) | (x, &Boolean::Constant(true)) => Ok(*x),
// a AND (NOT b) // a AND (NOT b)
(&Boolean::Is(ref is), &Boolean::Not(ref not)) (&Boolean::Is(ref is), &Boolean::Not(ref not))
| (&Boolean::Not(ref not), &Boolean::Is(ref is)) => { | (&Boolean::Not(ref not), &Boolean::Is(ref is)) => {
Ok(Boolean::Is(AllocatedBit::and_not(cs, is, not)?)) Ok(Boolean::Is(AllocatedBit::and_not(cs, is, not)?))
}, }
// (NOT a) AND (NOT b) = a NOR b // (NOT a) AND (NOT b) = a NOR b
(&Boolean::Not(ref a), &Boolean::Not(ref b)) => { (&Boolean::Not(ref a), &Boolean::Not(ref b)) => {
Ok(Boolean::Is(AllocatedBit::nor(cs, a, b)?)) Ok(Boolean::Is(AllocatedBit::nor(cs, a, b)?))
}, }
// a AND b // a AND b
(&Boolean::Is(ref a), &Boolean::Is(ref b)) => { (&Boolean::Is(ref a), &Boolean::Is(ref b)) => {
Ok(Boolean::Is(AllocatedBit::and(cs, a, b)?)) Ok(Boolean::Is(AllocatedBit::and(cs, a, b)?))
}, }
} }
} }
@@ -559,7 +559,7 @@ impl Boolean {
); );
Ok(()) Ok(())
}, }
Boolean::Not(ref res) => { Boolean::Not(ref res) => {
cs.enforce( cs.enforce(
|| "enforce nand", || "enforce nand",
@@ -569,7 +569,7 @@ impl Boolean {
); );
Ok(()) Ok(())
}, }
} }
} }
@@ -760,25 +760,25 @@ impl<ConstraintF: Field> ConditionalEqGadget<ConstraintF> for Boolean {
// 1 - a // 1 - a
(Constant(true), Is(a)) | (Is(a), Constant(true)) => { (Constant(true), Is(a)) | (Is(a), Constant(true)) => {
LinearCombination::zero() + one - a.get_variable() LinearCombination::zero() + one - a.get_variable()
}, }
// a - 0 = a // a - 0 = a
(Constant(false), Is(a)) | (Is(a), Constant(false)) => { (Constant(false), Is(a)) | (Is(a), Constant(false)) => {
LinearCombination::zero() + a.get_variable() LinearCombination::zero() + a.get_variable()
}, }
// 1 - !a = 1 - (1 - a) = a // 1 - !a = 1 - (1 - a) = a
(Constant(true), Not(a)) | (Not(a), Constant(true)) => { (Constant(true), Not(a)) | (Not(a), Constant(true)) => {
LinearCombination::zero() + a.get_variable() LinearCombination::zero() + a.get_variable()
}, }
// !a - 0 = !a = 1 - a // !a - 0 = !a = 1 - a
(Constant(false), Not(a)) | (Not(a), Constant(false)) => { (Constant(false), Not(a)) | (Not(a), Constant(false)) => {
LinearCombination::zero() + one - a.get_variable() LinearCombination::zero() + one - a.get_variable()
}, }
// b - a, // b - a,
(Is(a), Is(b)) => LinearCombination::zero() + b.get_variable() - a.get_variable(), (Is(a), Is(b)) => LinearCombination::zero() + b.get_variable() - a.get_variable(),
// !b - a = (1 - b) - a // !b - a = (1 - b) - a
(Is(a), Not(b)) | (Not(b), Is(a)) => { (Is(a), Not(b)) | (Not(b), Is(a)) => {
LinearCombination::zero() + one - b.get_variable() - a.get_variable() LinearCombination::zero() + one - b.get_variable() - a.get_variable()
}, }
// !b - !a = (1 - b) - (1 - a) = a - b, // !b - !a = (1 - b) - (1 - a) = a - b,
(Not(a), Not(b)) => LinearCombination::zero() + a.get_variable() - b.get_variable(), (Not(a), Not(b)) => LinearCombination::zero() + a.get_variable() - b.get_variable(),
}; };
@@ -831,7 +831,7 @@ impl<ConstraintF: PrimeField> CondSelectGadget<ConstraintF> for Boolean {
Boolean::Constant(false) => Ok(false_value.clone()), Boolean::Constant(false) => Ok(false_value.clone()),
cond @ Boolean::Not(_) => { cond @ Boolean::Not(_) => {
Self::conditionally_select(cs, &cond.not(), false_value, true_value) Self::conditionally_select(cs, &cond.not(), false_value, true_value)
}, }
cond @ Boolean::Is(_) => match (true_value, false_value) { cond @ Boolean::Is(_) => match (true_value, false_value) {
(x, &Boolean::Constant(false)) => Boolean::and(cs.ns(|| "and"), cond, x).into(), (x, &Boolean::Constant(false)) => Boolean::and(cs.ns(|| "and"), cond, x).into(),
(&Boolean::Constant(false), x) => Boolean::and(cs.ns(|| "and"), &cond.not(), x), (&Boolean::Constant(false), x) => Boolean::and(cs.ns(|| "and"), &cond.not(), x),
@@ -847,7 +847,7 @@ impl<ConstraintF: PrimeField> CondSelectGadget<ConstraintF> for Boolean {
cond_select_helper(cs, cond, (a.get_value(), a_lc), (b.get_value(), b_lc))? cond_select_helper(cs, cond, (a.get_value(), a_lc), (b.get_value(), b_lc))?
.into(), .into(),
) )
}, }
}, },
} }
} }
@@ -1138,42 +1138,42 @@ mod test {
let mut b = Boolean::from(AllocatedBit::alloc(&mut cs, || Ok(true)).unwrap()); let mut b = Boolean::from(AllocatedBit::alloc(&mut cs, || Ok(true)).unwrap());
match b { match b {
Boolean::Is(_) => {}, Boolean::Is(_) => {}
_ => panic!("unexpected value"), _ => panic!("unexpected value"),
} }
b = b.not(); b = b.not();
match b { match b {
Boolean::Not(_) => {}, Boolean::Not(_) => {}
_ => panic!("unexpected value"), _ => panic!("unexpected value"),
} }
b = b.not(); b = b.not();
match b { match b {
Boolean::Is(_) => {}, Boolean::Is(_) => {}
_ => panic!("unexpected value"), _ => panic!("unexpected value"),
} }
b = Boolean::constant(true); b = Boolean::constant(true);
match b { match b {
Boolean::Constant(true) => {}, Boolean::Constant(true) => {}
_ => panic!("unexpected value"), _ => panic!("unexpected value"),
} }
b = b.not(); b = b.not();
match b { match b {
Boolean::Constant(false) => {}, Boolean::Constant(false) => {}
_ => panic!("unexpected value"), _ => panic!("unexpected value"),
} }
b = b.not(); b = b.not();
match b { match b {
Boolean::Constant(true) => {}, Boolean::Constant(true) => {}
_ => panic!("unexpected value"), _ => panic!("unexpected value"),
} }
} }
@@ -1215,16 +1215,16 @@ mod test {
OperandType::False => Boolean::constant(false), OperandType::False => Boolean::constant(false),
OperandType::AllocatedTrue => { OperandType::AllocatedTrue => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap()) Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap())
}, }
OperandType::AllocatedFalse => { OperandType::AllocatedFalse => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap()) Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap())
}, }
OperandType::NegatedAllocatedTrue => { OperandType::NegatedAllocatedTrue => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap()).not() Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap()).not()
}, }
OperandType::NegatedAllocatedFalse => { OperandType::NegatedAllocatedFalse => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap()).not() Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap()).not()
}, }
} }
}; };
@@ -1237,22 +1237,22 @@ mod test {
assert!(cs.is_satisfied()); assert!(cs.is_satisfied());
match (first_operand, second_operand, c) { match (first_operand, second_operand, c) {
(OperandType::True, OperandType::True, Boolean::Constant(false)) => {}, (OperandType::True, OperandType::True, Boolean::Constant(false)) => {}
(OperandType::True, OperandType::False, Boolean::Constant(true)) => {}, (OperandType::True, OperandType::False, Boolean::Constant(true)) => {}
(OperandType::True, OperandType::AllocatedTrue, Boolean::Not(_)) => {}, (OperandType::True, OperandType::AllocatedTrue, Boolean::Not(_)) => {}
(OperandType::True, OperandType::AllocatedFalse, Boolean::Not(_)) => {}, (OperandType::True, OperandType::AllocatedFalse, Boolean::Not(_)) => {}
(OperandType::True, OperandType::NegatedAllocatedTrue, Boolean::Is(_)) => {}, (OperandType::True, OperandType::NegatedAllocatedTrue, Boolean::Is(_)) => {}
(OperandType::True, OperandType::NegatedAllocatedFalse, Boolean::Is(_)) => {}, (OperandType::True, OperandType::NegatedAllocatedFalse, Boolean::Is(_)) => {}
(OperandType::False, OperandType::True, Boolean::Constant(true)) => {}, (OperandType::False, OperandType::True, Boolean::Constant(true)) => {}
(OperandType::False, OperandType::False, Boolean::Constant(false)) => {}, (OperandType::False, OperandType::False, Boolean::Constant(false)) => {}
(OperandType::False, OperandType::AllocatedTrue, Boolean::Is(_)) => {}, (OperandType::False, OperandType::AllocatedTrue, Boolean::Is(_)) => {}
(OperandType::False, OperandType::AllocatedFalse, Boolean::Is(_)) => {}, (OperandType::False, OperandType::AllocatedFalse, Boolean::Is(_)) => {}
(OperandType::False, OperandType::NegatedAllocatedTrue, Boolean::Not(_)) => {}, (OperandType::False, OperandType::NegatedAllocatedTrue, Boolean::Not(_)) => {}
(OperandType::False, OperandType::NegatedAllocatedFalse, Boolean::Not(_)) => {}, (OperandType::False, OperandType::NegatedAllocatedFalse, Boolean::Not(_)) => {}
(OperandType::AllocatedTrue, OperandType::True, Boolean::Not(_)) => {}, (OperandType::AllocatedTrue, OperandType::True, Boolean::Not(_)) => {}
(OperandType::AllocatedTrue, OperandType::False, Boolean::Is(_)) => {}, (OperandType::AllocatedTrue, OperandType::False, Boolean::Is(_)) => {}
( (
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
@@ -1260,7 +1260,7 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::zero()); assert!(cs.get("xor result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
@@ -1268,7 +1268,7 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::one()); assert!(cs.get("xor result") == Fr::one());
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
@@ -1276,7 +1276,7 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::zero()); assert!(cs.get("xor result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
@@ -1284,10 +1284,10 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::one()); assert!(cs.get("xor result") == Fr::one());
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
(OperandType::AllocatedFalse, OperandType::True, Boolean::Not(_)) => {}, (OperandType::AllocatedFalse, OperandType::True, Boolean::Not(_)) => {}
(OperandType::AllocatedFalse, OperandType::False, Boolean::Is(_)) => {}, (OperandType::AllocatedFalse, OperandType::False, Boolean::Is(_)) => {}
( (
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
@@ -1295,7 +1295,7 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::one()); assert!(cs.get("xor result") == Fr::one());
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
@@ -1303,7 +1303,7 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::zero()); assert!(cs.get("xor result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
@@ -1311,7 +1311,7 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::one()); assert!(cs.get("xor result") == Fr::one());
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
@@ -1319,10 +1319,10 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::zero()); assert!(cs.get("xor result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
(OperandType::NegatedAllocatedTrue, OperandType::True, Boolean::Is(_)) => {}, (OperandType::NegatedAllocatedTrue, OperandType::True, Boolean::Is(_)) => {}
(OperandType::NegatedAllocatedTrue, OperandType::False, Boolean::Not(_)) => {}, (OperandType::NegatedAllocatedTrue, OperandType::False, Boolean::Not(_)) => {}
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
@@ -1330,7 +1330,7 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::zero()); assert!(cs.get("xor result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
@@ -1338,7 +1338,7 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::one()); assert!(cs.get("xor result") == Fr::one());
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
@@ -1346,7 +1346,7 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::zero()); assert!(cs.get("xor result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
@@ -1354,10 +1354,10 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::one()); assert!(cs.get("xor result") == Fr::one());
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
(OperandType::NegatedAllocatedFalse, OperandType::True, Boolean::Is(_)) => {}, (OperandType::NegatedAllocatedFalse, OperandType::True, Boolean::Is(_)) => {}
(OperandType::NegatedAllocatedFalse, OperandType::False, Boolean::Not(_)) => {}, (OperandType::NegatedAllocatedFalse, OperandType::False, Boolean::Not(_)) => {}
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
@@ -1365,7 +1365,7 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::one()); assert!(cs.get("xor result") == Fr::one());
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
@@ -1373,7 +1373,7 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::zero()); assert!(cs.get("xor result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
@@ -1381,7 +1381,7 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::one()); assert!(cs.get("xor result") == Fr::one());
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
@@ -1389,7 +1389,7 @@ mod test {
) => { ) => {
assert!(cs.get("xor result") == Fr::zero()); assert!(cs.get("xor result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
_ => panic!("this should never be encountered"), _ => panic!("this should never be encountered"),
} }
@@ -1426,18 +1426,18 @@ mod test {
OperandType::False => Boolean::constant(false), OperandType::False => Boolean::constant(false),
OperandType::AllocatedTrue => { OperandType::AllocatedTrue => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap()) Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap())
}, }
OperandType::AllocatedFalse => { OperandType::AllocatedFalse => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap()) Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap())
}, }
OperandType::NegatedAllocatedTrue => { OperandType::NegatedAllocatedTrue => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap()) Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap())
.not() .not()
}, }
OperandType::NegatedAllocatedFalse => { OperandType::NegatedAllocatedFalse => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap()) Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap())
.not() .not()
}, }
} }
}; };
@@ -1498,16 +1498,16 @@ mod test {
OperandType::False => Boolean::constant(false), OperandType::False => Boolean::constant(false),
OperandType::AllocatedTrue => { OperandType::AllocatedTrue => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap()) Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap())
}, }
OperandType::AllocatedFalse => { OperandType::AllocatedFalse => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap()) Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap())
}, }
OperandType::NegatedAllocatedTrue => { OperandType::NegatedAllocatedTrue => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap()).not() Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap()).not()
}, }
OperandType::NegatedAllocatedFalse => { OperandType::NegatedAllocatedFalse => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap()).not() Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap()).not()
}, }
} }
}; };
@@ -1520,159 +1520,159 @@ mod test {
assert!(cs.is_satisfied()); assert!(cs.is_satisfied());
match (first_operand, second_operand, c) { match (first_operand, second_operand, c) {
(OperandType::True, OperandType::True, Boolean::Constant(true)) => {}, (OperandType::True, OperandType::True, Boolean::Constant(true)) => {}
(OperandType::True, OperandType::False, Boolean::Constant(true)) => {}, (OperandType::True, OperandType::False, Boolean::Constant(true)) => {}
(OperandType::True, OperandType::AllocatedTrue, Boolean::Constant(true)) => {}, (OperandType::True, OperandType::AllocatedTrue, Boolean::Constant(true)) => {}
(OperandType::True, OperandType::AllocatedFalse, Boolean::Constant(true)) => {}, (OperandType::True, OperandType::AllocatedFalse, Boolean::Constant(true)) => {}
( (
OperandType::True, OperandType::True,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
Boolean::Constant(true), Boolean::Constant(true),
) => {}, ) => {}
( (
OperandType::True, OperandType::True,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
Boolean::Constant(true), Boolean::Constant(true),
) => {}, ) => {}
(OperandType::False, OperandType::True, Boolean::Constant(true)) => {}, (OperandType::False, OperandType::True, Boolean::Constant(true)) => {}
(OperandType::False, OperandType::False, Boolean::Constant(false)) => {}, (OperandType::False, OperandType::False, Boolean::Constant(false)) => {}
(OperandType::False, OperandType::AllocatedTrue, Boolean::Is(_)) => {}, (OperandType::False, OperandType::AllocatedTrue, Boolean::Is(_)) => {}
(OperandType::False, OperandType::AllocatedFalse, Boolean::Is(_)) => {}, (OperandType::False, OperandType::AllocatedFalse, Boolean::Is(_)) => {}
(OperandType::False, OperandType::NegatedAllocatedTrue, Boolean::Not(_)) => {}, (OperandType::False, OperandType::NegatedAllocatedTrue, Boolean::Not(_)) => {}
(OperandType::False, OperandType::NegatedAllocatedFalse, Boolean::Not(_)) => {}, (OperandType::False, OperandType::NegatedAllocatedFalse, Boolean::Not(_)) => {}
(OperandType::AllocatedTrue, OperandType::True, Boolean::Constant(true)) => {}, (OperandType::AllocatedTrue, OperandType::True, Boolean::Constant(true)) => {}
(OperandType::AllocatedTrue, OperandType::False, Boolean::Is(_)) => {}, (OperandType::AllocatedTrue, OperandType::False, Boolean::Is(_)) => {}
( (
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
Boolean::Is(ref v), Boolean::Is(ref v),
) => { ) => {
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
Boolean::Is(ref v), Boolean::Is(ref v),
) => { ) => {
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
Boolean::Not(ref v), Boolean::Not(ref v),
) => { ) => {
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
Boolean::Not(ref v), Boolean::Not(ref v),
) => { ) => {
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
(OperandType::AllocatedFalse, OperandType::True, Boolean::Constant(true)) => {}, (OperandType::AllocatedFalse, OperandType::True, Boolean::Constant(true)) => {}
(OperandType::AllocatedFalse, OperandType::False, Boolean::Is(_)) => {}, (OperandType::AllocatedFalse, OperandType::False, Boolean::Is(_)) => {}
( (
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
Boolean::Is(ref v), Boolean::Is(ref v),
) => { ) => {
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
Boolean::Is(ref v), Boolean::Is(ref v),
) => { ) => {
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
Boolean::Not(ref v), Boolean::Not(ref v),
) => { ) => {
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
Boolean::Not(ref v), Boolean::Not(ref v),
) => { ) => {
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::True, OperandType::True,
Boolean::Constant(true), Boolean::Constant(true),
) => {}, ) => {}
(OperandType::NegatedAllocatedTrue, OperandType::False, Boolean::Not(_)) => {}, (OperandType::NegatedAllocatedTrue, OperandType::False, Boolean::Not(_)) => {}
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
Boolean::Not(ref v), Boolean::Not(ref v),
) => { ) => {
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
Boolean::Not(ref v), Boolean::Not(ref v),
) => { ) => {
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
Boolean::Not(ref v), Boolean::Not(ref v),
) => { ) => {
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
Boolean::Not(ref v), Boolean::Not(ref v),
) => { ) => {
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::True, OperandType::True,
Boolean::Constant(true), Boolean::Constant(true),
) => {}, ) => {}
(OperandType::NegatedAllocatedFalse, OperandType::False, Boolean::Not(_)) => {}, (OperandType::NegatedAllocatedFalse, OperandType::False, Boolean::Not(_)) => {}
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
Boolean::Not(ref v), Boolean::Not(ref v),
) => { ) => {
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
Boolean::Not(ref v), Boolean::Not(ref v),
) => { ) => {
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
Boolean::Not(ref v), Boolean::Not(ref v),
) => { ) => {
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
Boolean::Not(ref v), Boolean::Not(ref v),
) => { ) => {
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
_ => panic!( _ => panic!(
"this should never be encountered, in case: (a = {:?}, b = {:?}, c = {:?})", "this should never be encountered, in case: (a = {:?}, b = {:?}, c = {:?})",
@@ -1710,16 +1710,16 @@ mod test {
OperandType::False => Boolean::constant(false), OperandType::False => Boolean::constant(false),
OperandType::AllocatedTrue => { OperandType::AllocatedTrue => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap()) Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap())
}, }
OperandType::AllocatedFalse => { OperandType::AllocatedFalse => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap()) Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap())
}, }
OperandType::NegatedAllocatedTrue => { OperandType::NegatedAllocatedTrue => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap()).not() Boolean::from(AllocatedBit::alloc(cs, || Ok(true)).unwrap()).not()
}, }
OperandType::NegatedAllocatedFalse => { OperandType::NegatedAllocatedFalse => {
Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap()).not() Boolean::from(AllocatedBit::alloc(cs, || Ok(false)).unwrap()).not()
}, }
} }
}; };
@@ -1732,33 +1732,31 @@ mod test {
assert!(cs.is_satisfied()); assert!(cs.is_satisfied());
match (first_operand, second_operand, c) { match (first_operand, second_operand, c) {
(OperandType::True, OperandType::True, Boolean::Constant(true)) => {}, (OperandType::True, OperandType::True, Boolean::Constant(true)) => {}
(OperandType::True, OperandType::False, Boolean::Constant(false)) => {}, (OperandType::True, OperandType::False, Boolean::Constant(false)) => {}
(OperandType::True, OperandType::AllocatedTrue, Boolean::Is(_)) => {}, (OperandType::True, OperandType::AllocatedTrue, Boolean::Is(_)) => {}
(OperandType::True, OperandType::AllocatedFalse, Boolean::Is(_)) => {}, (OperandType::True, OperandType::AllocatedFalse, Boolean::Is(_)) => {}
(OperandType::True, OperandType::NegatedAllocatedTrue, Boolean::Not(_)) => {}, (OperandType::True, OperandType::NegatedAllocatedTrue, Boolean::Not(_)) => {}
(OperandType::True, OperandType::NegatedAllocatedFalse, Boolean::Not(_)) => {}, (OperandType::True, OperandType::NegatedAllocatedFalse, Boolean::Not(_)) => {}
(OperandType::False, OperandType::True, Boolean::Constant(false)) => {}, (OperandType::False, OperandType::True, Boolean::Constant(false)) => {}
(OperandType::False, OperandType::False, Boolean::Constant(false)) => {}, (OperandType::False, OperandType::False, Boolean::Constant(false)) => {}
(OperandType::False, OperandType::AllocatedTrue, Boolean::Constant(false)) => { (OperandType::False, OperandType::AllocatedTrue, Boolean::Constant(false)) => {}
},
(OperandType::False, OperandType::AllocatedFalse, Boolean::Constant(false)) => { (OperandType::False, OperandType::AllocatedFalse, Boolean::Constant(false)) => {
}, }
( (
OperandType::False, OperandType::False,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
Boolean::Constant(false), Boolean::Constant(false),
) => {}, ) => {}
( (
OperandType::False, OperandType::False,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
Boolean::Constant(false), Boolean::Constant(false),
) => {}, ) => {}
(OperandType::AllocatedTrue, OperandType::True, Boolean::Is(_)) => {}, (OperandType::AllocatedTrue, OperandType::True, Boolean::Is(_)) => {}
(OperandType::AllocatedTrue, OperandType::False, Boolean::Constant(false)) => { (OperandType::AllocatedTrue, OperandType::False, Boolean::Constant(false)) => {}
},
( (
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
@@ -1766,7 +1764,7 @@ mod test {
) => { ) => {
assert!(cs.get("and result") == Fr::one()); assert!(cs.get("and result") == Fr::one());
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
@@ -1774,7 +1772,7 @@ mod test {
) => { ) => {
assert!(cs.get("and result") == Fr::zero()); assert!(cs.get("and result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
@@ -1782,7 +1780,7 @@ mod test {
) => { ) => {
assert!(cs.get("and not result") == Fr::zero()); assert!(cs.get("and not result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
@@ -1790,11 +1788,11 @@ mod test {
) => { ) => {
assert!(cs.get("and not result") == Fr::one()); assert!(cs.get("and not result") == Fr::one());
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
(OperandType::AllocatedFalse, OperandType::True, Boolean::Is(_)) => {}, (OperandType::AllocatedFalse, OperandType::True, Boolean::Is(_)) => {}
(OperandType::AllocatedFalse, OperandType::False, Boolean::Constant(false)) => { (OperandType::AllocatedFalse, OperandType::False, Boolean::Constant(false)) => {
}, }
( (
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
@@ -1802,7 +1800,7 @@ mod test {
) => { ) => {
assert!(cs.get("and result") == Fr::zero()); assert!(cs.get("and result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
@@ -1810,7 +1808,7 @@ mod test {
) => { ) => {
assert!(cs.get("and result") == Fr::zero()); assert!(cs.get("and result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
@@ -1818,7 +1816,7 @@ mod test {
) => { ) => {
assert!(cs.get("and not result") == Fr::zero()); assert!(cs.get("and not result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
@@ -1826,14 +1824,14 @@ mod test {
) => { ) => {
assert!(cs.get("and not result") == Fr::zero()); assert!(cs.get("and not result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
(OperandType::NegatedAllocatedTrue, OperandType::True, Boolean::Not(_)) => {}, (OperandType::NegatedAllocatedTrue, OperandType::True, Boolean::Not(_)) => {}
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::False, OperandType::False,
Boolean::Constant(false), Boolean::Constant(false),
) => {}, ) => {}
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
@@ -1841,7 +1839,7 @@ mod test {
) => { ) => {
assert!(cs.get("and not result") == Fr::zero()); assert!(cs.get("and not result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
@@ -1849,7 +1847,7 @@ mod test {
) => { ) => {
assert!(cs.get("and not result") == Fr::zero()); assert!(cs.get("and not result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
@@ -1857,7 +1855,7 @@ mod test {
) => { ) => {
assert!(cs.get("nor result") == Fr::zero()); assert!(cs.get("nor result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
@@ -1865,14 +1863,14 @@ mod test {
) => { ) => {
assert!(cs.get("nor result") == Fr::zero()); assert!(cs.get("nor result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
(OperandType::NegatedAllocatedFalse, OperandType::True, Boolean::Not(_)) => {}, (OperandType::NegatedAllocatedFalse, OperandType::True, Boolean::Not(_)) => {}
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::False, OperandType::False,
Boolean::Constant(false), Boolean::Constant(false),
) => {}, ) => {}
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::AllocatedTrue, OperandType::AllocatedTrue,
@@ -1880,7 +1878,7 @@ mod test {
) => { ) => {
assert!(cs.get("and not result") == Fr::one()); assert!(cs.get("and not result") == Fr::one());
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::AllocatedFalse, OperandType::AllocatedFalse,
@@ -1888,7 +1886,7 @@ mod test {
) => { ) => {
assert!(cs.get("and not result") == Fr::zero()); assert!(cs.get("and not result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::NegatedAllocatedTrue, OperandType::NegatedAllocatedTrue,
@@ -1896,7 +1894,7 @@ mod test {
) => { ) => {
assert!(cs.get("nor result") == Fr::zero()); assert!(cs.get("nor result") == Fr::zero());
assert_eq!(v.value, Some(false)); assert_eq!(v.value, Some(false));
}, }
( (
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
OperandType::NegatedAllocatedFalse, OperandType::NegatedAllocatedFalse,
@@ -1904,14 +1902,14 @@ mod test {
) => { ) => {
assert!(cs.get("nor result") == Fr::one()); assert!(cs.get("nor result") == Fr::one());
assert_eq!(v.value, Some(true)); assert_eq!(v.value, Some(true));
}, }
_ => { _ => {
panic!( panic!(
"unexpected behavior at {:?} AND {:?}", "unexpected behavior at {:?} AND {:?}",
first_operand, second_operand first_operand, second_operand
); );
}, }
} }
} }
} }
@@ -2072,7 +2070,7 @@ mod test {
match r { match r {
Boolean::Is(ref r) => { Boolean::Is(ref r) => {
assert_eq!(r.value.unwrap(), expected); assert_eq!(r.value.unwrap(), expected);
}, }
_ => unreachable!(), _ => unreachable!(),
} }
} }

View File

@@ -55,7 +55,7 @@ impl UInt32 {
} }
v v
}, }
None => vec![None; 32], None => vec![None; 32],
}; };
@@ -94,19 +94,19 @@ impl UInt32 {
if b { if b {
value.as_mut().map(|v| *v |= 1); value.as_mut().map(|v| *v |= 1);
} }
}, }
&Boolean::Is(ref b) => match b.get_value() { &Boolean::Is(ref b) => match b.get_value() {
Some(true) => { Some(true) => {
value.as_mut().map(|v| *v |= 1); value.as_mut().map(|v| *v |= 1);
}, }
Some(false) => {}, Some(false) => {}
None => value = None, None => value = None,
}, },
&Boolean::Not(ref b) => match b.get_value() { &Boolean::Not(ref b) => match b.get_value() {
Some(false) => { Some(false) => {
value.as_mut().map(|v| *v |= 1); value.as_mut().map(|v| *v |= 1);
}, }
Some(true) => {}, Some(true) => {}
None => value = None, None => value = None,
}, },
} }
@@ -193,12 +193,12 @@ impl UInt32 {
match op.value { match op.value {
Some(val) => { Some(val) => {
result_value.as_mut().map(|v| *v += u64::from(val)); result_value.as_mut().map(|v| *v += u64::from(val));
}, }
None => { None => {
// If any of our operands have unknown value, we won't // If any of our operands have unknown value, we won't
// know the value of the result // know the value of the result
result_value = None; result_value = None;
}, }
} }
// Iterate over each bit_gadget of the operand and add the operand to // Iterate over each bit_gadget of the operand and add the operand to
@@ -211,18 +211,18 @@ impl UInt32 {
// Add coeff * bit_gadget // Add coeff * bit_gadget
lc += (coeff, bit.get_variable()); lc += (coeff, bit.get_variable());
}, }
Boolean::Not(ref bit) => { Boolean::Not(ref bit) => {
all_constants = false; all_constants = false;
// Add coeff * (1 - bit_gadget) = coeff * ONE - coeff * bit_gadget // Add coeff * (1 - bit_gadget) = coeff * ONE - coeff * bit_gadget
lc = lc + (coeff, CS::one()) - (coeff, bit.get_variable()); lc = lc + (coeff, CS::one()) - (coeff, bit.get_variable());
}, }
Boolean::Constant(bit) => { Boolean::Constant(bit) => {
if bit { if bit {
lc += (coeff, CS::one()); lc += (coeff, CS::one());
} }
}, }
} }
coeff.double_in_place(); coeff.double_in_place();
@@ -362,7 +362,7 @@ mod test {
match bit_gadget { match bit_gadget {
&Boolean::Constant(bit_gadget) => { &Boolean::Constant(bit_gadget) => {
assert!(bit_gadget == ((b.value.unwrap() >> i) & 1 == 1)); assert!(bit_gadget == ((b.value.unwrap() >> i) & 1 == 1));
}, }
_ => unreachable!(), _ => unreachable!(),
} }
} }
@@ -371,8 +371,8 @@ mod test {
for x in v.iter().zip(expected_to_be_same.iter()) { for x in v.iter().zip(expected_to_be_same.iter()) {
match x { match x {
(&Boolean::Constant(true), &Boolean::Constant(true)) => {}, (&Boolean::Constant(true), &Boolean::Constant(true)) => {}
(&Boolean::Constant(false), &Boolean::Constant(false)) => {}, (&Boolean::Constant(false), &Boolean::Constant(false)) => {}
_ => unreachable!(), _ => unreachable!(),
} }
} }
@@ -407,13 +407,13 @@ mod test {
match b { match b {
&Boolean::Is(ref b) => { &Boolean::Is(ref b) => {
assert!(b.get_value().unwrap() == (expected & 1 == 1)); assert!(b.get_value().unwrap() == (expected & 1 == 1));
}, }
&Boolean::Not(ref b) => { &Boolean::Not(ref b) => {
assert!(!b.get_value().unwrap() == (expected & 1 == 1)); assert!(!b.get_value().unwrap() == (expected & 1 == 1));
}, }
&Boolean::Constant(b) => { &Boolean::Constant(b) => {
assert!(b == (expected & 1 == 1)); assert!(b == (expected & 1 == 1));
}, }
} }
expected >>= 1; expected >>= 1;
@@ -448,7 +448,7 @@ mod test {
&Boolean::Not(_) => panic!(), &Boolean::Not(_) => panic!(),
&Boolean::Constant(b) => { &Boolean::Constant(b) => {
assert!(b == (expected & 1 == 1)); assert!(b == (expected & 1 == 1));
}, }
} }
expected >>= 1; expected >>= 1;
@@ -486,10 +486,10 @@ mod test {
match b { match b {
&Boolean::Is(ref b) => { &Boolean::Is(ref b) => {
assert!(b.get_value().unwrap() == (expected & 1 == 1)); assert!(b.get_value().unwrap() == (expected & 1 == 1));
}, }
&Boolean::Not(ref b) => { &Boolean::Not(ref b) => {
assert!(!b.get_value().unwrap() == (expected & 1 == 1)); assert!(!b.get_value().unwrap() == (expected & 1 == 1));
}, }
&Boolean::Constant(_) => unreachable!(), &Boolean::Constant(_) => unreachable!(),
} }
@@ -525,7 +525,7 @@ mod test {
match b { match b {
&Boolean::Constant(b) => { &Boolean::Constant(b) => {
assert_eq!(b, tmp & 1 == 1); assert_eq!(b, tmp & 1 == 1);
}, }
_ => unreachable!(), _ => unreachable!(),
} }

View File

@@ -134,19 +134,19 @@ impl UInt8 {
if b { if b {
value.as_mut().map(|v| *v |= 1); value.as_mut().map(|v| *v |= 1);
} }
}, }
Boolean::Is(ref b) => match b.get_value() { Boolean::Is(ref b) => match b.get_value() {
Some(true) => { Some(true) => {
value.as_mut().map(|v| *v |= 1); value.as_mut().map(|v| *v |= 1);
}, }
Some(false) => {}, Some(false) => {}
None => value = None, None => value = None,
}, },
Boolean::Not(ref b) => match b.get_value() { Boolean::Not(ref b) => match b.get_value() {
Some(false) => { Some(false) => {
value.as_mut().map(|v| *v |= 1); value.as_mut().map(|v| *v |= 1);
}, }
Some(true) => {}, Some(true) => {}
None => value = None, None => value = None,
}, },
} }
@@ -233,7 +233,7 @@ impl<ConstraintF: Field> AllocGadget<u8, ConstraintF> for UInt8 {
} }
v v
}, }
_ => vec![None; 8], _ => vec![None; 8],
}; };
@@ -272,7 +272,7 @@ impl<ConstraintF: Field> AllocGadget<u8, ConstraintF> for UInt8 {
} }
v v
}, }
_ => vec![None; 8], _ => vec![None; 8],
}; };
@@ -342,7 +342,7 @@ mod test {
match bit_gadget { match bit_gadget {
&Boolean::Constant(bit_gadget) => { &Boolean::Constant(bit_gadget) => {
assert!(bit_gadget == ((b.value.unwrap() >> i) & 1 == 1)); assert!(bit_gadget == ((b.value.unwrap() >> i) & 1 == 1));
}, }
_ => unreachable!(), _ => unreachable!(),
} }
} }
@@ -351,8 +351,8 @@ mod test {
for x in v.iter().zip(expected_to_be_same.iter()) { for x in v.iter().zip(expected_to_be_same.iter()) {
match x { match x {
(&Boolean::Constant(true), &Boolean::Constant(true)) => {}, (&Boolean::Constant(true), &Boolean::Constant(true)) => {}
(&Boolean::Constant(false), &Boolean::Constant(false)) => {}, (&Boolean::Constant(false), &Boolean::Constant(false)) => {}
_ => unreachable!(), _ => unreachable!(),
} }
} }
@@ -387,13 +387,13 @@ mod test {
match b { match b {
&Boolean::Is(ref b) => { &Boolean::Is(ref b) => {
assert!(b.get_value().unwrap() == (expected & 1 == 1)); assert!(b.get_value().unwrap() == (expected & 1 == 1));
}, }
&Boolean::Not(ref b) => { &Boolean::Not(ref b) => {
assert!(!b.get_value().unwrap() == (expected & 1 == 1)); assert!(!b.get_value().unwrap() == (expected & 1 == 1));
}, }
&Boolean::Constant(b) => { &Boolean::Constant(b) => {
assert!(b == (expected & 1 == 1)); assert!(b == (expected & 1 == 1));
}, }
} }
expected >>= 1; expected >>= 1;

View File

@@ -111,14 +111,14 @@ impl<F: PrimeField> FpGadget<F> {
Ordering::Less => { Ordering::Less => {
left = a; left = a;
right = b; right = b;
}, }
Ordering::Greater => { Ordering::Greater => {
left = b; left = b;
right = a; right = a;
}, }
Ordering::Equal => { Ordering::Equal => {
return Err(SynthesisError::Unsatisfiable); return Err(SynthesisError::Unsatisfiable);
}, }
}; };
let right_for_check = if should_also_check_equality { let right_for_check = if should_also_check_equality {
right.add_constant(cs.ns(|| "plus one"), &F::one())? right.add_constant(cs.ns(|| "plus one"), &F::one())?
@@ -252,7 +252,7 @@ mod test {
true, true,
) )
.unwrap(); .unwrap();
}, }
Ordering::Greater => { Ordering::Greater => {
a_var a_var
.enforce_cmp( .enforce_cmp(
@@ -270,8 +270,8 @@ mod test {
true, true,
) )
.unwrap(); .unwrap();
}, }
_ => {}, _ => {}
} }
if i == 0 { if i == 0 {
@@ -300,7 +300,7 @@ mod test {
true, true,
) )
.unwrap(); .unwrap();
}, }
Ordering::Greater => { Ordering::Greater => {
a_var a_var
.enforce_cmp( .enforce_cmp(
@@ -318,8 +318,8 @@ mod test {
true, true,
) )
.unwrap(); .unwrap();
}, }
_ => {}, _ => {}
} }
assert!(!cs.is_satisfied()); assert!(!cs.is_satisfied());

View File

@@ -364,7 +364,7 @@ impl<F: PrimeField> ToBitsGadget<F> for FpGadget<F> {
assert_eq!(tmp.len(), num_bits as usize); assert_eq!(tmp.len(), num_bits as usize);
tmp tmp
}, }
None => vec![None; num_bits as usize], None => vec![None; num_bits as usize],
}; };
@@ -422,7 +422,7 @@ impl<F: PrimeField> ToBytesGadget<F> for FpGadget<F> {
let default = F::default(); let default = F::default();
let default_len = to_bytes![&default].unwrap().len(); let default_len = to_bytes![&default].unwrap().len();
vec![None; default_len] vec![None; default_len]
}, }
}; };
let bytes = UInt8::alloc_vec(cs.ns(|| "Alloc bytes"), &byte_values)?; let bytes = UInt8::alloc_vec(cs.ns(|| "Alloc bytes"), &byte_values)?;
@@ -438,7 +438,7 @@ impl<F: PrimeField> ToBytesGadget<F> for FpGadget<F> {
Boolean::Is(bit) => { Boolean::Is(bit) => {
lc += (coeff, bit.get_variable()); lc += (coeff, bit.get_variable());
coeff.double_in_place(); coeff.double_in_place();
}, }
Boolean::Constant(_) | Boolean::Not(_) => unreachable!(), Boolean::Constant(_) | Boolean::Not(_) => unreachable!(),
} }
} }

View File

@@ -847,7 +847,7 @@ where
Ok(fe) => { Ok(fe) => {
let fe = *fe.borrow(); let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1)) (Ok(fe.c0), Ok(fe.c1))
}, }
Err(_) => ( Err(_) => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
@@ -872,7 +872,7 @@ where
Ok(fe) => { Ok(fe) => {
let fe = *fe.borrow(); let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1)) (Ok(fe.c0), Ok(fe.c1))
}, }
Err(_) => ( Err(_) => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),

View File

@@ -624,7 +624,7 @@ impl<P: Fp2Parameters<Fp = ConstraintF>, ConstraintF: PrimeField> AllocGadget<Fp
Ok(fe) => { Ok(fe) => {
let fe = *fe.borrow(); let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1)) (Ok(fe.c0), Ok(fe.c1))
}, }
Err(_) => ( Err(_) => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
@@ -649,7 +649,7 @@ impl<P: Fp2Parameters<Fp = ConstraintF>, ConstraintF: PrimeField> AllocGadget<Fp
Ok(fe) => { Ok(fe) => {
let fe = *fe.borrow(); let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1)) (Ok(fe.c0), Ok(fe.c1))
}, }
Err(_) => ( Err(_) => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),

View File

@@ -880,7 +880,7 @@ impl<P: Fp3Parameters<Fp = ConstraintF>, ConstraintF: PrimeField + SquareRootFie
Ok(fe) => { Ok(fe) => {
let fe = *fe.borrow(); let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1), Ok(fe.c2)) (Ok(fe.c0), Ok(fe.c1), Ok(fe.c2))
}, }
_ => ( _ => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
@@ -907,7 +907,7 @@ impl<P: Fp3Parameters<Fp = ConstraintF>, ConstraintF: PrimeField + SquareRootFie
Ok(fe) => { Ok(fe) => {
let fe = *fe.borrow(); let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1), Ok(fe.c2)) (Ok(fe.c0), Ok(fe.c1), Ok(fe.c2))
}, }
_ => ( _ => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),

View File

@@ -686,7 +686,7 @@ where
Ok(fe) => { Ok(fe) => {
let fe = *fe.borrow(); let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1)) (Ok(fe.c0), Ok(fe.c1))
}, }
Err(_) => ( Err(_) => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
@@ -711,7 +711,7 @@ where
Ok(fe) => { Ok(fe) => {
let fe = *fe.borrow(); let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1)) (Ok(fe.c0), Ok(fe.c1))
}, }
Err(_) => ( Err(_) => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),

View File

@@ -677,7 +677,7 @@ where
Ok(fe) => { Ok(fe) => {
let fe = *fe.borrow(); let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1)) (Ok(fe.c0), Ok(fe.c1))
}, }
Err(_) => ( Err(_) => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
@@ -702,7 +702,7 @@ where
Ok(fe) => { Ok(fe) => {
let fe = *fe.borrow(); let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1)) (Ok(fe.c0), Ok(fe.c1))
}, }
Err(_) => ( Err(_) => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),

View File

@@ -977,7 +977,7 @@ where
Ok(fe) => { Ok(fe) => {
let fe = *fe.borrow(); let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1), Ok(fe.c2)) (Ok(fe.c0), Ok(fe.c1), Ok(fe.c2))
}, }
_ => ( _ => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
@@ -1004,7 +1004,7 @@ where
Ok(fe) => { Ok(fe) => {
let fe = *fe.borrow(); let fe = *fe.borrow();
(Ok(fe.c0), Ok(fe.c1), Ok(fe.c2)) (Ok(fe.c0), Ok(fe.c1), Ok(fe.c2))
}, }
_ => ( _ => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),

View File

@@ -53,7 +53,7 @@ impl<P: SWModelParameters, ConstraintF: Field, F: FieldGadget<P::BaseField, Cons
Ok(ge) => { Ok(ge) => {
let ge = ge.into_affine(); let ge = ge.into_affine();
(Ok(ge.x), Ok(ge.y), Ok(ge.infinity)) (Ok(ge.x), Ok(ge.y), Ok(ge.infinity))
}, }
_ => ( _ => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
@@ -107,7 +107,7 @@ where
) { ) {
(Some(x), Some(y), Some(infinity)) => { (Some(x), Some(y), Some(infinity)) => {
Some(SWAffine::new(x, y, infinity).into_projective()) Some(SWAffine::new(x, y, infinity).into_projective())
}, }
(None, None, None) => None, (None, None, None) => None,
_ => unreachable!(), _ => unreachable!(),
} }
@@ -450,7 +450,7 @@ where
Ok(ge) => { Ok(ge) => {
let ge = ge.borrow().into_affine(); let ge = ge.borrow().into_affine();
(Ok(ge.x), Ok(ge.y), Ok(ge.infinity)) (Ok(ge.x), Ok(ge.y), Ok(ge.infinity))
}, }
_ => ( _ => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
@@ -574,7 +574,7 @@ where
Ok(ge) => { Ok(ge) => {
let ge = ge.borrow().into_affine(); let ge = ge.borrow().into_affine();
(Ok(ge.x), Ok(ge.y), Ok(ge.infinity)) (Ok(ge.x), Ok(ge.y), Ok(ge.infinity))
}, }
_ => ( _ => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),

View File

@@ -90,7 +90,7 @@ mod montgomery_affine_impl {
t0.mul_assign(&invy); t0.mul_assign(&invy);
Ok(t0) Ok(t0)
}, }
None => Err(SynthesisError::DivisionByZero), None => Err(SynthesisError::DivisionByZero),
} }
})?; })?;
@@ -108,7 +108,7 @@ mod montgomery_affine_impl {
t0.mul_assign(&t1); t0.mul_assign(&t1);
Ok(t0) Ok(t0)
}, }
None => Err(SynthesisError::DivisionByZero), None => Err(SynthesisError::DivisionByZero),
} }
})?; })?;
@@ -140,7 +140,7 @@ mod montgomery_affine_impl {
Some(d) => { Some(d) => {
n.mul_assign(&d); n.mul_assign(&d);
Ok(n) Ok(n)
}, }
None => Err(SynthesisError::DivisionByZero), None => Err(SynthesisError::DivisionByZero),
} }
})?; })?;
@@ -504,7 +504,7 @@ mod affine_impl {
Ok(ge) => { Ok(ge) => {
let ge = *ge.borrow(); let ge = *ge.borrow();
(Ok(ge.x), Ok(ge.y)) (Ok(ge.x), Ok(ge.y))
}, }
_ => ( _ => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
@@ -621,7 +621,7 @@ mod affine_impl {
Ok(ge) => { Ok(ge) => {
let ge = *ge.borrow(); let ge = *ge.borrow();
(Ok(ge.x), Ok(ge.y)) (Ok(ge.x), Ok(ge.y))
}, }
_ => ( _ => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
@@ -960,14 +960,14 @@ mod projective_impl {
match edwards_result { match edwards_result {
None => { None => {
edwards_result = Some(segment_result); edwards_result = Some(segment_result);
}, }
Some(ref mut edwards_result) => { Some(ref mut edwards_result) => {
*edwards_result = GroupGadget::<TEAffine<P>, ConstraintF>::add( *edwards_result = GroupGadget::<TEAffine<P>, ConstraintF>::add(
&segment_result, &segment_result,
cs.ns(|| "edwards addition"), cs.ns(|| "edwards addition"),
edwards_result, edwards_result,
)?; )?;
}, }
} }
Ok(()) Ok(())
@@ -1050,13 +1050,13 @@ mod projective_impl {
match result { match result {
None => { None => {
result = Some(tmp); result = Some(tmp);
}, }
Some(ref mut result) => { Some(ref mut result) => {
*result = tmp.add( *result = tmp.add(
cs.ns(|| format!("addition of window {}, {}", segment_i, i)), cs.ns(|| format!("addition of window {}, {}", segment_i, i)),
result, result,
)?; )?;
}, }
} }
} }
@@ -1101,7 +1101,7 @@ mod projective_impl {
Ok(ge) => { Ok(ge) => {
let ge = ge.borrow().into_affine(); let ge = ge.borrow().into_affine();
(Ok(ge.x), Ok(ge.y)) (Ok(ge.x), Ok(ge.y))
}, }
_ => ( _ => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
@@ -1223,7 +1223,7 @@ mod projective_impl {
Ok(ge) => { Ok(ge) => {
let ge = ge.borrow().into_affine(); let ge = ge.borrow().into_affine();
(Ok(ge.x), Ok(ge.y)) (Ok(ge.x), Ok(ge.y))
}, }
_ => ( _ => (
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),
Err(SynthesisError::AssignmentMissing), Err(SynthesisError::AssignmentMissing),

View File

@@ -36,7 +36,7 @@ impl<P: Bls12Parameters> PairingGadget<P> {
c1.c1 = c1.c1.mul(cs.ns(|| "mul c1.c1"), &p.x)?; c1.c1 = c1.c1.mul(cs.ns(|| "mul c1.c1"), &p.x)?;
*f = f.mul_by_014(cs.ns(|| "sparse mul f"), &c0, &c1, &c2)?; *f = f.mul_by_014(cs.ns(|| "sparse mul f"), &c0, &c1, &c2)?;
Ok(()) Ok(())
}, }
TwistType::D => { TwistType::D => {
let c0 = Fp2G::<P>::new(p.y.clone(), zero); let c0 = Fp2G::<P>::new(p.y.clone(), zero);
let mut c1 = coeffs.0.clone(); let mut c1 = coeffs.0.clone();
@@ -46,7 +46,7 @@ impl<P: Bls12Parameters> PairingGadget<P> {
c1.c1 = c1.c1.mul(cs.ns(|| "mul c1.c1"), &p.x)?; c1.c1 = c1.c1.mul(cs.ns(|| "mul c1.c1"), &p.x)?;
*f = f.mul_by_034(cs.ns(|| "sparse mul f"), &c0, &c1, &c2)?; *f = f.mul_by_034(cs.ns(|| "sparse mul f"), &c0, &c1, &c2)?;
Ok(()) Ok(())
}, }
} }
} }

View File

@@ -1,13 +1,9 @@
reorder_imports = true reorder_imports = true
wrap_comments = true wrap_comments = true
normalize_comments = true normalize_comments = true
format_strings = true
struct_field_align_threshold = 40
use_try_shorthand = true use_try_shorthand = true
match_block_trailing_comma = true match_block_trailing_comma = true
use_field_init_shorthand = true use_field_init_shorthand = true
edition = "2018" edition = "2018"
condense_wildcard_suffixes = true condense_wildcard_suffixes = true
merge_imports = true merge_imports = true
imports_layout = "Mixed"
unstable_features = true