arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/secp256k1/src/curves/mod.rs
secp256k1/src/curves/mod.rsRaw
 1use ark_ec::{
 2    models::CurveConfig,
 3    short_weierstrass::{self as sw, SWCurveConfig},
 4};
 5use ark_ff::{AdditiveGroup, Field, MontFp, Zero};
 6
 7use crate::{fq::Fq, fr::Fr};
 8
 9#[cfg(test)]
10mod tests;
11
12pub type Affine = sw::Affine<Config>;
13pub type Projective = sw::Projective<Config>;
14
15#[derive(Copy, Clone, Default, PartialEq, Eq)]
16pub struct Config;
17
18impl CurveConfig for Config {
19    type BaseField = Fq;
20    type ScalarField = Fr;
21
22    /// COFACTOR = 1
23    const COFACTOR: &'static [u64] = &[0x1];
24
25    /// COFACTOR_INV = COFACTOR^{-1} mod r = 1
26    #[rustfmt::skip]
27    const COFACTOR_INV: Fr =  Fr::ONE;
28}
29
30impl SWCurveConfig for Config {
31    /// COEFF_A = 0
32    const COEFF_A: Fq = Fq::ZERO;
33
34    /// COEFF_B = 7
35    const COEFF_B: Fq = MontFp!("7");
36
37    /// GENERATOR = (G_GENERATOR_X, G_GENERATOR_Y)
38    const GENERATOR: Affine = Affine::new_unchecked(G_GENERATOR_X, G_GENERATOR_Y);
39
40    #[inline(always)]
41    fn mul_by_a(_: Self::BaseField) -> Self::BaseField {
42        Self::BaseField::zero()
43    }
44}
45
46/// G_GENERATOR_X =
47/// 55066263022277343669578718895168534326250603453777594175500187360389116729240
48pub const G_GENERATOR_X: Fq =
49    MontFp!("55066263022277343669578718895168534326250603453777594175500187360389116729240");
50
51/// G_GENERATOR_Y =
52/// 32670510020758816978083085130507043184471273380659243275938904335757337482424
53pub const G_GENERATOR_Y: Fq =
54    MontFp!("32670510020758816978083085130507043184471273380659243275938904335757337482424");