Skip to main content

airbender_crypto/bn254/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(Fq::ONE, Fq::ZERO),
29        // Fp2::NONRESIDUE^(((q^1) - 1) / 6)
30        Fq2::new(
31            MontFp!("8376118865763821496583973867626364092589906065868298776909617916018768340080"),
32            MontFp!(
33                "16469823323077808223889137241176536799009286646108169935659301613961712198316"
34            ),
35        ),
36        // Fp2::NONRESIDUE^(((q^2) - 1) / 6)
37        Fq2::new(
38            MontFp!(
39                "21888242871839275220042445260109153167277707414472061641714758635765020556617"
40            ),
41            Fq::ZERO,
42        ),
43        // Fp2::NONRESIDUE^(((q^3) - 1) / 6)
44        Fq2::new(
45            MontFp!(
46                "11697423496358154304825782922584725312912383441159505038794027105778954184319"
47            ),
48            MontFp!("303847389135065887422783454877609941456349188919719272345083954437860409601"),
49        ),
50        // Fp2::NONRESIDUE^(((q^4) - 1) / 6)
51        Fq2::new(
52            MontFp!(
53                "21888242871839275220042445260109153167277707414472061641714758635765020556616"
54            ),
55            Fq::ZERO,
56        ),
57        // Fp2::NONRESIDUE^(((q^5) - 1) / 6)
58        Fq2::new(
59            MontFp!("3321304630594332808241809054958361220322477375291206261884409189760185844239"),
60            MontFp!("5722266937896532885780051958958348231143373700109372999374820235121374419868"),
61        ),
62        // Fp2::NONRESIDUE^(((q^6) - 1) / 6)
63        Fq2::new(MontFp!("-1"), Fq::ZERO),
64        // Fp2::NONRESIDUE^(((q^7) - 1) / 6)
65        Fq2::new(
66            MontFp!(
67                "13512124006075453725662431877630910996106405091429524885779419978626457868503"
68            ),
69            MontFp!("5418419548761466998357268504080738289687024511189653727029736280683514010267"),
70        ),
71        // Fp2::NONRESIDUE^(((q^8) - 1) / 6)
72        Fq2::new(
73            MontFp!("2203960485148121921418603742825762020974279258880205651966"),
74            Fq::ZERO,
75        ),
76        // Fp2::NONRESIDUE^(((q^9) - 1) / 6)
77        Fq2::new(
78            MontFp!(
79                "10190819375481120917420622822672549775783927716138318623895010788866272024264"
80            ),
81            MontFp!(
82                "21584395482704209334823622290379665147239961968378104390343953940207365798982"
83            ),
84        ),
85        // Fp2::NONRESIDUE^(((q^10) - 1) / 6)
86        Fq2::new(
87            MontFp!("2203960485148121921418603742825762020974279258880205651967"),
88            Fq::ZERO,
89        ),
90        // Fp2::NONRESIDUE^(((q^11) - 1) / 6)
91        Fq2::new(
92            MontFp!(
93                "18566938241244942414004596690298913868373833782006617400804628704885040364344"
94            ),
95            MontFp!(
96                "16165975933942742336466353786298926857552937457188450663314217659523851788715"
97            ),
98        ),
99    ];
100}