arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/bn254/src/curves/g1.rs
bn254/src/curves/g1.rsRaw
 1use ark_ec::models::{ModelParameters, SWModelParameters};
 2use ark_ff::{biginteger::BigInteger256, 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, BigInteger256([0x0, 0x0, 0x0, 0x0]));
17
18    /// COEFF_B = 3
19    #[rustfmt::skip]
20    const COEFF_B: Fq = field_new!(Fq, BigInteger256([
21        0x7a17caa950ad28d7,
22        0x1f6ac17ae15521b9,
23        0x334bea4e696bd284,
24        0x2a1f6744ce179d8e,
25    ]));
26
27    /// COFACTOR = 1
28    const COFACTOR: &'static [u64] = &[0x1];
29
30    /// COFACTOR_INV = COFACTOR^{-1} mod r = 1
31    #[rustfmt::skip]
32    const COFACTOR_INV: Fr = field_new!(Fr, BigInteger256([
33        0xac96341c4ffffffb,
34        0x36fc76959f60cd29,
35        0x666ea36f7879462e,
36        0xe0a77c19a07df2f,
37    ]));
38
39    /// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
40    const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
41        (G1_GENERATOR_X, G1_GENERATOR_Y);
42
43    #[inline(always)]
44    fn mul_by_a(_: &Self::BaseField) -> Self::BaseField {
45        Self::BaseField::zero()
46    }
47}
48
49/// G1_GENERATOR_X =
50/// 1
51#[rustfmt::skip]
52pub const G1_GENERATOR_X: Fq = field_new!(Fq, BigInteger256([
53    0xd35d438dc58f0d9d,
54    0x0a78eb28f5c70b3d,
55    0x666ea36f7879462c,
56    0x0e0a77c19a07df2f,
57]));
58
59/// G1_GENERATOR_Y =
60/// 2
61#[rustfmt::skip]
62pub const G1_GENERATOR_Y: Fq = field_new!(Fq, BigInteger256([
63    0xa6ba871b8b1e1b3a,
64    0x14f1d651eb8e167b,
65    0xccdd46def0f28c58,
66    0x1c14ef83340fbe5e,
67]));