arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/mnt6_753/src/curves/mod.rs
mnt6_753/src/curves/mod.rsRaw
 1use ark_ff::{biginteger::BigInteger768, field_new, fields::FpParameters, Fp3};
 2
 3use ark_ec::models::{
 4    mnt6::{MNT6Parameters, MNT6},
 5    SWModelParameters,
 6};
 7
 8use crate::{Fq, Fq3, Fq3Parameters, Fq6Parameters, FqParameters, Fr, FrParameters};
 9
10pub mod g1;
11pub mod g2;
12
13#[cfg(test)]
14mod tests;
15
16pub use self::{
17    g1::{G1Affine, G1Prepared, G1Projective},
18    g2::{G2Affine, G2Prepared, G2Projective},
19};
20
21pub type MNT6_753 = MNT6<Parameters>;
22
23pub struct Parameters;
24
25impl MNT6Parameters for Parameters {
26    const TWIST: Fp3<Self::Fp3Params> = field_new!(Fq3, FQ_ZERO, FQ_ONE, FQ_ZERO);
27    // A coefficient of MNT6-753 G2 =
28    // ```
29    // mnt6753_twist_coeff_a = mnt6753_Fq3(mnt6753_Fq::zero(), mnt6753_Fq::zero(),
30    //                                  mnt6753_G1::coeff_a);
31    //  = (ZERO, ZERO, A_COEFF);
32    // ```
33    #[rustfmt::skip]
34    const TWIST_COEFF_A: Fp3<Self::Fp3Params> = field_new!(Fq3,
35        FQ_ZERO,
36        FQ_ZERO,
37        g1::Parameters::COEFF_A,
38    );
39    // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt6753.ml
40    const ATE_LOOP_COUNT: &'static [u64] = &[
41        8824542903220142080,
42        7711082599397206192,
43        8303354903384568230,
44        5874150271971943936,
45        9717849827920685054,
46        95829799234282493,
47    ];
48    const ATE_IS_LOOP_COUNT_NEG: bool = false;
49    const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger768 =
50        BigInteger768([0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]);
51    const FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG: bool = false;
52    const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger768 = BigInteger768([
53        8824542903220142080,
54        7711082599397206192,
55        8303354903384568230,
56        5874150271971943936,
57        9717849827920685054,
58        95829799234282493,
59        0,
60        0,
61        0,
62        0,
63        0,
64        0,
65    ]);
66    type Fp = Fq;
67    type Fr = Fr;
68    type Fp3Params = Fq3Parameters;
69    type Fp6Params = Fq6Parameters;
70    type G1Parameters = self::g1::Parameters;
71    type G2Parameters = self::g2::Parameters;
72}
73
74pub const FQ_ZERO: Fq = field_new!(Fq, BigInteger768([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]));
75pub const FQ_ONE: Fq = field_new!(Fq, FqParameters::R);
76pub const FR_ZERO: Fr = field_new!(Fr, BigInteger768([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]));
77pub const FR_ONE: Fr = field_new!(Fr, FrParameters::R);