From 39b22a6cab780adf2e99c14218584ae3b4c8defe Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Thu, 1 Jul 2021 12:00:56 -0700 Subject: [PATCH] addressed nits --- src/gadgets/insert.rs | 5 ++++- src/generator.rs | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gadgets/insert.rs b/src/gadgets/insert.rs index 64260209..7a1ee98d 100644 --- a/src/gadgets/insert.rs +++ b/src/gadgets/insert.rs @@ -6,11 +6,14 @@ use crate::target::Target; impl, const D: usize> CircuitBuilder { /// 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, diff --git a/src/generator.rs b/src/generator.rs index 3795fdfa..a47c5267 100644 --- a/src/generator.rs +++ b/src/generator.rs @@ -151,8 +151,6 @@ impl SimpleGenerator 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) } }