snarkvm_curves/bls12_377/
fq12.rs

1// Copyright (c) 2019-2025 Provable Inc.
2// This file is part of the snarkVM library.
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at:
7
8// http://www.apache.org/licenses/LICENSE-2.0
9
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16use snarkvm_fields::{Fp12, Fp12Parameters, field};
17use snarkvm_utilities::biginteger::BigInteger384 as BigInteger;
18
19use crate::bls12_377::{Fq, Fq2, Fq6Parameters};
20
21pub type Fq12 = Fp12<Fq12Parameters>;
22
23#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
24pub struct Fq12Parameters;
25
26impl Fp12Parameters for Fq12Parameters {
27    type Fp6Params = Fq6Parameters;
28
29    const FROBENIUS_COEFF_FP12_C1: [Fq2; 12] = [
30        // Fp2::NONRESIDUE^(((q^0) - 1) / 6)
31        field!(
32            Fq2,
33            field!(
34                Fq,
35                BigInteger([
36                    0x2cdffffffffff68,
37                    0x51409f837fffffb1,
38                    0x9f7db3a98a7d3ff2,
39                    0x7b4e97b76e7c6305,
40                    0x4cf495bf803c84e8,
41                    0x8d6661e2fdf49a,
42                ])
43            ),
44            field!(Fq, BigInteger([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
45        ),
46        // Fp2::NONRESIDUE^(((q^1) - 1) / 6)
47        field!(
48            Fq2,
49            field!(
50                Fq,
51                BigInteger([
52                    0x6ec47a04a3f7ca9e,
53                    0xa42e0cb968c1fa44,
54                    0x578d5187fbd2bd23,
55                    0x930eeb0ac79dd4bd,
56                    0xa24883de1e09a9ee,
57                    0xdaa7058067d46f,
58                ])
59            ),
60            field!(Fq, BigInteger([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
61        ),
62        // Fp2::NONRESIDUE^(((q^2) - 1) / 6)
63        field!(
64            Fq2,
65            field!(
66                Fq,
67                BigInteger([
68                    0x5892506da58478da,
69                    0x133366940ac2a74b,
70                    0x9b64a150cdf726cf,
71                    0x5cc426090a9c587e,
72                    0x5cf848adfdcd640c,
73                    0x4702bf3ac02380,
74                ])
75            ),
76            field!(Fq, BigInteger([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
77        ),
78        // Fp2::NONRESIDUE^(((q^3) - 1) / 6)
79        field!(
80            Fq2,
81            field!(
82                Fq,
83                BigInteger([
84                    0x982c13d9d084771f,
85                    0xfd49de0c6da34a32,
86                    0x61a530d183ab0e53,
87                    0xdf8fe44106dd9879,
88                    0x40f29b58d88472bc,
89                    0x158723199046d5d,
90                ])
91            ),
92            field!(Fq, BigInteger([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
93        ),
94        // Fp2::NONRESIDUE^(((q^4) - 1) / 6)
95        field!(
96            Fq2,
97            field!(
98                Fq,
99                BigInteger([
100                    0xdacd106da5847973,
101                    0xd8fe2454bac2a79a,
102                    0x1ada4fd6fd832edc,
103                    0xfb9868449d150908,
104                    0xd63eb8aeea32285e,
105                    0x167d6a36f873fd0,
106                ])
107            ),
108            field!(Fq, BigInteger([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
109        ),
110        // Fp2::NONRESIDUE^(((q^5) - 1) / 6)
111        field!(
112            Fq2,
113            field!(
114                Fq,
115                BigInteger([
116                    0x296799d52c8cac81,
117                    0x591bd15304e14fee,
118                    0xa17df4987d85130,
119                    0x4c80f9363f3fc3bc,
120                    0x9eaa177aba7ac8ce,
121                    0x7dcb2c189c98ed,
122                ])
123            ),
124            field!(Fq, BigInteger([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
125        ),
126        // Fp2::NONRESIDUE^(((q^6) - 1) / 6)
127        field!(
128            Fq2,
129            field!(
130                Fq,
131                BigInteger([
132                    0x823ac00000000099,
133                    0xc5cabdc0b000004f,
134                    0x7f75ae862f8c080d,
135                    0x9ed4423b9278b089,
136                    0x79467000ec64c452,
137                    0x120d3e434c71c50,
138                ])
139            ),
140            field!(Fq, BigInteger([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
141        ),
142        // Fp2::NONRESIDUE^(((q^7) - 1) / 6)
143        field!(
144            Fq2,
145            field!(
146                Fq,
147                BigInteger([
148                    0x164445fb5c083563,
149                    0x72dd508ac73e05bc,
150                    0xc76610a7be368adc,
151                    0x8713eee839573ed1,
152                    0x23f281e24e979f4c,
153                    0xd39340975d3c7b,
154                ])
155            ),
156            field!(Fq, BigInteger([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
157        ),
158        // Fp2::NONRESIDUE^(((q^8) - 1) / 6)
159        field!(
160            Fq2,
161            field!(
162                Fq,
163                BigInteger([
164                    0x2c766f925a7b8727,
165                    0x3d7f6b0253d58b5,
166                    0x838ec0deec122131,
167                    0xbd5eb3e9f658bb10,
168                    0x6942bd126ed3e52e,
169                    0x1673786dd04ed6a,
170                ])
171            ),
172            field!(Fq, BigInteger([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
173        ),
174        // Fp2::NONRESIDUE^(((q^9) - 1) / 6)
175        field!(
176            Fq2,
177            field!(
178                Fq,
179                BigInteger([
180                    0xecdcac262f7b88e2,
181                    0x19c17f37c25cb5cd,
182                    0xbd4e315e365e39ac,
183                    0x3a92f5b1fa177b15,
184                    0x85486a67941cd67e,
185                    0x55c8147ec0a38d,
186                ])
187            ),
188            field!(Fq, BigInteger([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
189        ),
190        // Fp2::NONRESIDUE^(((q^10) - 1) / 6)
191        field!(
192            Fq2,
193            field!(
194                Fq,
195                BigInteger([
196                    0xaa3baf925a7b868e,
197                    0x3e0d38ef753d5865,
198                    0x4191258bc861923,
199                    0x1e8a71ae63e00a87,
200                    0xeffc4d11826f20dc,
201                    0x4663a2a83dd119,
202                ])
203            ),
204            field!(Fq, BigInteger([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
205        ),
206        // Fp2::NONRESIDUE^(((q^11) - 1) / 6)
207        field!(
208            Fq2,
209            field!(
210                Fq,
211                BigInteger([
212                    0x5ba1262ad3735380,
213                    0xbdef8bf12b1eb012,
214                    0x14db82e63230f6cf,
215                    0xcda1e0bcc1b54fd3,
216                    0x2790ee45b226806c,
217                    0x1306f19ff2877fd,
218                ])
219            ),
220            field!(Fq, BigInteger([0x0, 0x0, 0x0, 0x0, 0x0, 0x0])),
221        ),
222    ];
223}