mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-09 01:03:08 +00:00
addressed nits
This commit is contained in:
parent
efe39f2d63
commit
39b22a6cab
@ -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,
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user