arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/bw6_761/src/curves/g2.rs
bw6_761/src/curves/g2.rsRaw
 1use ark_ec::{
 2    models::{short_weierstrass::SWCurveConfig, CurveConfig},
 3    short_weierstrass::{Affine, Projective},
 4};
 5use ark_ff::{Field, MontFp};
 6
 7use crate::{Fq, Fr};
 8
 9pub type G2Affine = Affine<Parameters>;
10pub type G2Projective = Projective<Parameters>;
11
12#[derive(Clone, Default, PartialEq, Eq)]
13pub struct Parameters;
14
15impl CurveConfig for Parameters {
16    type BaseField = Fq;
17    type ScalarField = Fr;
18
19    /// COFACTOR =
20    /// 26642435879335816683987677701488073867751118270052650655942102502312977592501693353047140953112195348280268661194869
21    #[rustfmt::skip]
22    const COFACTOR: &'static [u64] = &[
23        0x3de5800000000075,
24        0x832ba4061000003b,
25        0xc61c554757551c0c,
26        0xc856a0853c9db94c,
27        0x2c77d5ac34cb12ef,
28        0xad1972339049ce76,
29    ];
30
31    /// COFACTOR^(-1) mod r =
32    /// 214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124
33    const COFACTOR_INV: Fr = MontFp!("214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124");
34}
35
36impl SWCurveConfig for Parameters {
37    /// COEFF_A = 0
38    const COEFF_A: Fq = Fq::ZERO;
39
40    /// COEFF_B = 4
41    const COEFF_B: Fq = MontFp!("4");
42
43    /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)
44    const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y);
45
46    #[inline(always)]
47    fn mul_by_a(_elem: Self::BaseField) -> Self::BaseField {
48        use ark_ff::Zero;
49        Self::BaseField::zero()
50    }
51}
52
53/// G2_GENERATOR_X =
54///  6445332910596979336035888152774071626898886139774101364933948236926875073754470830732273879639675437155036544153105017729592600560631678554299562762294743927912429096636156401171909259073181112518725201388196280039960074422214428
55pub const G2_GENERATOR_X: Fq = MontFp!("6445332910596979336035888152774071626898886139774101364933948236926875073754470830732273879639675437155036544153105017729592600560631678554299562762294743927912429096636156401171909259073181112518725201388196280039960074422214428");
56
57/// G2_GENERATOR_Y =
58/// 562923658089539719386922163444547387757586534741080263946953401595155211934630598999300396317104182598044793758153214972605680357108252243146746187917218885078195819486220416605630144001533548163105316661692978285266378674355041
59pub const G2_GENERATOR_Y: Fq = MontFp!("562923658089539719386922163444547387757586534741080263946953401595155211934630598999300396317104182598044793758153214972605680357108252243146746187917218885078195819486220416605630144001533548163105316661692978285266378674355041");