From a053372176cc83c804fa9af6b44cc189808a7ecd Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Mon, 26 Sep 2022 11:19:09 -0700 Subject: [PATCH] cleanup and documentation --- field/src/goldilocks_field.rs | 2 +- plonky2/examples/square_root.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/field/src/goldilocks_field.rs b/field/src/goldilocks_field.rs index 537b1f11..28d17a05 100644 --- a/field/src/goldilocks_field.rs +++ b/field/src/goldilocks_field.rs @@ -303,7 +303,7 @@ impl GoldilocksField { } else if self.is_quadratic_residue() { let t = (Self::order() - BigUint::from(1u32)) / (BigUint::from(2u32).pow(Self::TWO_ADICITY as u32)); - let mut z = Self::MULTIPLICATIVE_GROUP_GENERATOR.exp_biguint(&t); + let mut z = Self::POWER_OF_TWO_GENERATOR; let mut w = self.exp_biguint(&((t - BigUint::from(1u32)) / BigUint::from(2u32))); let mut x = w * *self; let mut b = x * w; diff --git a/plonky2/examples/square_root.rs b/plonky2/examples/square_root.rs index b20bf8e6..230b33aa 100644 --- a/plonky2/examples/square_root.rs +++ b/plonky2/examples/square_root.rs @@ -19,6 +19,8 @@ struct SquareRootGenerator, const D: usize> { _phantom: PhantomData, } +// We implement specifically for the Goldilocks field because it's currently the only field with +// the sqrt() function written. impl SimpleGenerator for SquareRootGenerator { fn dependencies(&self) -> Vec { vec![self.x_squared] @@ -30,15 +32,14 @@ impl SimpleGenerator for SquareRootGenerator, ) { let x_squared = witness.get_target(self.x_squared); - dbg!(x_squared); let x = x_squared.sqrt().unwrap(); - dbg!(x); out_buffer.set_target(self.x, x); } } /// An example of using Plonky2 to prove a statement of the form +/// "I know the square root of this field element." fn main() -> Result<()> { const D: usize = 2; type C = PoseidonGoldilocksConfig;