ark-curves-cherry-picked/bn254/src/fields/fq2.rs
bn254/src/fields/fq2.rsRaw
1use super::*;
2use ark_ff::{field_new, fields::*};
3
4pub type Fq2 = Fp2<Fq2Parameters>;
5
6pub struct Fq2Parameters;
7
8impl Fp2Parameters for Fq2Parameters {
9 type Fp = Fq;
10
11 /// NONRESIDUE = -1
12 #[rustfmt::skip]
13 const NONRESIDUE: Fq = field_new!(Fq, "-1");
14
15 /// QUADRATIC_NONRESIDUE = U+2
16 #[rustfmt::skip]
17 const QUADRATIC_NONRESIDUE: (Fq, Fq) = (
18 field_new!(Fq, "2"),
19 field_new!(Fq, "1"),
20 );
21
22 /// Coefficients for the Frobenius automorphism.
23 #[rustfmt::skip]
24 const FROBENIUS_COEFF_FP2_C1: &'static [Fq] = &[
25 // NONRESIDUE**(((q^0) - 1) / 2)
26 field_new!(Fq, "1"),
27 // NONRESIDUE**(((q^1) - 1) / 2)
28 field_new!(Fq, "-1"),
29 ];
30
31 #[inline(always)]
32 fn mul_fp_by_nonresidue(fe: &Self::Fp) -> Self::Fp {
33 -(*fe)
34 }
35}
36
37pub const FQ2_ZERO: Fq2 = field_new!(Fq2, FQ_ZERO, FQ_ZERO);
38pub const FQ2_ONE: Fq2 = field_new!(Fq2, FQ_ONE, FQ_ZERO);