ark-curves-cherry-picked/bls12_381/src/fields/fq2.rs
bls12_381/src/fields/fq2.rsRaw
1use crate::*;
2use ark_ff::{biginteger::BigInteger384 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 0x43f5fffffffcaaae,
15 0x32b7fff2ed47fffd,
16 0x7e83a49a2e99d69,
17 0xeca8f3318332bb7a,
18 0xef148d1ea0f4c069,
19 0x40ab3263eff0206,
20 ]));
21
22 /// QUADRATIC_NONRESIDUE = (U + 1)
23 #[rustfmt::skip]
24 const QUADRATIC_NONRESIDUE: (Fq, Fq) = (
25 field_new!(Fq, BigInteger([
26 0x760900000002fffd,
27 0xebf4000bc40c0002,
28 0x5f48985753c758ba,
29 0x77ce585370525745,
30 0x5c071a97a256ec6d,
31 0x15f65ec3fa80e493,
32 ])),
33 field_new!(Fq, BigInteger([
34 0x760900000002fffd,
35 0xebf4000bc40c0002,
36 0x5f48985753c758ba,
37 0x77ce585370525745,
38 0x5c071a97a256ec6d,
39 0x15f65ec3fa80e493,
40 ])),
41 );
42
43 /// Coefficients for the Frobenius automorphism.
44 #[rustfmt::skip]
45 const FROBENIUS_COEFF_FP2_C1: &'static [Fq] = &[
46 // Fq(-1)**(((q^0) - 1) / 2)
47 field_new!(Fq, BigInteger([
48 0x760900000002fffd,
49 0xebf4000bc40c0002,
50 0x5f48985753c758ba,
51 0x77ce585370525745,
52 0x5c071a97a256ec6d,
53 0x15f65ec3fa80e493,
54 ])),
55 // Fq(-1)**(((q^1) - 1) / 2)
56 field_new!(Fq, BigInteger([
57 0x43f5fffffffcaaae,
58 0x32b7fff2ed47fffd,
59 0x7e83a49a2e99d69,
60 0xeca8f3318332bb7a,
61 0xef148d1ea0f4c069,
62 0x40ab3263eff0206,
63 ])),
64 ];
65
66 #[inline(always)]
67 fn mul_fp_by_nonresidue(fp: &Self::Fp) -> Self::Fp {
68 -(*fp)
69 }
70}
71
72pub const FQ2_ZERO: Fq2 = field_new!(Fq2, FQ_ZERO, FQ_ZERO);
73pub const FQ2_ONE: Fq2 = field_new!(Fq2, FQ_ONE, FQ_ZERO);