ark-curves-cherry-picked/secq256k1/src/curves/mod.rs
secq256k1/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<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 = 53718550993811904772965658690407829053653678808745171666022356150019200052646
47pub const G_GENERATOR_X: Fq =
48 MontFp!("53718550993811904772965658690407829053653678808745171666022356150019200052646");
49
50/// G_GENERATOR_Y = 28941648020349172432234515805717979317553499307621291159490218670604692907903
51pub const G_GENERATOR_Y: Fq =
52 MontFp!("28941648020349172432234515805717979317553499307621291159490218670604692907903");