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 crate::{Fq, Fr};
  2use ark_ec::{
  3    models::{ModelParameters, SWModelParameters},
  4    short_weierstrass_jacobian::{GroupAffine, GroupProjective},
  5};
  6use ark_ff::{
  7    biginteger::{BigInteger384, BigInteger768},
  8    field_new,
  9};
 10
 11pub type G2Affine = GroupAffine<Parameters>;
 12pub type G2Projective = GroupProjective<Parameters>;
 13
 14#[derive(Clone, Default, PartialEq, Eq)]
 15pub struct Parameters;
 16
 17impl ModelParameters for Parameters {
 18    type BaseField = Fq;
 19    type ScalarField = Fr;
 20}
 21
 22impl SWModelParameters for Parameters {
 23    /// COEFF_A = 0
 24    #[rustfmt::skip]
 25
 26    const COEFF_A: Fq = field_new!(Fq, BigInteger768([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]));
 27
 28    /// COEFF_B = 4
 29    #[rustfmt::skip]
 30    const COEFF_B: Fq = field_new!(Fq, BigInteger768([
 31        0x136efffffffe16c9,
 32        0x82cf5a6dcffe3319,
 33        0x6458c05f1f0e0741,
 34        0xd10ae605e52a4eda,
 35        0x41ca591c0266e100,
 36        0x7d0fd59c3626929f,
 37        0x9967dc004d00c112,
 38        0x1ccff9c033379af5,
 39        0x9ad6ec10a23f63af,
 40        0x5cec11251a72c235,
 41        0x8d18b1ae789ba83e,
 42        10403402007434220,
 43    ]));
 44
 45    /// COFACTOR =
 46    /// 26642435879335816683987677701488073867751118270052650655942102502312977592501693353047140953112195348280268661194869
 47    #[rustfmt::skip]
 48    const COFACTOR: &'static [u64] = &[
 49        0x3de5800000000075,
 50        0x832ba4061000003b,
 51        0xc61c554757551c0c,
 52        0xc856a0853c9db94c,
 53        0x2c77d5ac34cb12ef,
 54        0xad1972339049ce76,
 55    ];
 56
 57    /// COFACTOR^(-1) mod r =
 58    /// 214911522365886453591244899095480747723790054550866810551297776298664428889000553861210287833206024638187939842124
 59    #[rustfmt::skip]
 60    const COFACTOR_INV: Fr = field_new!(Fr, BigInteger384([
 61        14378295991815829998,
 62        14586153992421458638,
 63        9788477762582722914,
 64        12654821707953664524,
 65        15185631607604703397,
 66        26723985783783076,
 67    ]));
 68
 69    /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)
 70    const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
 71        (G2_GENERATOR_X, G2_GENERATOR_Y);
 72    #[inline(always)]
 73    fn mul_by_a(_elem: &Self::BaseField) -> Self::BaseField {
 74        use ark_ff::Zero;
 75        Self::BaseField::zero()
 76    }
 77}
 78
 79/// G2_GENERATOR_X =
 80///  6445332910596979336035888152774071626898886139774101364933948236926875073754470830732273879639675437155036544153105017729592600560631678554299562762294743927912429096636156401171909259073181112518725201388196280039960074422214428
 81#[rustfmt::skip]
 82pub const G2_GENERATOR_X: Fq = field_new!(Fq, BigInteger768([
 83    0x3d902a84cd9f4f78,
 84    0x864e451b8a9c05dd,
 85    0xc2b3c0d6646c5673,
 86    0x17a7682def1ecb9d,
 87    0xbe31a1e0fb768fe3,
 88    0x4df125e09b92d1a6,
 89    0x0943fce635b02ee9,
 90    0xffc8e7ad0605e780,
 91    0x8165c00a39341e95,
 92    0x8ccc2ae90a0f094f,
 93    0x73a8b8cc0ad09e0c,
 94    0x11027e203edd9f4,
 95]));
 96
 97/// G2_GENERATOR_Y =
 98/// 562923658089539719386922163444547387757586534741080263946953401595155211934630598999300396317104182598044793758153214972605680357108252243146746187917218885078195819486220416605630144001533548163105316661692978285266378674355041
 99#[rustfmt::skip]
100pub const G2_GENERATOR_Y: Fq = field_new!(Fq, BigInteger768([
101    0x9a159be4e773f67c,
102    0x6b957244aa8f4e6b,
103    0xa27b70c9c945a38c,
104    0xacb6a09fda11d0ab,
105    0x3abbdaa9bb6b1291,
106    0xdbdf642af5694c36,
107    0xb6360bb9560b369f,
108    0xac0bd1e822b8d6da,
109    0xfa355d17afe6945f,
110    0x8d6a0fc1fbcad35e,
111    0x72a63c7874409840,
112    0x114976e5b0db280,
113]));