ark-curves-cherry-picked/bls12_381/src/fields/fq6.rs
bls12_381/src/fields/fq6.rsRaw
1use crate::*;
2use ark_ff::{field_new, fields::*};
3
4pub type Fq6 = Fp6<Fq6Parameters>;
5
6#[derive(Clone, Copy)]
7pub struct Fq6Parameters;
8
9impl Fp6Parameters for Fq6Parameters {
10 type Fp2Params = Fq2Parameters;
11
12 /// NONRESIDUE = (U + 1)
13 #[rustfmt::skip]
14 const NONRESIDUE: Fq2 = field_new!(Fq2,
15 field_new!(Fq, "1"),
16 field_new!(Fq, "1"),
17 );
18
19 #[rustfmt::skip]
20 const FROBENIUS_COEFF_FP6_C1: &'static [Fq2] = &[
21 // Fp2::NONRESIDUE^(((q^0) - 1) / 3)
22 field_new!(Fq2,
23 field_new!(Fq, "1"),
24 field_new!(Fq, "0"),
25 ),
26 // Fp2::NONRESIDUE^(((q^1) - 1) / 3)
27 field_new!(Fq2,
28 field_new!(Fq, "0"),
29 field_new!(Fq, "4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436"),
30 ),
31 // Fp2::NONRESIDUE^(((q^2) - 1) / 3)
32 field_new!(Fq2,
33 field_new!(Fq, "793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350"),
34 field_new!(Fq, "0"),
35 ),
36 // Fp2::NONRESIDUE^(((q^3) - 1) / 3)
37 field_new!(Fq2,
38 field_new!(Fq, "0"),
39 field_new!(Fq, "1"),
40 ),
41 // Fp2::NONRESIDUE^(((q^4) - 1) / 3)
42 field_new!(Fq2,
43 field_new!(Fq, "4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436"),
44 field_new!(Fq, "0"),
45 ),
46 // Fp2::NONRESIDUE^(((q^5) - 1) / 3)
47 field_new!(Fq2,
48 field_new!(Fq, "0"),
49 field_new!(Fq, "793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350"),
50 ),
51];
52
53 #[rustfmt::skip]
54 const FROBENIUS_COEFF_FP6_C2: &'static [Fq2] = &[
55 // Fq2(u + 1)**(((2q^0) - 2) / 3)
56 field_new!(Fq2,
57 field_new!(Fq, "1"),
58 field_new!(Fq, "0"),
59 ),
60 // Fq2(u + 1)**(((2q^1) - 2) / 3)
61 field_new!(Fq2,
62 field_new!(Fq, "4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939437"),
63 field_new!(Fq, "0"),
64 ),
65 // Fq2(u + 1)**(((2q^2) - 2) / 3)
66 field_new!(Fq2,
67 field_new!(Fq, "4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436"),
68 field_new!(Fq, "0"),
69 ),
70 // Fq2(u + 1)**(((2q^3) - 2) / 3)
71 field_new!(Fq2,
72 field_new!(Fq, "-1"),
73 field_new!(Fq, "0"),
74 ),
75 // Fq2(u + 1)**(((2q^4) - 2) / 3)
76 field_new!(Fq2,
77 field_new!(Fq, "793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350"),
78 field_new!(Fq, "0"),
79 ),
80 // Fq2(u + 1)**(((2q^5) - 2) / 3)
81 field_new!(Fq2,
82 field_new!(Fq, "793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620351"),
83 field_new!(Fq, "0"),
84 ),
85 ];
86
87 /// Multiply this element by the quadratic nonresidue 1 + u.
88 /// Make this generic.
89 fn mul_fp2_by_nonresidue(fe: &Fq2) -> Fq2 {
90 let mut copy = *fe;
91 let t0 = copy.c0;
92 copy.c0 -= &fe.c1;
93 copy.c1 += &t0;
94 copy
95 }
96}