From bda96e84ee599355b239170341ff5c1e97d6f002 Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Fri, 23 Sep 2022 15:10:14 -0700 Subject: [PATCH] working on SquareRootGenerator instead of SquareGenerator --- plonky2/examples/square_root.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/plonky2/examples/square_root.rs b/plonky2/examples/square_root.rs index 86d53271..0aab8283 100644 --- a/plonky2/examples/square_root.rs +++ b/plonky2/examples/square_root.rs @@ -12,25 +12,27 @@ use plonky2::plonk::config::{GenericConfig, PoseidonGoldilocksConfig}; use plonky2_field::extension::Extendable; #[derive(Debug)] -struct SquareGenerator, const D: usize> { +struct SquareRootGenerator, const D: usize> { x: Target, x_squared: Target, _phantom: PhantomData, } -impl, const D: usize> SimpleGenerator for SquareGenerator { +impl, const D: usize> SimpleGenerator for SquareRootGenerator { fn dependencies(&self) -> Vec { - vec![self.x] + vec![self.x_squared] } fn run_once(&self, witness: &PartitionWitness, out_buffer: &mut GeneratedValues) { - let x = witness.get_target(self.x); - let x_squared = x * x; + let x_squared = witness.get_target(self.x); + let s = F::from_canonical_u32(4294967295); + let x = - out_buffer.set_target(self.x_squared, x_squared); + out_buffer.set_target(self.x, x); } } +/// An example of using Plonky2 to prove a statement of the form fn main() -> Result<()> { const D: usize = 2; type C = PoseidonGoldilocksConfig; @@ -46,11 +48,11 @@ fn main() -> Result<()> { builder.register_public_input(x); builder.register_public_input(x_squared); - builder.add_simple_generator(SquareGenerator:: { - x, - x_squared, - _phantom: PhantomData, - }); + // builder.add_simple_generator(SquareGenerator:: { + // x, + // x_squared, + // _phantom: PhantomData, + // }); let x_value = F::rand();