mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-13 03:03:05 +00:00
comments and renaming
This commit is contained in:
parent
8de59c2a84
commit
f4ca0df85d
@ -1,7 +1,7 @@
|
||||
use crate::circuit_builder::CircuitBuilder;
|
||||
use crate::field::extension_field::target::ExtensionTarget;
|
||||
use crate::field::extension_field::Extendable;
|
||||
use crate::generator::EqualityGenerator;
|
||||
use crate::generator::EqualsZeroGenerator;
|
||||
use crate::target::Target;
|
||||
|
||||
impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
@ -10,7 +10,7 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
let m = todo!();
|
||||
let y = todo!();
|
||||
|
||||
self.add_generator(EqualityGenerator { x, m, y });
|
||||
self.add_generator(EqualsZeroGenerator { x, m, y });
|
||||
|
||||
y
|
||||
}
|
||||
|
||||
@ -131,32 +131,32 @@ impl<F: Field> SimpleGenerator<F> for RandomValueGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
/// A generator for including a random value
|
||||
pub(crate) struct EqualityGenerator {
|
||||
pub(crate) x: Target,
|
||||
pub(crate) m: Target,
|
||||
pub(crate) y: Target,
|
||||
/// A generator for testing if a value equals zero
|
||||
pub(crate) struct EqualsZeroGenerator {
|
||||
pub(crate) to_test: Target,
|
||||
pub(crate) dummy: Target,
|
||||
pub(crate) is_zero: Target,
|
||||
}
|
||||
|
||||
impl<F: Field> SimpleGenerator<F> for EqualityGenerator {
|
||||
impl<F: Field> SimpleGenerator<F> for EqualsZeroGenerator {
|
||||
fn dependencies(&self) -> Vec<Target> {
|
||||
vec![self.x]
|
||||
vec![self.to_test]
|
||||
}
|
||||
|
||||
fn run_once(&self, witness: &PartialWitness<F>) -> PartialWitness<F> {
|
||||
let x_value = witness.get_target(self.x);
|
||||
let to_test_value = witness.get_target(self.to_test);
|
||||
|
||||
let y_value = if x_value == F::ZERO { F::ZERO } else { F::ONE };
|
||||
let is_zero_value = if to_test_value == F::ZERO { F::ZERO } else { F::ONE };
|
||||
|
||||
let m_value = if x_value == F::ZERO {
|
||||
let dummy_value = if to_test_value == F::ZERO {
|
||||
F::ONE
|
||||
} else {
|
||||
x_value.inverse()
|
||||
to_test_value.inverse()
|
||||
};
|
||||
|
||||
let mut witness = PartialWitness::new();
|
||||
witness.set_target(self.m, m_value);
|
||||
witness.set_target(self.y, y_value);
|
||||
witness.set_target(self.dummy, dummy_value);
|
||||
witness.set_target(self.is_zero, is_zero_value);
|
||||
witness
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user