ark-curves-cherry-picked/mnt4_298/src/curves/mod.rs
mnt4_298/src/curves/mod.rsRaw
1use ark_ec::models::mnt4::{MNT4Parameters, MNT4};
2use ark_ff::{biginteger::BigInteger320, BigInt, Field, MontFp};
3
4use crate::{Fq, Fq2, 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_298 = MNT4<Parameters>;
18
19pub struct Parameters;
20
21impl MNT4Parameters for Parameters {
22 const TWIST: Fq2 = Fq2::new(Fq::ZERO, Fq::ONE);
23 // A coefficient of MNT4-298 G2 =
24 // ```
25 // mnt4298_twist_coeff_a = mnt4298_Fq2(mnt4298_G1::coeff_a * non_residue, mnt6298_Fq::zero());
26 // = (A_COEFF * NONRESIDUE, ZERO)
27 // = (34, ZERO)
28 // ```
29 const TWIST_COEFF_A: Fq2 = Fq2::new(G1_COEFF_A_NON_RESIDUE, Fq::ZERO);
30
31 // https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt4_80.ml#L88
32 const ATE_LOOP_COUNT: &'static [i8] = &[
33 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,
34 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,
35 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,
36 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,
37 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,
38 0, 0, 0, 0, 0, 0,
39 ];
40 const ATE_IS_LOOP_COUNT_NEG: bool = false;
41 const FINAL_EXPONENT_LAST_CHUNK_1: BigInteger320 = BigInt::new([0x1, 0x0, 0x0, 0x0, 0x0]);
42 const FINAL_EXPONENT_LAST_CHUNK_W0_IS_NEG: bool = false;
43 const FINAL_EXPONENT_LAST_CHUNK_ABS_OF_W0: BigInteger320 =
44 BigInt::new([993502997770534913, 5071219579242586943, 2027349, 0, 0]);
45 type Fp = Fq;
46 type Fr = Fr;
47 type Fp2Config = Fq2Config;
48 type Fp4Config = Fq4Config;
49 type G1Parameters = self::g1::Parameters;
50 type G2Parameters = self::g2::Parameters;
51}
52
53// 34
54pub const G1_COEFF_A_NON_RESIDUE: Fq = MontFp!("34");