ark-curves-cherry-picked/bn254/src/curves/g1.rs
bn254/src/curves/g1.rsRaw
1use ark_ec::{
2 models::{short_weierstrass::SWCurveConfig, CurveConfig},
3 short_weierstrass::Affine,
4};
5use ark_ff::{Field, MontFp, Zero};
6
7use crate::{Fq, Fr};
8
9#[derive(Clone, Default, PartialEq, Eq)]
10pub struct Parameters;
11
12pub type G1Affine = Affine<Parameters>;
13
14impl CurveConfig for Parameters {
15 type BaseField = Fq;
16 type ScalarField = Fr;
17
18 /// COFACTOR = 1
19 const COFACTOR: &'static [u64] = &[0x1];
20
21 /// COFACTOR_INV = COFACTOR^{-1} mod r = 1
22 const COFACTOR_INV: Fr = Fr::ONE;
23}
24
25impl SWCurveConfig for Parameters {
26 /// COEFF_A = 0
27 const COEFF_A: Fq = Fq::ZERO;
28
29 /// COEFF_B = 3
30 const COEFF_B: Fq = MontFp!("3");
31
32 /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
33 const GENERATOR: G1Affine = G1Affine::new_unchecked(G1_GENERATOR_X, G1_GENERATOR_Y);
34
35 #[inline(always)]
36 fn mul_by_a(_: &Self::BaseField) -> Self::BaseField {
37 Self::BaseField::zero()
38 }
39}
40
41/// G1_GENERATOR_X = 1
42pub const G1_GENERATOR_X: Fq = Fq::ONE;
43
44/// G1_GENERATOR_Y = 2
45pub const G1_GENERATOR_Y: Fq = MontFp!("2");