arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/mnt4_753/src/curves/mod.rs
mnt4_753/src/curves/mod.rsRaw
 1use ark_ec::models::mnt4::{MNT4Config, MNT4};
 2use ark_ff::{
 3    biginteger::{BigInt, BigInteger768},
 4    AdditiveGroup, Field, Fp2, MontFp,
 5};
 6
 7use crate::{Fq, Fq2Config, Fq4Config, 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 MNT4_753 = MNT4<Config>;
21
22pub struct Config;
23
24impl MNT4Config for Config {
25    const TWIST: Fp2<Self::Fp2Config> = Fp2::new(Fq::ZERO, Fq::ONE);
26    // A coefficient of MNT4-753 G2 =
27    // ```
28    // mnt4753_twist_coeff_a = mnt4753_Fq2(mnt4753_G1::coeff_a * non_residue, mnt6753_Fq::zero());
29    //  = (A_COEFF * NONRESIDUE, ZERO)
30    //  = (26, ZERO)
31    // ```
32    const TWIST_COEFF_A: Fp2<Self::Fp2Config> = Fp2::new(G1_COEFF_A_NON_RESIDUE, Fq::ZERO);
33    // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt4753.ml
34    const ATE_LOOP_COUNT: &'static [i8] = &[
35        1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, 0, 1, 0, 0, 0, -1, 0,
36        -1, 0, -1, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1,
37        0, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 1, 0, -1, 0, 0, 0, -1, 0, 1, 0, 0, 0, -1, 0,
38        0, -1, 0, 1, 0, -1, 0, 0, 0, -1, 0, 0, -1, 0, 1, 0, 0, -1, 0, -1, 0, 1, 0, 1, 0, 0, 0, 0,
39        0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 1, 0, 0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, -1, 0, -1,
40        0, 0, 1, 0, 0, 1, 0, -1, 0, 1, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 1, 0, 0, -1, 0, 0, -1,
41        0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0, 0, -1, 0, 0,
42        -1, 0, 0, -1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
43        -1, 0, 0, 0, 1, 0, -1, 0, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, 1, 0, 0, -1, 0, -1, 0, -1, 0,
44        0, 0, 0, 0, 1, 0, -1, 0, 1, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0, 1, 0, 0, -1, 0, 0, 1,
45        0, -1, 0, -1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, -1, 0, -1, 0, 0, 0, 0, 1, 0, 0,
46        0, -1, 0, 1, 0, 1, 0, 0, 0, -1, 0, 0, -1, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0,
47        0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 1, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
48        0, 0, 0,
49    ];
50    const ATE_IS_LOOP_COUNT_NEG: bool = true;
51    const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger768 =
52        BigInt::new([0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]);
53    const FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG: bool = true;
54    const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger768 = BigInt::new([
55        8824542903220142079,
56        7711082599397206192,
57        8303354903384568230,
58        5874150271971943936,
59        9717849827920685054,
60        95829799234282493,
61        0,
62        0,
63        0,
64        0,
65        0,
66        0,
67    ]);
68    type Fp = Fq;
69    type Fr = Fr;
70    type Fp2Config = Fq2Config;
71    type Fp4Config = Fq4Config;
72    type G1Config = self::g1::Config;
73    type G2Config = self::g2::Config;
74}
75
76// 26
77pub const G1_COEFF_A_NON_RESIDUE: Fq = MontFp!("26");