More NIST curves (#142)

Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
This commit is contained in:
Ruben De Smet
2023-01-10 13:59:32 +01:00
committed by GitHub
parent bf8c488263
commit 69a9c3513b
27 changed files with 343 additions and 1 deletions

View File

@@ -0,0 +1,50 @@
use ark_ec::{
models::CurveConfig,
short_weierstrass::{self as sw, SWCurveConfig},
};
use ark_ff::{Field, MontFp};
use crate::{fq::Fq, fr::Fr};
#[cfg(test)]
mod tests;
pub type Affine = sw::Affine<Config>;
pub type Projective = sw::Projective<Config>;
#[derive(Copy, Clone, Default, PartialEq, Eq)]
pub struct Config;
impl CurveConfig for Config {
type BaseField = Fq;
type ScalarField = Fr;
/// COFACTOR = 1
const COFACTOR: &'static [u64] = &[0x1];
/// COFACTOR_INV = COFACTOR^{-1} mod r = 1
#[rustfmt::skip]
const COFACTOR_INV: Fr = Fr::ONE;
}
impl SWCurveConfig for Config {
/// COEFF_A = -3
const COEFF_A: Fq = MontFp!("-3");
/// COEFF_B = 41058363725152142129326129780047268409114441015993725554835256314039467401291
const COEFF_B: Fq =
MontFp!("41058363725152142129326129780047268409114441015993725554835256314039467401291");
/// GENERATOR = (G_GENERATOR_X, G_GENERATOR_Y)
const GENERATOR: Affine = Affine::new_unchecked(G_GENERATOR_X, G_GENERATOR_Y);
}
/// G_GENERATOR_X =
/// 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296
pub const G_GENERATOR_X: Fq =
MontFp!("48439561293906451759052585252797914202762949526041747995844080717082404635286");
/// G_GENERATOR_Y =
/// 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5
pub const G_GENERATOR_Y: Fq =
MontFp!("36134250956749795798585127919587881956611106672985015071877198253568414405109");

4
secp256r1/src/curves/tests.rs Executable file
View File

@@ -0,0 +1,4 @@
use crate::Projective;
use ark_algebra_test_templates::*;
test_group!(g1; Projective; sw);