mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-10 01:33:07 +00:00
merge
This commit is contained in:
parent
50db118718
commit
2c2d36a6be
@ -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_curve;
|
||||
|
||||
@ -22,7 +22,7 @@ impl Curve for Secp256K1 {
|
||||
};
|
||||
}
|
||||
|
||||
const SECP256K1_GENERATOR_X: Secp256K1Base = Secp256K1Base([
|
||||
const SECP256K1_GENERATOR_X: Secp256K1Base = Secp256K1Base([
|
||||
0x59F2815B16F81798,
|
||||
0x029BFCDB2DCE28D9,
|
||||
0x55A06295CE870B07,
|
||||
@ -39,10 +39,10 @@ const SECP256K1_GENERATOR_Y: Secp256K1Base = Secp256K1Base([
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::field::field_types::Field;
|
||||
use crate::field::secp256k1_scalar::Secp256K1Scalar;
|
||||
use crate::curve::curve_types::{Curve, ProjectivePoint};
|
||||
use crate::curve::secp256k1_curve::Secp256K1;
|
||||
use crate::field::field_types::Field;
|
||||
use crate::field::secp256k1_scalar::Secp256K1Scalar;
|
||||
|
||||
/*#[test]
|
||||
fn test_double_affine() {
|
||||
|
||||
@ -81,7 +81,7 @@ impl Field for Secp256K1Scalar {
|
||||
0xBFD25E8CD0364140,
|
||||
0xBAAEDCE6AF48A03B,
|
||||
0xFFFFFFFFFFFFFC2F,
|
||||
0xFFFFFFFFFFFFFFFF
|
||||
0xFFFFFFFFFFFFFFFF,
|
||||
]);
|
||||
|
||||
// TODO: fix
|
||||
@ -106,7 +106,7 @@ impl Field for Secp256K1Scalar {
|
||||
fn order() -> BigUint {
|
||||
BigUint::from_slice(&[
|
||||
0xD0364141, 0xBFD25E8C, 0xAF48A03B, 0xBAAEDCE6, 0xFFFFFC2F, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF
|
||||
0xFFFFFFFF,
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ pub mod permutation;
|
||||
pub mod polynomial;
|
||||
pub mod random_access;
|
||||
pub mod range_check;
|
||||
pub mod secp256k1;
|
||||
pub mod select;
|
||||
pub mod sorting;
|
||||
pub mod split_base;
|
||||
|
||||
32
src/gadgets/secp256k1.rs
Normal file
32
src/gadgets/secp256k1.rs
Normal file
@ -0,0 +1,32 @@
|
||||
use crate::curve::curve_types::{AffinePoint, Curve};
|
||||
use crate::field::extension_field::Extendable;
|
||||
use crate::field::field_types::RichField;
|
||||
use crate::gadgets::nonnative::ForeignFieldTarget;
|
||||
use crate::plonk::circuit_builder::CircuitBuilder;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct AffinePointTarget<C: Curve> {
|
||||
pub x: ForeignFieldTarget<C::ScalarField>,
|
||||
pub y: ForeignFieldTarget<C::ScalarField>,
|
||||
}
|
||||
|
||||
impl<C: Curve> AffinePointTarget<C> {
|
||||
pub fn to_vec(&self) -> Vec<ForeignFieldTarget<C::ScalarField>> {
|
||||
vec![self.x.clone(), self.y.clone()]
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
pub fn constant_affine_point<C: Curve, InnerC: Curve<BaseField = C::ScalarField>>(
|
||||
&mut self,
|
||||
point: AffinePoint<InnerC>,
|
||||
) -> AffinePointTarget<C> {
|
||||
debug_assert!(!point.zero);
|
||||
AffinePointTarget {
|
||||
x: self.constant_ff(point.x),
|
||||
y: self.constant_ff(point.y),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod tests {}
|
||||
Loading…
x
Reference in New Issue
Block a user