mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-11 10:13:09 +00:00
curve gadget changes
This commit is contained in:
parent
f11fe2a928
commit
0e6c5bb80c
@ -190,7 +190,7 @@ mod tests {
|
||||
affine_summation_batch_inversion, affine_summation_pairwise,
|
||||
};
|
||||
use crate::curve::curve_types::{Curve, ProjectivePoint};
|
||||
use crate::curve::secp256k1_curve::Secp256K1;
|
||||
use crate::curve::secp256k1::Secp256K1;
|
||||
|
||||
#[test]
|
||||
fn test_pairwise_affine_summation() {
|
||||
|
||||
@ -2,4 +2,4 @@ pub mod curve_adds;
|
||||
pub mod curve_multiplication;
|
||||
pub mod curve_summation;
|
||||
pub mod curve_types;
|
||||
pub mod secp256k1_curve;
|
||||
pub mod secp256k1;
|
||||
|
||||
@ -42,7 +42,7 @@ mod tests {
|
||||
use num::BigUint;
|
||||
|
||||
use crate::curve::curve_types::{Curve, ProjectivePoint};
|
||||
use crate::curve::secp256k1_curve::Secp256K1;
|
||||
use crate::curve::secp256k1::Secp256K1;
|
||||
use crate::field::field_types::Field;
|
||||
use crate::field::secp256k1_scalar::Secp256K1Scalar;
|
||||
|
||||
@ -51,6 +51,46 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
|
||||
self.connect_nonnative(&y_squared, &rhs);
|
||||
}
|
||||
|
||||
pub fn curve_neg<C: Curve>(&mut self, p: AffinePointTarget<C>) {
|
||||
let neg_y = self.neg_nonnative(p.y);
|
||||
AffinePointTarget {
|
||||
x: p.x,
|
||||
y: neg_y,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod tests {}
|
||||
mod tests {
|
||||
use anyhow::Result;
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_curve_gadget_is_valid() -> Result<()> {
|
||||
type F = CrandallField;
|
||||
const D: usize = 4;
|
||||
|
||||
let config = CircuitConfig::large_config();
|
||||
|
||||
let pw = PartialWitness::new();
|
||||
let mut builder = CircuitBuilder::<F, D>::new(config);
|
||||
|
||||
let
|
||||
|
||||
let lst: Vec<F> = (0..size * 2).map(|n| F::from_canonical_usize(n)).collect();
|
||||
let a: Vec<Vec<Target>> = lst[..]
|
||||
.chunks(2)
|
||||
.map(|pair| vec![builder.constant(pair[0]), builder.constant(pair[1])])
|
||||
.collect();
|
||||
let mut b = a.clone();
|
||||
b.shuffle(&mut thread_rng());
|
||||
|
||||
builder.assert_permutation(a, b);
|
||||
|
||||
let data = builder.build();
|
||||
let proof = data.prove(pw).unwrap();
|
||||
|
||||
verify(proof, &data.verifier_only, &data.common)
|
||||
}
|
||||
}
|
||||
@ -11,7 +11,7 @@ pub mod permutation;
|
||||
pub mod polynomial;
|
||||
pub mod random_access;
|
||||
pub mod range_check;
|
||||
pub mod secp256k1;
|
||||
pub mod curve;
|
||||
pub mod select;
|
||||
pub mod sorting;
|
||||
pub mod split_base;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user