use ark_ec::models::{ModelParameters, SWModelParameters}; use ark_ff::{MontFp, QuadExt, Zero}; use crate::{Fq, Fq2, Fr}; #[derive(Clone, Default, PartialEq, Eq)] pub struct Parameters; impl ModelParameters for Parameters { type BaseField = Fq2; type ScalarField = Fr; /// COFACTOR = (36 * X^4) + (36 * X^3) + (30 * X^2) + 6*X + 1 /// 21888242871839275222246405745257275088844257914179612981679871602714643921549 #[rustfmt::skip] const COFACTOR: &'static [u64] = &[ 0x345f2299c0f9fa8d, 0x06ceecda572a2489, 0xb85045b68181585e, 0x30644e72e131a029, ]; /// COFACTOR_INV = COFACTOR^{-1} mod r const COFACTOR_INV: Fr = MontFp!( Fr, "10944121435919637613327163357776759465618812564592884533313067514031822496649" ); } impl SWModelParameters for Parameters { /// COEFF_A = [0, 0] const COEFF_A: Fq2 = QuadExt!(MontFp!(Fq, "0"), MontFp!(Fq, "0")); /// COEFF_B = 3/(u+9) /// (19485874751759354771024239261021720505790618469301721065564631296452457478373, 266929791119991161246907387137283842545076965332900288569378510910307636690) const COEFF_B: Fq2 = QuadExt!( MontFp!( Fq, "19485874751759354771024239261021720505790618469301721065564631296452457478373" ), MontFp!( Fq, "266929791119991161246907387137283842545076965332900288569378510910307636690" ), ); /// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y) const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) = (G2_GENERATOR_X, G2_GENERATOR_Y); #[inline(always)] fn mul_by_a(_: &Self::BaseField) -> Self::BaseField { Self::BaseField::zero() } } pub const G2_GENERATOR_X: Fq2 = QuadExt!(G2_GENERATOR_X_C0, G2_GENERATOR_X_C1); pub const G2_GENERATOR_Y: Fq2 = QuadExt!(G2_GENERATOR_Y_C0, G2_GENERATOR_Y_C1); /// G2_GENERATOR_X_C0 = /// 10857046999023057135944570762232829481370756359578518086990519993285655852781 pub const G2_GENERATOR_X_C0: Fq = MontFp!( Fq, "10857046999023057135944570762232829481370756359578518086990519993285655852781" ); /// G2_GENERATOR_X_C1 = /// 11559732032986387107991004021392285783925812861821192530917403151452391805634 pub const G2_GENERATOR_X_C1: Fq = MontFp!( Fq, "11559732032986387107991004021392285783925812861821192530917403151452391805634" ); /// G2_GENERATOR_Y_C0 = /// 8495653923123431417604973247489272438418190587263600148770280649306958101930 pub const G2_GENERATOR_Y_C0: Fq = MontFp!( Fq, "8495653923123431417604973247489272438418190587263600148770280649306958101930" ); /// G2_GENERATOR_Y_C1 = /// 4082367875863433681332203403145435568316851327593401208105741076214120093531 pub const G2_GENERATOR_Y_C1: Fq = MontFp!( Fq, "4082367875863433681332203403145435568316851327593401208105741076214120093531" );