ark-curves-cherry-picked/bn254/src/fields/fq2.rs
bn254/src/fields/fq2.rsRaw
1use super::*;
2use ark_ff::{biginteger::BigInteger256 as BigInteger, 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, BigInteger([
14 0x68c3488912edefaa,
15 0x8d087f6872aabf4f,
16 0x51e1a24709081231,
17 0x2259d6b14729c0fa,
18 ]));
19
20 /// QUADRATIC_NONRESIDUE = U+2
21 #[rustfmt::skip]
22 const QUADRATIC_NONRESIDUE: (Fq, Fq) = (
23 field_new!(Fq, BigInteger([
24 12014063508332092218u64,
25 1509222997478479483u64,
26 14762033076929465432u64,
27 2023505479389396574u64,
28 ])),
29 field_new!(Fq, BigInteger([
30 202099033278250856u64,
31 8885205928937022213u64,
32 5545221690922665192u64,
33 39800542322357402u64,
34 ])),
35 );
36
37 /// Coefficients for the Frobenius automorphism.
38 #[rustfmt::skip]
39 const FROBENIUS_COEFF_FP2_C1: &'static [Fq] = &[
40 // NONRESIDUE**(((q^0) - 1) / 2)
41 field_new!(Fq, BigInteger([
42 0xd35d438dc58f0d9d,
43 0x0a78eb28f5c70b3d,
44 0x666ea36f7879462c,
45 0xe0a77c19a07df2f,
46 ])),
47 // NONRESIDUE**(((q^1) - 1) / 2)
48 field_new!(Fq, BigInteger([
49 0x68c3488912edefaa,
50 0x8d087f6872aabf4f,
51 0x51e1a24709081231,
52 0x2259d6b14729c0fa,
53 ])),
54 ];
55
56 #[inline(always)]
57 fn mul_fp_by_nonresidue(fe: &Self::Fp) -> Self::Fp {
58 -(*fe)
59 }
60}
61
62pub const FQ2_ZERO: Fq2 = field_new!(Fq2, FQ_ZERO, FQ_ZERO);
63pub const FQ2_ONE: Fq2 = field_new!(Fq2, FQ_ONE, FQ_ZERO);