ark-curves-cherry-picked/bls12_377/src/fields/fq6.rs
bls12_377/src/fields/fq6.rsRaw
1use super::*;
2use ark_ff::{biginteger::BigInteger384, 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
13 #[rustfmt::skip]
14 const NONRESIDUE: Fq2 = field_new!(Fq2,
15 field_new!(Fq, BigInteger384([0, 0, 0, 0, 0, 0])),
16 field_new!(Fq, BigInteger384([
17 202099033278250856u64,
18 5854854902718660529u64,
19 11492539364873682930u64,
20 8885205928937022213u64,
21 5545221690922665192u64,
22 39800542322357402u64,
23 ])),
24 );
25
26 #[rustfmt::skip]
27 const FROBENIUS_COEFF_FP6_C1: &'static [Fq2] = &[
28 // Fp2::NONRESIDUE^(((q^0) - 1) / 3)
29 field_new!(Fq2,
30 field_new!(Fq, BigInteger384([
31 0x2cdffffffffff68,
32 0x51409f837fffffb1,
33 0x9f7db3a98a7d3ff2,
34 0x7b4e97b76e7c6305,
35 0x4cf495bf803c84e8,
36 0x8d6661e2fdf49a,
37 ])),
38 field_new!(Fq, BigInteger384([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
39 ),
40 // Fp2::NONRESIDUE^(((q^1) - 1) / 3)
41 field_new!(Fq2,
42 field_new!(Fq, BigInteger384([
43 0x5892506da58478da,
44 0x133366940ac2a74b,
45 0x9b64a150cdf726cf,
46 0x5cc426090a9c587e,
47 0x5cf848adfdcd640c,
48 0x4702bf3ac02380,
49 ])),
50 field_new!(Fq, BigInteger384([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
51 ),
52 // Fp2::NONRESIDUE^(((q^2) - 1) / 3)
53 field_new!(Fq2,
54 field_new!(Fq, BigInteger384([
55 0xdacd106da5847973,
56 0xd8fe2454bac2a79a,
57 0x1ada4fd6fd832edc,
58 0xfb9868449d150908,
59 0xd63eb8aeea32285e,
60 0x167d6a36f873fd0,
61 ])),
62 field_new!(Fq, BigInteger384([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
63 ),
64 // Fp2::NONRESIDUE^(((q^3) - 1) / 3)
65 field_new!(Fq2,
66 field_new!(Fq, BigInteger384([
67 0x823ac00000000099,
68 0xc5cabdc0b000004f,
69 0x7f75ae862f8c080d,
70 0x9ed4423b9278b089,
71 0x79467000ec64c452,
72 0x120d3e434c71c50,
73 ])),
74 field_new!(Fq, BigInteger384([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
75 ),
76 // Fp2::NONRESIDUE^(((q^4) - 1) / 3)
77 field_new!(Fq2,
78 field_new!(Fq, BigInteger384([
79 0x2c766f925a7b8727,
80 0x3d7f6b0253d58b5,
81 0x838ec0deec122131,
82 0xbd5eb3e9f658bb10,
83 0x6942bd126ed3e52e,
84 0x1673786dd04ed6a,
85 ])),
86 field_new!(Fq, BigInteger384([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
87 ),
88 // Fp2::NONRESIDUE^(((q^5) - 1) / 3)
89 field_new!(Fq2,
90 field_new!(Fq, BigInteger384([
91 0xaa3baf925a7b868e,
92 0x3e0d38ef753d5865,
93 0x4191258bc861923,
94 0x1e8a71ae63e00a87,
95 0xeffc4d11826f20dc,
96 0x4663a2a83dd119,
97 ])),
98 field_new!(Fq, BigInteger384([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
99 ),
100 ];
101 #[rustfmt::skip]
102 const FROBENIUS_COEFF_FP6_C2: &'static [Fq2] = &[
103 // Fp2::NONRESIDUE^((2*(q^0) - 2) / 3)
104 field_new!(Fq2,
105 field_new!(Fq, BigInteger384([
106 0x2cdffffffffff68,
107 0x51409f837fffffb1,
108 0x9f7db3a98a7d3ff2,
109 0x7b4e97b76e7c6305,
110 0x4cf495bf803c84e8,
111 0x8d6661e2fdf49a,
112 ])),
113 field_new!(Fq, BigInteger384([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
114 ),
115 // Fp2::NONRESIDUE^((2*(q^1) - 2) / 3)
116 field_new!(Fq2,
117 field_new!(Fq, BigInteger384([
118 0xdacd106da5847973,
119 0xd8fe2454bac2a79a,
120 0x1ada4fd6fd832edc,
121 0xfb9868449d150908,
122 0xd63eb8aeea32285e,
123 0x167d6a36f873fd0,
124 ])),
125 field_new!(Fq, BigInteger384([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
126 ),
127 // Fp2::NONRESIDUE^((2*(q^2) - 2) / 3)
128 field_new!(Fq2,
129 field_new!(Fq, BigInteger384([
130 0x2c766f925a7b8727,
131 0x3d7f6b0253d58b5,
132 0x838ec0deec122131,
133 0xbd5eb3e9f658bb10,
134 0x6942bd126ed3e52e,
135 0x1673786dd04ed6a,
136 ])),
137 field_new!(Fq, BigInteger384([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
138 ),
139 // Fp2::NONRESIDUE^((2*(q^3) - 2) / 3)
140 field_new!(Fq2,
141 field_new!(Fq, BigInteger384([
142 0x2cdffffffffff68,
143 0x51409f837fffffb1,
144 0x9f7db3a98a7d3ff2,
145 0x7b4e97b76e7c6305,
146 0x4cf495bf803c84e8,
147 0x8d6661e2fdf49a,
148 ])),
149 field_new!(Fq, BigInteger384([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
150 ),
151 // Fp2::NONRESIDUE^((2*(q^4) - 2) / 3)
152 field_new!(Fq2,
153 field_new!(Fq, BigInteger384([
154 0xdacd106da5847973,
155 0xd8fe2454bac2a79a,
156 0x1ada4fd6fd832edc,
157 0xfb9868449d150908,
158 0xd63eb8aeea32285e,
159 0x167d6a36f873fd0,
160 ])),
161 field_new!(Fq, BigInteger384([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
162 ),
163 // Fp2::NONRESIDUE^((2*(q^5) - 2) / 3)
164 field_new!(Fq2,
165 field_new!(Fq, BigInteger384([
166 0x2c766f925a7b8727,
167 0x3d7f6b0253d58b5,
168 0x838ec0deec122131,
169 0xbd5eb3e9f658bb10,
170 0x6942bd126ed3e52e,
171 0x1673786dd04ed6a,
172 ])),
173 field_new!(Fq, BigInteger384([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
174 ),
175 ];
176
177 #[inline(always)]
178 fn mul_fp2_by_nonresidue(fe: &Fq2) -> Fq2 {
179 // Karatsuba multiplication with constant other = u.
180 let c0 = Fq2Parameters::mul_fp_by_nonresidue(&fe.c1);
181 let c1 = fe.c0;
182 field_new!(Fq2, c0, c1)
183 }
184}