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