ark-curves-cherry-picked/mnt4_753/src/curves/mod.rs
mnt4_753/src/curves/mod.rsRaw
1use ark_ec::models::mnt4::{MNT4Parameters, MNT4};
2use ark_ff::{
3 biginteger::{BigInt, BigInteger768},
4 field_new, Fp2,
5};
6
7use crate::{Fq, Fq2, Fq2Parameters, Fq4Parameters, 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<Parameters>;
21
22pub struct Parameters;
23
24impl MNT4Parameters for Parameters {
25 const TWIST: Fp2<Self::Fp2Params> = field_new!(Fq2, 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 #[rustfmt::skip]
33 const TWIST_COEFF_A: Fp2<Self::Fp2Params> = field_new!(Fq2,
34 G1_COEFF_A_NON_RESIDUE,
35 FQ_ZERO,
36 );
37 // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt4753.ml
38 const ATE_LOOP_COUNT: &'static [u64] = &[
39 8824542903220142080,
40 7711082599397206192,
41 8303354903384568230,
42 5874150271971943936,
43 9717849827920685054,
44 95829799234282493,
45 ];
46 const ATE_IS_LOOP_COUNT_NEG: bool = true;
47 const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger768 =
48 BigInt::new([0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]);
49 const FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG: bool = true;
50 const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger768 = BigInt::new([
51 8824542903220142079,
52 7711082599397206192,
53 8303354903384568230,
54 5874150271971943936,
55 9717849827920685054,
56 95829799234282493,
57 0,
58 0,
59 0,
60 0,
61 0,
62 0,
63 ]);
64 type Fp = Fq;
65 type Fr = Fr;
66 type Fp2Params = Fq2Parameters;
67 type Fp4Params = Fq4Parameters;
68 type G1Parameters = self::g1::Parameters;
69 type G2Parameters = self::g2::Parameters;
70}
71
72// 26
73pub const G1_COEFF_A_NON_RESIDUE: Fq = field_new!(Fq, "26");
74
75pub const FQ_ZERO: Fq = field_new!(Fq, "0");
76pub const FQ_ONE: Fq = field_new!(Fq, "1");
77pub const FR_ZERO: Fr = field_new!(Fr, "0");
78pub const FR_ONE: Fr = field_new!(Fr, "1");