1use core::ops::Neg;
2
3use openvm_algebra_guest::{Field, IntMod};
4use openvm_algebra_moduli_macros::moduli_declare;
5use openvm_ecc_guest::{weierstrass::IntrinsicCurve, CyclicGroup, Group};
6
7mod fp12;
8mod fp2;
9mod pairing;
10#[cfg(all(feature = "halo2curves", not(target_os = "zkvm")))]
11pub(crate) mod utils;
12
13pub use fp12::*;
14pub use fp2::*;
15use hex_literal::hex;
16#[cfg(not(target_os = "zkvm"))]
17use lazy_static::lazy_static;
18#[cfg(not(target_os = "zkvm"))]
19use num_bigint::BigUint;
20use openvm_ecc_sw_macros::sw_declare;
21
22use crate::pairing::PairingIntrinsics;
23
24#[cfg(all(test, feature = "halo2curves", not(target_os = "zkvm")))]
25mod tests;
26
27#[cfg(not(target_os = "zkvm"))]
28lazy_static! {
29 pub static ref BLS12_381_MODULUS: BigUint = BigUint::from_bytes_be(&hex!(
30 "1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"
31 ));
32 pub static ref BLS12_381_ORDER: BigUint = BigUint::from_bytes_be(&hex!(
33 "73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001"
34 ));
35}
36
37pub const BLS12_381_XI_ISIZE: [isize; 2] = [1, 1];
38pub const BLS12_381_NUM_LIMBS: usize = 48;
39pub const BLS12_381_LIMB_BITS: usize = 8;
40pub const BLS12_381_BLOCK_SIZE: usize = 16;
41
42pub const BLS12_381_SEED_ABS: u64 = 0xd201000000010000;
43pub const BLS12_381_PSEUDO_BINARY_ENCODING: [i8; 64] = [
48 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
49 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1,
50];
51
52moduli_declare! {
53 Bls12_381Fp { modulus = "0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab" },
54 Bls12_381Scalar { modulus = "0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001" },
55}
56
57const CURVE_B: Bls12_381Fp = Bls12_381Fp::from_const_u8(4);
58
59sw_declare! {
60 Bls12_381G1Affine { mod_type = Bls12_381Fp, b = CURVE_B },
61}
62
63pub type Fp = Bls12_381Fp;
64pub type Scalar = Bls12_381Scalar;
65pub type G1Affine = Bls12_381G1Affine;
70pub use g2::G2Affine;
71
72impl Field for Fp {
73 type SelfRef<'a> = &'a Self;
74 const ZERO: Self = <Self as IntMod>::ZERO;
75 const ONE: Self = <Self as IntMod>::ONE;
76
77 fn double_assign(&mut self) {
78 IntMod::double_assign(self);
79 }
80
81 fn square_assign(&mut self) {
82 IntMod::square_assign(self);
83 }
84}
85
86impl Field for Scalar {
87 type SelfRef<'a> = &'a Self;
88 const ZERO: Self = <Self as IntMod>::ZERO;
89 const ONE: Self = <Self as IntMod>::ONE;
90
91 fn double_assign(&mut self) {
92 IntMod::double_assign(self);
93 }
94
95 fn square_assign(&mut self) {
96 IntMod::square_assign(self);
97 }
98}
99
100impl CyclicGroup for G1Affine {
104 const GENERATOR: Self = G1Affine {
106 x: Bls12_381Fp::from_const_bytes(hex!(
107 "BBC622DB0AF03AFBEF1A7AF93FE8556C58AC1B173F3A4EA105B974974F8C68C30FACA94F8C63952694D79731A7D3F117"
108 )),
109 y: Bls12_381Fp::from_const_bytes(hex!(
110 "E1E7C5462923AA0CE48A88A244C73CD0EDB3042CCB18DB00F60AD0D595E0F5FCE48A1D74ED309EA0F1A0AAE381F4B308"
111 )),
112 };
113 const NEG_GENERATOR: Self = G1Affine {
114 x: Bls12_381Fp::from_const_bytes(hex!(
115 "BBC622DB0AF03AFBEF1A7AF93FE8556C58AC1B173F3A4EA105B974974F8C68C30FACA94F8C63952694D79731A7D3F117"
116 )),
117 y: Bls12_381Fp::from_const_bytes(hex!(
118 "CAC239B9D6DC54AD1B75CB0EBA386F4E3642ACCAD5B95566C907B51DEF6A8167F2212ECFC8767DAAA845D555681D4D11"
119 )),
120 };
121}
122
123pub struct Bls12_381;
124
125impl IntrinsicCurve for Bls12_381 {
126 type Scalar = Scalar;
127 type Point = G1Affine;
128
129 fn msm(coeffs: &[Self::Scalar], bases: &[Self::Point]) -> Self::Point {
130 openvm_ecc_guest::msm(coeffs, bases)
131 }
132}
133
134mod g2 {
137 use openvm_algebra_guest::Field;
138 use openvm_ecc_guest::{
139 impl_sw_affine, impl_sw_group_ops, weierstrass::WeierstrassPoint, AffinePoint, Group,
140 };
141
142 use super::{Fp, Fp2};
143
144 const THREE: Fp2 = Fp2::new(Fp::from_const_u8(3), Fp::ZERO);
145 const B: Fp2 = Fp2::new(Fp::from_const_u8(4), Fp::from_const_u8(4));
146 impl_sw_affine!(G2Affine, Fp2, THREE, B);
147 impl_sw_group_ops!(G2Affine, Fp2);
148}
149
150impl PairingIntrinsics for Bls12_381 {
151 type Fp = Fp;
152 type Fp2 = Fp2;
153 type Fp12 = Fp12;
154
155 const PAIRING_IDX: usize = 1;
156 const XI: Fp2 = Fp2::new(Fp::from_const_u8(1), Fp::from_const_u8(1));
158 const FP2_TWO: Fp2 = Fp2::new(Fp::from_const_u8(2), Fp::from_const_u8(0));
159 const FP2_THREE: Fp2 = Fp2::new(Fp::from_const_u8(3), Fp::from_const_u8(0));
160
161 const FROBENIUS_COEFFS: [[Self::Fp2; 5]; 12] = [
165 [
166 Fp2 {
167 c0: Bls12_381Fp(hex!(
168 "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
169 )),
170 c1: Bls12_381Fp(hex!(
171 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
172 ")),
173 },
174 Fp2 {
175 c0: Bls12_381Fp(hex!(
176 "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
177 )),
178 c1: Bls12_381Fp(hex!(
179 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
180 ")),
181 },
182 Fp2 {
183 c0: Bls12_381Fp(hex!(
184 "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
185 )),
186 c1: Bls12_381Fp(hex!(
187 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
188 ")),
189 },
190 Fp2 {
191 c0: Bls12_381Fp(hex!(
192 "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
193 )),
194 c1: Bls12_381Fp(hex!(
195 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
196 ")),
197 },
198 Fp2 {
199 c0: Bls12_381Fp(hex!(
200 "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
201 )),
202 c1: Bls12_381Fp(hex!(
203 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
204 ")),
205 },
206 ],
207 [
208 Fp2 {
209 c0: Bls12_381Fp(hex!(
210 "b85f2392ed75078d3d81e7633da57ef6c4b9ba84d743247b4f5fbd3cfd03d60f1f0d2c20b4be31c26706bb02bfd30419"
211 )),
212 c1: Bls12_381Fp(hex!(
213 "f34adc6d128af72cc27e6c4dc15a2d285f3cf671c98e0cec6fb3c7b68747a154b89f1f2302e9e98832e0c4362b3efc00"
214 ))
215 },
216 Fp2 {
217 c0: Bls12_381Fp(hex!(
218 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
219 )),
220 c1: Bls12_381Fp(hex!(
221 "acaa00000000fd8bfdff494feb2794409b5fb80f65297d89d49a75897d850daa85ded463864002ec99e67f39ea11011a"
222 ))
223 },
224 Fp2 {
225 c0: Bls12_381Fp(hex!(
226 "09cce3edfb8410c8f405ec722f9967eec5419200176ef7775e43d3c2ab5d3948fe7fd16b6de331680b40ff37040eaf06"
227 )),
228 c1: Bls12_381Fp(hex!(
229 "09cce3edfb8410c8f405ec722f9967eec5419200176ef7775e43d3c2ab5d3948fe7fd16b6de331680b40ff37040eaf06"
230 ))
231 },
232 Fp2 {
233 c0: Bls12_381Fp(hex!(
234 "adaa00000000fd8bfdff494feb2794409b5fb80f65297d89d49a75897d850daa85ded463864002ec99e67f39ea11011a"
235 )),
236 c1: Bls12_381Fp(hex!(
237 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
238 ))
239 },
240 Fp2 {
241 c0: Bls12_381Fp(hex!(
242 "16810780e9fa189b32877f256e3e3ac666059c8e4ddfea8bee8f0b0c241698f345e0b1486bfa47dfd85f3a01d9cfb205"
243 )),
244 c1: Bls12_381Fp(hex!(
245 "9529f87f1605e61ecd78d48b90c17158bdf0146853f345dbd08279e76035df7091cc99fa4aadd36bc186453811424e14"
246 ))
247 },
248 ],
249 [
250 Fp2 {
251 c0: Bls12_381Fp(hex!(
252 "fffffeffffff012e02000a6213d817de8896f8e63ba9b3ddea770f6a07c669ba51ce76df2f67195f0000000000000000"
253 )),
254 c1: Bls12_381Fp(hex!(
255 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
256 ))
257 },
258 Fp2 {
259 c0: Bls12_381Fp(hex!(
260 "fefffeffffff012e02000a6213d817de8896f8e63ba9b3ddea770f6a07c669ba51ce76df2f67195f0000000000000000"
261 )),
262 c1: Bls12_381Fp(hex!(
263 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
264 ))
265 },
266 Fp2 {
267 c0: Bls12_381Fp(hex!(
268 "aaaafffffffffeb9ffff53b1feffab1e24f6b0f6a0d23067bf1285f3844b7764d7ac4b43b6a71b4b9ae67f39ea11011a"
269 )),
270 c1: Bls12_381Fp(hex!(
271 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
272 ))
273 },
274 Fp2 {
275 c0: Bls12_381Fp(hex!(
276 "acaa00000000fd8bfdff494feb2794409b5fb80f65297d89d49a75897d850daa85ded463864002ec99e67f39ea11011a"
277 )),
278 c1: Bls12_381Fp(hex!(
279 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
280 ))
281 },
282 Fp2 {
283 c0: Bls12_381Fp(hex!(
284 "adaa00000000fd8bfdff494feb2794409b5fb80f65297d89d49a75897d850daa85ded463864002ec99e67f39ea11011a"
285 )),
286 c1: Bls12_381Fp(hex!(
287 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
288 ))
289 },
290 ],
291 [
292 Fp2 {
293 c0: Bls12_381Fp(hex!(
294 "a2de1b12047beef10afa673ecf6644305eb41ef6896439ef60cfb130d9ed3d1cd92c7ad748c4e9e28ea68001e6035213"
295 )),
296 c1: Bls12_381Fp(hex!(
297 "09cce3edfb8410c8f405ec722f9967eec5419200176ef7775e43d3c2ab5d3948fe7fd16b6de331680b40ff37040eaf06"
298 ))
299 },
300 Fp2 {
301 c0: Bls12_381Fp(hex!(
302 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
303 )),
304 c1: Bls12_381Fp(hex!(
305 "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
306 ))
307 },
308 Fp2 {
309 c0: Bls12_381Fp(hex!(
310 "a2de1b12047beef10afa673ecf6644305eb41ef6896439ef60cfb130d9ed3d1cd92c7ad748c4e9e28ea68001e6035213"
311 )),
312 c1: Bls12_381Fp(hex!(
313 "a2de1b12047beef10afa673ecf6644305eb41ef6896439ef60cfb130d9ed3d1cd92c7ad748c4e9e28ea68001e6035213"
314 ))
315 },
316 Fp2 {
317 c0: Bls12_381Fp(hex!(
318 "aaaafffffffffeb9ffff53b1feffab1e24f6b0f6a0d23067bf1285f3844b7764d7ac4b43b6a71b4b9ae67f39ea11011a"
319 )),
320 c1: Bls12_381Fp(hex!(
321 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
322 ))
323 },
324 Fp2 {
325 c0: Bls12_381Fp(hex!(
326 "09cce3edfb8410c8f405ec722f9967eec5419200176ef7775e43d3c2ab5d3948fe7fd16b6de331680b40ff37040eaf06"
327 )),
328 c1: Bls12_381Fp(hex!(
329 "a2de1b12047beef10afa673ecf6644305eb41ef6896439ef60cfb130d9ed3d1cd92c7ad748c4e9e28ea68001e6035213"
330 ))
331 },
332 ],
333 [
334 Fp2 {
335 c0: Bls12_381Fp(hex!(
336 "fefffeffffff012e02000a6213d817de8896f8e63ba9b3ddea770f6a07c669ba51ce76df2f67195f0000000000000000"
337 )),
338 c1: Bls12_381Fp(hex!(
339 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
340 ))
341 },
342 Fp2 {
343 c0: Bls12_381Fp(hex!(
344 "acaa00000000fd8bfdff494feb2794409b5fb80f65297d89d49a75897d850daa85ded463864002ec99e67f39ea11011a"
345 )),
346 c1: Bls12_381Fp(hex!(
347 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
348 ))
349 },
350 Fp2 {
351 c0: Bls12_381Fp(hex!(
352 "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
353 )),
354 c1: Bls12_381Fp(hex!(
355 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
356 ))
357 },
358 Fp2 {
359 c0: Bls12_381Fp(hex!(
360 "fefffeffffff012e02000a6213d817de8896f8e63ba9b3ddea770f6a07c669ba51ce76df2f67195f0000000000000000"
361 )),
362 c1: Bls12_381Fp(hex!(
363 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
364 ))
365 },
366 Fp2 {
367 c0: Bls12_381Fp(hex!(
368 "acaa00000000fd8bfdff494feb2794409b5fb80f65297d89d49a75897d850daa85ded463864002ec99e67f39ea11011a"
369 )),
370 c1: Bls12_381Fp(hex!(
371 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
372 ))
373 },
374 ],
375 [
376 Fp2 {
377 c0: Bls12_381Fp(hex!(
378 "9529f87f1605e61ecd78d48b90c17158bdf0146853f345dbd08279e76035df7091cc99fa4aadd36bc186453811424e14"
379 )),
380 c1: Bls12_381Fp(hex!(
381 "16810780e9fa189b32877f256e3e3ac666059c8e4ddfea8bee8f0b0c241698f345e0b1486bfa47dfd85f3a01d9cfb205"
382 ))
383 },
384 Fp2 {
385 c0: Bls12_381Fp(hex!(
386 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
387 )),
388 c1: Bls12_381Fp(hex!(
389 "fefffeffffff012e02000a6213d817de8896f8e63ba9b3ddea770f6a07c669ba51ce76df2f67195f0000000000000000"
390 ))
391 },
392 Fp2 {
393 c0: Bls12_381Fp(hex!(
394 "09cce3edfb8410c8f405ec722f9967eec5419200176ef7775e43d3c2ab5d3948fe7fd16b6de331680b40ff37040eaf06"
395 )),
396 c1: Bls12_381Fp(hex!(
397 "09cce3edfb8410c8f405ec722f9967eec5419200176ef7775e43d3c2ab5d3948fe7fd16b6de331680b40ff37040eaf06"
398 ))
399 },
400 Fp2 {
401 c0: Bls12_381Fp(hex!(
402 "fffffeffffff012e02000a6213d817de8896f8e63ba9b3ddea770f6a07c669ba51ce76df2f67195f0000000000000000"
403 )),
404 c1: Bls12_381Fp(hex!(
405 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
406 ))
407 },
408 Fp2 {
409 c0: Bls12_381Fp(hex!(
410 "f34adc6d128af72cc27e6c4dc15a2d285f3cf671c98e0cec6fb3c7b68747a154b89f1f2302e9e98832e0c4362b3efc00"
411 )),
412 c1: Bls12_381Fp(hex!(
413 "b85f2392ed75078d3d81e7633da57ef6c4b9ba84d743247b4f5fbd3cfd03d60f1f0d2c20b4be31c26706bb02bfd30419"
414 ))
415 },
416 ],
417 [
418 Fp2 {
419 c0: Bls12_381Fp(hex!(
420 "aaaafffffffffeb9ffff53b1feffab1e24f6b0f6a0d23067bf1285f3844b7764d7ac4b43b6a71b4b9ae67f39ea11011a"
421 )),
422 c1: Bls12_381Fp(hex!(
423 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
424 ))
425 },
426 Fp2 {
427 c0: Bls12_381Fp(hex!(
428 "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
429 )),
430 c1: Bls12_381Fp(hex!(
431 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
432 ))
433 },
434 Fp2 {
435 c0: Bls12_381Fp(hex!(
436 "aaaafffffffffeb9ffff53b1feffab1e24f6b0f6a0d23067bf1285f3844b7764d7ac4b43b6a71b4b9ae67f39ea11011a"
437 )),
438 c1: Bls12_381Fp(hex!(
439 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
440 ))
441 },
442 Fp2 {
443 c0: Bls12_381Fp(hex!(
444 "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
445 )),
446 c1: Bls12_381Fp(hex!(
447 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
448 ))
449 },
450 Fp2 {
451 c0: Bls12_381Fp(hex!(
452 "aaaafffffffffeb9ffff53b1feffab1e24f6b0f6a0d23067bf1285f3844b7764d7ac4b43b6a71b4b9ae67f39ea11011a"
453 )),
454 c1: Bls12_381Fp(hex!(
455 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
456 ))
457 },
458 ],
459 [
460 Fp2 {
461 c0: Bls12_381Fp(hex!(
462 "f34adc6d128af72cc27e6c4dc15a2d285f3cf671c98e0cec6fb3c7b68747a154b89f1f2302e9e98832e0c4362b3efc00"
463 )),
464 c1: Bls12_381Fp(hex!(
465 "b85f2392ed75078d3d81e7633da57ef6c4b9ba84d743247b4f5fbd3cfd03d60f1f0d2c20b4be31c26706bb02bfd30419"
466 ))
467 },
468 Fp2 {
469 c0: Bls12_381Fp(hex!(
470 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
471 )),
472 c1: Bls12_381Fp(hex!(
473 "acaa00000000fd8bfdff494feb2794409b5fb80f65297d89d49a75897d850daa85ded463864002ec99e67f39ea11011a"
474 ))
475 },
476 Fp2 {
477 c0: Bls12_381Fp(hex!(
478 "a2de1b12047beef10afa673ecf6644305eb41ef6896439ef60cfb130d9ed3d1cd92c7ad748c4e9e28ea68001e6035213"
479 )),
480 c1: Bls12_381Fp(hex!(
481 "a2de1b12047beef10afa673ecf6644305eb41ef6896439ef60cfb130d9ed3d1cd92c7ad748c4e9e28ea68001e6035213"
482 ))
483 },
484 Fp2 {
485 c0: Bls12_381Fp(hex!(
486 "adaa00000000fd8bfdff494feb2794409b5fb80f65297d89d49a75897d850daa85ded463864002ec99e67f39ea11011a"
487 )),
488 c1: Bls12_381Fp(hex!(
489 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
490 ))
491 },
492 Fp2 {
493 c0: Bls12_381Fp(hex!(
494 "9529f87f1605e61ecd78d48b90c17158bdf0146853f345dbd08279e76035df7091cc99fa4aadd36bc186453811424e14"
495 )),
496 c1: Bls12_381Fp(hex!(
497 "16810780e9fa189b32877f256e3e3ac666059c8e4ddfea8bee8f0b0c241698f345e0b1486bfa47dfd85f3a01d9cfb205"
498 ))
499 },
500 ],
501 [
502 Fp2 {
503 c0: Bls12_381Fp(hex!(
504 "acaa00000000fd8bfdff494feb2794409b5fb80f65297d89d49a75897d850daa85ded463864002ec99e67f39ea11011a"
505 )),
506 c1: Bls12_381Fp(hex!(
507 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
508 ))
509 },
510 Fp2 {
511 c0: Bls12_381Fp(hex!(
512 "fefffeffffff012e02000a6213d817de8896f8e63ba9b3ddea770f6a07c669ba51ce76df2f67195f0000000000000000"
513 )),
514 c1: Bls12_381Fp(hex!(
515 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
516 ))
517 },
518 Fp2 {
519 c0: Bls12_381Fp(hex!(
520 "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
521 )),
522 c1: Bls12_381Fp(hex!(
523 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
524 ))
525 },
526 Fp2 {
527 c0: Bls12_381Fp(hex!(
528 "acaa00000000fd8bfdff494feb2794409b5fb80f65297d89d49a75897d850daa85ded463864002ec99e67f39ea11011a"
529 )),
530 c1: Bls12_381Fp(hex!(
531 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
532 ))
533 },
534 Fp2 {
535 c0: Bls12_381Fp(hex!(
536 "fefffeffffff012e02000a6213d817de8896f8e63ba9b3ddea770f6a07c669ba51ce76df2f67195f0000000000000000"
537 )),
538 c1: Bls12_381Fp(hex!(
539 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
540 ))
541 },
542 ],
543 [
544 Fp2 {
545 c0: Bls12_381Fp(hex!(
546 "09cce3edfb8410c8f405ec722f9967eec5419200176ef7775e43d3c2ab5d3948fe7fd16b6de331680b40ff37040eaf06"
547 )),
548 c1: Bls12_381Fp(hex!(
549 "a2de1b12047beef10afa673ecf6644305eb41ef6896439ef60cfb130d9ed3d1cd92c7ad748c4e9e28ea68001e6035213"
550 ))
551 },
552 Fp2 {
553 c0: Bls12_381Fp(hex!(
554 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
555 )),
556 c1: Bls12_381Fp(hex!(
557 "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
558 ))
559 },
560 Fp2 {
561 c0: Bls12_381Fp(hex!(
562 "09cce3edfb8410c8f405ec722f9967eec5419200176ef7775e43d3c2ab5d3948fe7fd16b6de331680b40ff37040eaf06"
563 )),
564 c1: Bls12_381Fp(hex!(
565 "09cce3edfb8410c8f405ec722f9967eec5419200176ef7775e43d3c2ab5d3948fe7fd16b6de331680b40ff37040eaf06"
566 ))
567 },
568 Fp2 {
569 c0: Bls12_381Fp(hex!(
570 "aaaafffffffffeb9ffff53b1feffab1e24f6b0f6a0d23067bf1285f3844b7764d7ac4b43b6a71b4b9ae67f39ea11011a"
571 )),
572 c1: Bls12_381Fp(hex!(
573 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
574 ))
575 },
576 Fp2 {
577 c0: Bls12_381Fp(hex!(
578 "a2de1b12047beef10afa673ecf6644305eb41ef6896439ef60cfb130d9ed3d1cd92c7ad748c4e9e28ea68001e6035213"
579 )),
580 c1: Bls12_381Fp(hex!(
581 "09cce3edfb8410c8f405ec722f9967eec5419200176ef7775e43d3c2ab5d3948fe7fd16b6de331680b40ff37040eaf06"
582 ))
583 },
584 ],
585 [
586 Fp2 {
587 c0: Bls12_381Fp(hex!(
588 "adaa00000000fd8bfdff494feb2794409b5fb80f65297d89d49a75897d850daa85ded463864002ec99e67f39ea11011a"
589 )),
590 c1: Bls12_381Fp(hex!(
591 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
592 ))
593 },
594 Fp2 {
595 c0: Bls12_381Fp(hex!(
596 "acaa00000000fd8bfdff494feb2794409b5fb80f65297d89d49a75897d850daa85ded463864002ec99e67f39ea11011a"
597 )),
598 c1: Bls12_381Fp(hex!(
599 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
600 ))
601 },
602 Fp2 {
603 c0: Bls12_381Fp(hex!(
604 "aaaafffffffffeb9ffff53b1feffab1e24f6b0f6a0d23067bf1285f3844b7764d7ac4b43b6a71b4b9ae67f39ea11011a"
605 )),
606 c1: Bls12_381Fp(hex!(
607 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
608 ))
609 },
610 Fp2 {
611 c0: Bls12_381Fp(hex!(
612 "fefffeffffff012e02000a6213d817de8896f8e63ba9b3ddea770f6a07c669ba51ce76df2f67195f0000000000000000"
613 )),
614 c1: Bls12_381Fp(hex!(
615 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
616 ))
617 },
618 Fp2 {
619 c0: Bls12_381Fp(hex!(
620 "fffffeffffff012e02000a6213d817de8896f8e63ba9b3ddea770f6a07c669ba51ce76df2f67195f0000000000000000"
621 )),
622 c1: Bls12_381Fp(hex!(
623 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
624 ))
625 },
626 ],
627 [
628 Fp2 {
629 c0: Bls12_381Fp(hex!(
630 "16810780e9fa189b32877f256e3e3ac666059c8e4ddfea8bee8f0b0c241698f345e0b1486bfa47dfd85f3a01d9cfb205"
631 )),
632 c1: Bls12_381Fp(hex!(
633 "9529f87f1605e61ecd78d48b90c17158bdf0146853f345dbd08279e76035df7091cc99fa4aadd36bc186453811424e14"
634 ))
635 },
636 Fp2 {
637 c0: Bls12_381Fp(hex!(
638 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
639 )),
640 c1: Bls12_381Fp(hex!(
641 "fefffeffffff012e02000a6213d817de8896f8e63ba9b3ddea770f6a07c669ba51ce76df2f67195f0000000000000000"
642 ))
643 },
644 Fp2 {
645 c0: Bls12_381Fp(hex!(
646 "a2de1b12047beef10afa673ecf6644305eb41ef6896439ef60cfb130d9ed3d1cd92c7ad748c4e9e28ea68001e6035213"
647 )),
648 c1: Bls12_381Fp(hex!(
649 "a2de1b12047beef10afa673ecf6644305eb41ef6896439ef60cfb130d9ed3d1cd92c7ad748c4e9e28ea68001e6035213"
650 ))
651 },
652 Fp2 {
653 c0: Bls12_381Fp(hex!(
654 "fffffeffffff012e02000a6213d817de8896f8e63ba9b3ddea770f6a07c669ba51ce76df2f67195f0000000000000000"
655 )),
656 c1: Bls12_381Fp(hex!(
657 "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
658 ))
659 },
660 Fp2 {
661 c0: Bls12_381Fp(hex!(
662 "b85f2392ed75078d3d81e7633da57ef6c4b9ba84d743247b4f5fbd3cfd03d60f1f0d2c20b4be31c26706bb02bfd30419"
663 )),
664 c1: Bls12_381Fp(hex!(
665 "f34adc6d128af72cc27e6c4dc15a2d285f3cf671c98e0cec6fb3c7b68747a154b89f1f2302e9e98832e0c4362b3efc00"
666 ))
667 },
668 ],
669 ];
670}
671
672impl Bls12_381 {
673 pub const FINAL_EXPONENT: [u8; 540] = hex!(
676 "02ee1db5dcc825b7e1bda9c0496a1c0a89ee0193d4977b3f7d4507d07363baa13f8d14a917848517badc3a43d1073776ab353f2c30698e8cc7deada9c0aadff5e9cfee9a074e43b9a660835cc872ee83ff3a0f0f1c0ad0d6106feaf4e347aa68ad49466fa927e7bb9375331807a0dce2630d9aa4b113f414386b0e8819328148978e2b0dd39099b86e1ab656d2670d93e4d7acdd350da5359bc73ab61a0c5bf24c374693c49f570bcd2b01f3077ffb10bf24dde41064837f27611212596bc293c8d4c01f25118790f4684d0b9c40a68eb74bb22a40ee7169cdc1041296532fef459f12438dfc8e2886ef965e61a474c5c85b0129127a1b5ad0463434724538411d1676a53b5a62eb34c05739334f46c02c3f0bd0c55d3109cd15948d0a1fad20044ce6ad4c6bec3ec03ef19592004cedd556952c6d8823b19dadd7c2498345c6e5308f1c511291097db60b1749bf9b71a9f9e0100418a3ef0bc627751bbd81367066bca6a4c1b6dcfc5cceb73fc56947a403577dfa9e13c24ea820b09c1d9f7c31759c3635de3f7a3639991708e88adce88177456c49637fd7961be1a4c7e79fb02faa732e2f3ec2bea83d196283313492caa9d4aff1c910e9622d2a73f62537f2701aaef6539314043f7bbce5b78c7869aeb2181a67e49eeed2161daf3f881bd88592d767f67c4717489119226c2f011d4cab803e9d71650a6f80698e2f8491d12191a04406fbc8fbd5f48925f98630e68bfb24c0bcb9b55df57510"
677 );
678}