ark-curves-cherry-picked/bls12_381/src/curves/g1.rs
bls12_381/src/curves/g1.rsRaw
1use crate::*;
2use ark_ec::{
3 bls12,
4 models::{ModelParameters, SWModelParameters},
5};
6use ark_ff::{field_new, Zero};
7
8pub type G1Affine = bls12::G1Affine<crate::Parameters>;
9pub type G1Projective = bls12::G1Projective<crate::Parameters>;
10
11#[derive(Clone, Default, PartialEq, Eq)]
12pub struct Parameters;
13
14impl ModelParameters for Parameters {
15 type BaseField = Fq;
16 type ScalarField = Fr;
17}
18
19impl SWModelParameters for Parameters {
20 /// COEFF_A = 0
21 const COEFF_A: Fq = field_new!(Fq, "0");
22
23 /// COEFF_B = 4
24 #[rustfmt::skip]
25 const COEFF_B: Fq = field_new!(Fq, "4");
26
27 /// COFACTOR = (x - 1)^2 / 3 = 76329603384216526031706109802092473003
28 const COFACTOR: &'static [u64] = &[0x8c00aaab0000aaab, 0x396c8c005555e156];
29
30 /// COFACTOR_INV = COFACTOR^{-1} mod r
31 /// = 52435875175126190458656871551744051925719901746859129887267498875565241663483
32 #[rustfmt::skip]
33 const COFACTOR_INV: Fr = field_new!(Fr, "52435875175126190458656871551744051925719901746859129887267498875565241663483");
34
35 /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
36 const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
37 (G1_GENERATOR_X, G1_GENERATOR_Y);
38
39 #[inline(always)]
40 fn mul_by_a(_: &Self::BaseField) -> Self::BaseField {
41 Self::BaseField::zero()
42 }
43}
44
45/// G1_GENERATOR_X =
46/// 3685416753713387016781088315183077757961620795782546409894578378688607592378376318836054947676345821548104185464507
47#[rustfmt::skip]
48pub const G1_GENERATOR_X: Fq = field_new!(Fq, "3685416753713387016781088315183077757961620795782546409894578378688607592378376318836054947676345821548104185464507");
49
50/// G1_GENERATOR_Y =
51/// 1339506544944476473020471379941921221584933875938349620426543736416511423956333506472724655353366534992391756441569
52#[rustfmt::skip]
53pub const G1_GENERATOR_Y: Fq = field_new!(Fq, "1339506544944476473020471379941921221584933875938349620426543736416511423956333506472724655353366534992391756441569");