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::{biginteger::BigInteger768, AdditiveGroup, BigInt, Field, Fp2, MontFp};
3
4use crate::{Fq, Fq2Config, Fq4Config, Fr};
5
6pub mod g1;
7pub mod g2;
8
9#[cfg(test)]
10mod tests;
11
12pub use self::{
13 g1::{G1Affine, G1Prepared, G1Projective},
14 g2::{G2Affine, G2Prepared, G2Projective},
15};
16
17pub type MNT4_753 = MNT4<Config>;
18
19pub struct Config;
20
21impl MNT4Config for Config {
22 const TWIST: Fp2<Self::Fp2Config> = Fp2::new(Fq::ZERO, Fq::ONE);
23 // A coefficient of MNT4-753 G2 =
24 // ```
25 // mnt4753_twist_coeff_a = mnt4753_Fq2(mnt4753_G1::coeff_a * non_residue, mnt6753_Fq::zero());
26 // = (A_COEFF * NONRESIDUE, ZERO)
27 // = (26, ZERO)
28 // ```
29 const TWIST_COEFF_A: Fp2<Self::Fp2Config> = Fp2::new(G1_COEFF_A_NON_RESIDUE, Fq::ZERO);
30 // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt4753.ml
31 const ATE_LOOP_COUNT: &'static [i8] = &[
32 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,
33 -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,
34 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,
35 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,
36 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,
37 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,
38 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,
39 -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,
40 -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,
41 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,
42 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,
43 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,
44 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,
45 0, 0, 0,
46 ];
47 const ATE_IS_LOOP_COUNT_NEG: bool = true;
48 const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger768 = BigInt!("0x1");
49 const FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG: bool = true;
50 // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt4753.ml#L100
51 const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger768 = BigInt!("204691208819330962009469868104636132783269696790011977400223898462431810102935615891307667367766898917669754470399");
52 type Fp = Fq;
53 type Fr = Fr;
54 type Fp2Config = Fq2Config;
55 type Fp4Config = Fq4Config;
56 type G1Config = self::g1::Config;
57 type G2Config = self::g2::Config;
58}
59
60// 26
61pub const G1_COEFF_A_NON_RESIDUE: Fq = MontFp!("26");