arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/bls12_377/src/curves/g1.rs
bls12_377/src/curves/g1.rsRaw
 1use ark_ec::models::{ModelParameters, SWModelParameters};
 2use ark_ff::{
 3    biginteger::{BigInteger256, BigInteger384},
 4    field_new, Zero,
 5};
 6
 7use crate::{Fq, Fr};
 8
 9#[derive(Clone, Default, PartialEq, Eq)]
10pub struct Parameters;
11
12impl ModelParameters for Parameters {
13    type BaseField = Fq;
14    type ScalarField = Fr;
15}
16
17impl SWModelParameters for Parameters {
18    /// COEFF_A = 0
19    const COEFF_A: Fq = field_new!(Fq, BigInteger384([0x0, 0x0, 0x0, 0x0, 0x0, 0x0]));
20
21    /// COEFF_B = 1
22    #[rustfmt::skip]
23    const COEFF_B: Fq = field_new!(Fq, BigInteger384([
24        0x2cdffffffffff68,
25        0x51409f837fffffb1,
26        0x9f7db3a98a7d3ff2,
27        0x7b4e97b76e7c6305,
28        0x4cf495bf803c84e8,
29        0x8d6661e2fdf49a,
30    ]));
31
32    /// COFACTOR = (x - 1)^2 / 3  = 30631250834960419227450344600217059328
33    const COFACTOR: &'static [u64] = &[0x0, 0x170b5d4430000000];
34
35    /// COFACTOR_INV = COFACTOR^{-1} mod r
36    /// = 5285428838741532253824584287042945485047145357130994810877
37    #[rustfmt::skip]
38    const COFACTOR_INV: Fr = field_new!(Fr, BigInteger256([
39        2013239619100046060,
40        4201184776506987597,
41        2526766393982337036,
42        1114629510922847535,
43    ]));
44
45    /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
46    const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
47        (G1_GENERATOR_X, G1_GENERATOR_Y);
48
49    #[inline(always)]
50    fn mul_by_a(_: &Self::BaseField) -> Self::BaseField {
51        Self::BaseField::zero()
52    }
53}
54
55/// G1_GENERATOR_X =
56/// 81937999373150964239938255573465948239988671502647976594219695644855304257327692006745978603320413799295628339695
57#[rustfmt::skip]
58pub const G1_GENERATOR_X: Fq = field_new!(Fq, BigInteger384([
59    0x260f33b9772451f4,
60    0xc54dd773169d5658,
61    0x5c1551c469a510dd,
62    0x761662e4425e1698,
63    0xc97d78cc6f065272,
64    0xa41206b361fd4d,
65]));
66
67/// G1_GENERATOR_Y =
68/// 241266749859715473739788878240585681733927191168601896383759122102112907357779751001206799952863815012735208165030
69#[rustfmt::skip]
70pub const G1_GENERATOR_Y: Fq = field_new!(Fq, BigInteger384([
71    0x8193961fb8cb81f3,
72    0x638d4c5f44adb8,
73    0xfafaf3dad4daf54a,
74    0xc27849e2d655cd18,
75    0x2ec3ddb401d52814,
76    0x7da93326303c71,
77]));