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::{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    /// COFACTOR = 1
14    const COFACTOR: &'static [u64] = &[0x1];
15
16    /// COFACTOR_INV = COFACTOR^{-1} mod r = 1
17    const COFACTOR_INV: Fr = field_new!(Fr, "1");
18}
19
20impl SWModelParameters for Parameters {
21    /// COEFF_A = 0
22    const COEFF_A: Fq = field_new!(Fq, "0");
23
24    /// COEFF_B = 3
25    const COEFF_B: Fq = field_new!(Fq, "3");
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");