ark_bls12_377/fields/
fq2.rs1use ark_ff::{fields::*, MontFp};
2
3use crate::*;
4
5pub type Fq2 = Fp2<Fq2Config>;
6
7pub struct Fq2Config;
8
9impl Fp2Config for Fq2Config {
10 type Fp = Fq;
11
12 const NONRESIDUE: Fq = MontFp!("-5");
14
15 const FROBENIUS_COEFF_FP2_C1: &'static [Fq] = &[
17 Fq::ONE,
19 MontFp!("-1"),
21 ];
22
23 #[inline(always)]
24 fn mul_fp_by_nonresidue_in_place(fe: &mut Self::Fp) -> &mut Self::Fp {
25 fe.neg_in_place();
26 *fe = *fe + fe.double_in_place().double_in_place();
27 fe
28 }
29
30 #[inline(always)]
31 fn sub_and_mul_fp_by_nonresidue(y: &mut Self::Fp, x: &Self::Fp) {
32 let mut original = *y;
33 original += x;
34 y.double_in_place().double_in_place();
35 *y += original;
36 }
37
38 #[inline(always)]
39 fn mul_fp_by_nonresidue_plus_one_and_add(y: &mut Self::Fp, x: &Self::Fp) {
40 y.double_in_place().double_in_place().neg_in_place();
41 *y += x;
42 }
43
44 fn mul_fp_by_nonresidue_and_add(y: &mut Self::Fp, x: &Self::Fp) {
45 let mut original = *y;
46 original.double_in_place().double_in_place();
47 original += &*y;
48 *y = *x;
49 *y -= original;
50 }
51}