1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
use ark_ff::{
field_new,
fields::fp3::{Fp3, Fp3Parameters},
};
use crate::{
fields::{FQ_ONE, FQ_ZERO},
Fq,
};
pub type Fq3 = Fp3<Fq3Parameters>;
pub struct Fq3Parameters;
impl Fp3Parameters for Fq3Parameters {
type Fp = Fq;
#[rustfmt::skip]
const NONRESIDUE: Fq = field_new!(Fq, "-4");
const TWO_ADICITY: u32 = 1;
#[rustfmt::skip]
const T_MINUS_ONE_DIV_TWO: &'static [u64] = &[
0xb5e7c000000a3eac,
0xf79b99dbf41cf4ab,
0xe9372b1919e55ee5,
0xbb7bbc4936c1980b,
0x7c0cb9d4399b36e1,
0x73304a5507bb1ae0,
0x92f639be8963936f,
0x4f574ac2439ba816,
0x670d9bd389dd29ef,
0x606ddf900d2124f1,
0x928fb14985ec3270,
0x6b2f2428c5f420f3,
0xac9ade29d5ab5fbe,
0xec0d0434c4005822,
0x973f10d7f3c5c108,
0x6d5e83fc81095979,
0xdac3e6e4e1647752,
0x227febf93994603e,
0x4ab8755d894167d1,
0x4fd2d3f67d8b537a,
0x33e196a4d5f4030a,
0x88b51fb72092df1a,
0xa67e5b1e8fc48316,
0xb0855eb2a00d7dab,
0xe875dd2da6751442,
0x777594a243e25676,
0x294e0f70376a85a8,
0x83f431c7988e4f18,
0x8e8fb6af3ca2f5f1,
0x7297896b4b9e90f1,
0xff38f54664d66123,
0xb5ecf80bfff41e13,
0x1662a3666bb8392a,
0x07a0968e8742d3e1,
0xf12927e564bcdfdc,
0x5de9825a0e,
];
#[rustfmt::skip]
const QUADRATIC_NONRESIDUE_TO_T: (Fq, Fq, Fq) = (
field_new!(Fq, "6891450384315732539396789682275657542479668912536150109513790160209623422243491736087683183289411687640864567753786613451161759120554247759349511699125301598951605099378508850372543631423596795951899700429969112842764913119068298"),
FQ_ZERO,
FQ_ZERO,
);
#[rustfmt::skip]
const FROBENIUS_COEFF_FP3_C1: &'static [Fq] = &[
FQ_ONE,
field_new!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775648"),
field_new!(Fq, "1968985824090209297278610739700577151397666382303825728450741611566800370218827257750865013421937292370006175842381275743914023380727582819905021229583192207421122272650305267822868639090213645505120388400344940985710520836292650"),
];
#[rustfmt::skip]
const FROBENIUS_COEFF_FP3_C2: &'static [Fq] = &[
FQ_ONE,
field_new!(Fq, "1968985824090209297278610739700577151397666382303825728450741611566800370218827257750865013421937292370006175842381275743914023380727582819905021229583192207421122272650305267822868639090213645505120388400344940985710520836292650"),
field_new!(Fq, "4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775648"),
];
#[inline(always)]
fn mul_fp_by_nonresidue(fe: &Self::Fp) -> Self::Fp {
let original = -(*fe);
let double = original + &original;
double + &double
}
}