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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#[cfg(feature = "test_macros")]
#[cfg(test)]
mod tests {
// Random prime with no nice properties for Montgomery friendliness
mod fp_ugly_tests {
// Field modulus
const MODULUS: [u64; 2] = [0x5A0E852097C48043, 0x7EA2A3A646684E9D];
// Contents are opaque, all functions are constant-time.
// Macro input generated with scripts/gen_fp.sage
fp2::define_fp_core!(typename = FpUgly, modulus = MODULUS,);
fp2::define_fp_tests!(FpUgly);
// FpUglyExt: a finite field element GF(p^2) with modulus x^2 + 1.
// Contents are opaque, all functions are constant-time.
// Macro input generated with scripts/gen_fp.sage
fp2::define_fp2_from_modulus!(typename = FpUglyExt, base_typename = Fp, modulus = MODULUS,);
fp2::define_fp2_tests!(FpUglyExt, MODULUS, 1);
}
mod fp127_tests {
// Field modulus
const MODULUS: [u64; 2] = [0xFFFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF];
// Fp139: a finite field element GF(p) with p = 3 mod 4.
// Contents are opaque, all functions are constant-time.
// Macro input generated with scripts/gen_fp.sage
// p = 2^127 - 1
fp2::define_fp_core!(typename = Fp127, modulus = MODULUS,);
fp2::define_fp_tests!(Fp127);
// Fp127Ext: a finite field element GF(p^2) with modulus x^2 + 1.
// Contents are opaque, all functions are constant-time.
// Macro input generated with scripts/gen_fp.sage
fp2::define_fp2_from_modulus!(typename = Fp127Ext, base_typename = Fp, modulus = MODULUS,);
fp2::define_fp2_tests!(Fp127Ext, MODULUS, 2);
}
mod fp251_tests {
// Field modulus
const MODULUS: [u64; 4] = [
0xFFFFFFFFFFFFFFFF,
0xFFFFFFFFFFFFFFFF,
0xFFFFFFFFFFFFFFFF,
0x04FFFFFFFFFFFFFF,
];
// Fp251: a finite field element GF(p) with p = 3 mod 4.
// Contents are opaque, all functions are constant-time.
// Macro input generated with scripts/gen_fp.sage
// p = 5*2^248 - 1
fp2::define_fp_core!(typename = Fp251, modulus = MODULUS,);
// Fp251Ext: a finite field element GF(p^2) with modulus x^2 + 1.
// Contents are opaque, all functions are constant-time.
// Macro input generated with scripts/gen_fp.sage
fp2::define_fp2_from_type!(typename = Fp251Ext, base_field = Fp251,);
fp2::define_fp_tests!(Fp251);
fp2::define_fp2_tests!(Fp251Ext, MODULUS, 5);
}
mod fp383_tests {
// Field modulus
const MODULUS: [u64; 6] = [
0xFFFFFFFFFFFFFFFF,
0xFFFFFFFFFFFFFFFF,
0xFFFFFFFFFFFFFFFF,
0xFFFFFFFFFFFFFFFF,
0xFFFFFFFFFFFFFFFF,
0x40FFFFFFFFFFFFFF,
];
// Fp383: a finite field element GF(p) with p = 3 mod 4.
// Contents are opaque, all functions are constant-time.
// Macro input generated with scripts/gen_fp.sage
// p = 65 * 2**376 - 1
fp2::define_fp_core!(typename = Fp383, modulus = MODULUS,);
// Fp383Ext: a finite field element GF(p^2) with modulus x^2 + 1.
// Contents are opaque, all functions are constant-time.
// Macro input generated with scripts/gen_fp.sage
fp2::define_fp2_from_type!(typename = Fp383Ext, base_field = Fp383,);
// For define_fp2_tests we must include a u64 nqr_re such that
// nqr_re + i is a non-quadratic residue in Fp2
fp2::define_fp_tests!(Fp383);
fp2::define_fp2_tests!(Fp383Ext, MODULUS, 6);
}
mod fp434_tests {
// NIST lvl 1 SIKE prime: p = 2^216 * 3^137 - 1
// Fp434Ext: a finite field element GF(p^2) with modulus x^2 + 1.
const MODULUS: [u64; 7] = [
0xFFFFFFFFFFFFFFFF,
0xFFFFFFFFFFFFFFFF,
0xFFFFFFFFFFFFFFFF,
0xFDC1767AE2FFFFFF,
0x7BC65C783158AEA3,
0x6CFC5FD681C52056,
0x0002341F27177344,
];
fp2::define_fp2_from_modulus!(
typename = Fp434Ext,
base_typename = Fp434,
modulus = MODULUS,
);
// For define_fp2_tests we must include a u64 nqr_re such that
// nqr_re + i is a non-quadratic residue in Fp2
fp2::define_fp_tests!(Fp434);
fp2::define_fp2_tests!(Fp434Ext, MODULUS, 2);
}
}