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