addressed nits

This commit is contained in:
Nicholas Ward 2021-07-01 12:00:56 -07:00
parent efe39f2d63
commit 39b22a6cab
2 changed files with 5 additions and 4 deletions

View File

@ -6,11 +6,14 @@ use crate::target::Target;
impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
/// Evaluates to 0 if `x` equals zero, 1 otherwise.
/// From section 2 of https://github.com/mir-protocol/r1cs-workshop/blob/master/workshop.pdf,
/// based on an idea from https://eprint.iacr.org/2012/598.pdf.
pub fn is_nonzero(&mut self, x: Target) -> Target {
// Dummy variable.
let m = self.add_virtual_target();
// The prover sets the dummy variable to 0 if x == 0 and to 1/x otherwise.
// The prover sets this the dummy variable to 1/x if x != 0, or to an arbitrary value if
// x == 0.
self.add_generator(NonzeroTestGenerator {
to_test: x,
dummy: m,

View File

@ -151,8 +151,6 @@ impl<F: Field> SimpleGenerator<F> for NonzeroTestGenerator {
to_test_value.inverse()
};
let mut witness = PartialWitness::new();
witness.set_target(self.dummy, dummy_value);
witness
PartialWitness::singleton_target(self.dummy, dummy_value)
}
}