ark-curves-cherry-picked/mnt4_298/src/fields/fq2.rs
mnt4_298/src/fields/fq2.rsRaw
1use crate::{Fq, FQ_ONE};
2use ark_ff::{
3 biginteger::BigInteger320 as BigInteger,
4 field_new,
5 fields::fp2::{Fp2, Fp2Parameters},
6};
7
8pub type Fq2 = Fp2<Fq2Parameters>;
9
10pub struct Fq2Parameters;
11
12impl Fp2Parameters for Fq2Parameters {
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 #[rustfmt::skip]
18 const NONRESIDUE: Fq = field_new!(Fq, BigInteger([
19 2709730703260633621,
20 13556085429182073539,
21 10903316137158576359,
22 5319113788683590444,
23 4022235209932,
24 ]));
25
26 /// The quadratic non-residue in F<sub>p</sub><sup>2</sup> that is used
27 /// in the computation of square roots is (8, 1), the same as that in
28 /// [`libff`](https://github.com/scipr-lab/libff/blob/c927821ebe02e0a24b5e0f9170cec5e211a35f08/libff/algebra/curves/mnt/mnt4/mnt4_init.cpp#L103)
29 const QUADRATIC_NONRESIDUE: (Self::Fp, Self::Fp) = (
30 field_new!(
31 Fq,
32 BigInteger([
33 7706310747053761245,
34 9941175645274129776,
35 14857322459377157960,
36 7030003475866554129,
37 3101682770110
38 ])
39 ),
40 FQ_ONE,
41 );
42
43 /// Precomputed coefficients:
44 /// `[1, 475922286169261325753349249653048451545124879242694725395555128576210262817955800483758080]`
45 const FROBENIUS_COEFF_FP2_C1: &'static [Self::Fp] = &[
46 FQ_ONE,
47 field_new!(
48 Fq,
49 BigInteger([
50 12702890790846888869,
51 6326265861366186013,
52 364584707886187945,
53 8740893163049517815,
54 2181130330288
55 ])
56 ),
57 ];
58}