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