mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-02 13:53:07 +00:00
cleanup and documentation
This commit is contained in:
parent
3bc1e65a7a
commit
a053372176
@ -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;
|
||||
|
||||
@ -19,6 +19,8 @@ struct SquareRootGenerator<F: RichField + Extendable<D>, const D: usize> {
|
||||
_phantom: PhantomData<F>,
|
||||
}
|
||||
|
||||
// We implement specifically for the Goldilocks field because it's currently the only field with
|
||||
// the sqrt() function written.
|
||||
impl SimpleGenerator<GoldilocksField> for SquareRootGenerator<GoldilocksField, 2> {
|
||||
fn dependencies(&self) -> Vec<Target> {
|
||||
vec![self.x_squared]
|
||||
@ -30,15 +32,14 @@ impl SimpleGenerator<GoldilocksField> for SquareRootGenerator<GoldilocksField, 2
|
||||
out_buffer: &mut GeneratedValues<GoldilocksField>,
|
||||
) {
|
||||
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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user