ark-curves-cherry-picked/mnt4_298/src/fields/fq2.rs
mnt4_298/src/fields/fq2.rsRaw
1use ark_ff::{
2 fields::fp2::{Fp2, Fp2Config},
3 MontFp, QuadExt,
4};
5
6use crate::{Fq, FQ_ONE};
7
8pub type Fq2 = Fp2<Fq2Config>;
9
10pub struct Fq2Config;
11
12impl Fp2Config for Fq2Config {
13 type Fp = Fq;
14
15 /// The quadratic non-residue (17) used to construct the extension is
16 /// the same as that used in [`libff`](https://github.com/scipr-lab/libff/blob/c927821ebe02e0a24b5e0f9170cec5e211a35f08/libff/algebra/curves/mnt/mnt4/mnt4_init.cpp#L102).
17 const NONRESIDUE: Fq = MontFp!(Fq, "17");
18
19 /// The quadratic non-residue in F<sub>p</sub><sup>2</sup> that is used
20 /// in the computation of square roots is (8, 1), the same as that in
21 /// [`libff`](https://github.com/scipr-lab/libff/blob/c927821ebe02e0a24b5e0f9170cec5e211a35f08/libff/algebra/curves/mnt/mnt4/mnt4_init.cpp#L103)
22 const QUADRATIC_NONRESIDUE: Fq2 = QuadExt!(MontFp!(Fq, "8"), FQ_ONE);
23
24 /// Precomputed coefficients:
25 /// `[1, 475922286169261325753349249653048451545124879242694725395555128576210262817955800483758080]`
26 const FROBENIUS_COEFF_FP2_C1: &'static [Self::Fp] = &[
27 FQ_ONE,
28 MontFp!(Fq, "475922286169261325753349249653048451545124879242694725395555128576210262817955800483758080"),
29 ];
30}