arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/mnt6_298/src/curves/mod.rs
mnt6_298/src/curves/mod.rsRaw
 1use ark_ec::{
 2    models::mnt6::{MNT6Config, MNT6},
 3    short_weierstrass::SWCurveConfig,
 4};
 5use ark_ff::{biginteger::BigInteger320, AdditiveGroup, BigInt, Field, Fp3};
 6
 7use crate::{Fq, Fq3Config, Fq6Config, Fr};
 8
 9pub mod g1;
10pub mod g2;
11
12#[cfg(test)]
13mod tests;
14
15pub use self::{
16    g1::{G1Affine, G1Prepared, G1Projective},
17    g2::{G2Affine, G2Prepared, G2Projective},
18};
19
20pub type MNT6_298 = MNT6<Config>;
21
22pub struct Config;
23
24impl MNT6Config for Config {
25    const TWIST: Fp3<Self::Fp3Config> = Fp3::<Self::Fp3Config>::new(Fq::ZERO, Fq::ONE, Fq::ZERO);
26    const TWIST_COEFF_A: Fp3<Self::Fp3Config> =
27        Fp3::<Self::Fp3Config>::new(Fq::ZERO, Fq::ZERO, g1::Config::COEFF_A);
28
29    // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt6_80.ml#L118
30    const ATE_LOOP_COUNT: &'static [i8] = &[
31        1, 0, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, -1,
32        0, 1, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, -1, 0, -1, 0, -1, 0, 0, -1, 0, -1, 0,
33        0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, -1, 0, 1, 0, 0, 0, 0, 0, -1,
34        0, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, 0, 0, 1, 0, 0, -1, 0, 0, -1,
35        0, -1, 0, 1, 0, 0, -1, 0, 0, 1, 0, -1, 0, -1, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
36        0, 0, 0, 0, 0, 0,
37    ];
38    const ATE_IS_LOOP_COUNT_NEG: bool = true;
39    const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger320 = BigInt!("0x1");
40    const FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG: bool = true;
41    // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt6_80.ml#L126
42    const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger320 =
43        BigInt!("689871209842287392837045615510547309923794944");
44    type Fp = Fq;
45    type Fr = Fr;
46    type Fp3Config = Fq3Config;
47    type Fp6Config = Fq6Config;
48    type G1Config = self::g1::Config;
49    type G2Config = self::g2::Config;
50}