Skip to main content

airbender_crypto/bls12_381/fields/
fq12.rs

1use super::{Fq, Fq2, Fq6, Fq6Config};
2#[cfg(any(
3    all(target_arch = "riscv32", feature = "bigint_ops"),
4    test,
5    feature = "proving"
6))]
7use crate::ark_ff_delegation::MontFp;
8#[cfg(not(any(
9    all(target_arch = "riscv32", feature = "bigint_ops"),
10    test,
11    feature = "proving"
12)))]
13use ark_ff::MontFp;
14use ark_ff::{AdditiveGroup, Field, Fp12, Fp12Config};
15
16pub type Fq12 = Fp12<Fq12Config>;
17
18#[derive(Clone, Copy)]
19pub struct Fq12Config;
20
21impl Fp12Config for Fq12Config {
22    type Fp6Config = Fq6Config;
23
24    const NONRESIDUE: Fq6 = Fq6::new(Fq2::ZERO, Fq2::ONE, Fq2::ZERO);
25
26    const FROBENIUS_COEFF_FP12_C1: &'static [Fq2] = &[
27        // Fp2::NONRESIDUE^(((q^0) - 1) / 6)
28        Fq2::new(
29            Fq::ONE,
30            Fq::ZERO,
31        ),
32        // Fp2::NONRESIDUE^(((q^1) - 1) / 6)
33        Fq2::new(
34            MontFp!("3850754370037169011952147076051364057158807420970682438676050522613628423219637725072182697113062777891589506424760"),
35            MontFp!("151655185184498381465642749684540099398075398968325446656007613510403227271200139370504932015952886146304766135027"),
36        ),
37        // Fp2::NONRESIDUE^(((q^2) - 1) / 6)
38        Fq2::new(
39            MontFp!("793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620351"),
40            Fq::ZERO,
41        ),
42        // Fp2::NONRESIDUE^(((q^3) - 1) / 6)
43        Fq2::new(
44            MontFp!("2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530"),
45            MontFp!("1028732146235106349975324479215795277384839936929757896155643118032610843298655225875571310552543014690878354869257"),
46        ),
47        // Fp2::NONRESIDUE^(((q^4) - 1) / 6)
48        Fq2::new(
49            MontFp!("793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350"),
50            Fq::ZERO,
51        ),
52        // Fp2::NONRESIDUE^(((q^5) - 1) / 6)
53        Fq2::new(
54            MontFp!("3125332594171059424908108096204648978570118281977575435832422631601824034463382777937621250592425535493320683825557"),
55            MontFp!("877076961050607968509681729531255177986764537961432449499635504522207616027455086505066378536590128544573588734230"),
56        ),
57        // Fp2::NONRESIDUE^(((q^6) - 1) / 6)
58        Fq2::new(
59            MontFp!("-1"),
60            Fq::ZERO,
61        ),
62        // Fp2::NONRESIDUE^(((q^7) - 1) / 6)
63        Fq2::new(
64            MontFp!("151655185184498381465642749684540099398075398968325446656007613510403227271200139370504932015952886146304766135027"),
65            MontFp!("3850754370037169011952147076051364057158807420970682438676050522613628423219637725072182697113062777891589506424760"),
66        ),
67        // Fp2::NONRESIDUE^(((q^8) - 1) / 6)
68        Fq2::new(
69            MontFp!("4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436"),
70            Fq::ZERO,
71        ),
72        // Fp2::NONRESIDUE^(((q^9) - 1) / 6)
73        Fq2::new(
74            MontFp!("1028732146235106349975324479215795277384839936929757896155643118032610843298655225875571310552543014690878354869257"),
75            MontFp!("2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530"),
76        ),
77        // Fp2::NONRESIDUE^(((q^10) - 1) / 6)
78        Fq2::new(
79            MontFp!("4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939437"),
80            Fq::ZERO,
81        ),
82        // Fp2::NONRESIDUE^(((q^11) - 1) / 6)
83        Fq2::new(
84            MontFp!("877076961050607968509681729531255177986764537961432449499635504522207616027455086505066378536590128544573588734230"),
85            MontFp!("3125332594171059424908108096204648978570118281977575435832422631601824034463382777937621250592425535493320683825557"),
86        ),
87    ];
88}