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::{Field, MontFp, Zero};
6
7use crate::{fq::Fq, fr::Fr};
8
9#[cfg(test)]
10mod tests;
11
12pub type Affine = sw::Affine<Parameters>;
13pub type Projective = sw::Projective<Parameters>;
14
15#[derive(Copy, Clone, Default, PartialEq, Eq)]
16pub struct Parameters;
17
18impl CurveConfig for Parameters {
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 Parameters {
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 = 55066263022277343669578718895168534326250603453777594175500187360389116729240
47pub const G_GENERATOR_X: Fq =
48 MontFp!("55066263022277343669578718895168534326250603453777594175500187360389116729240");
49
50/// G_GENERATOR_Y = 32670510020758816978083085130507043184471273380659243275938904335757337482424
51pub const G_GENERATOR_Y: Fq =
52 MontFp!("32670510020758816978083085130507043184471273380659243275938904335757337482424");