Botan 3.11.0
Crypto and TLS for C&
pcurves_numsp512d1.cpp
Go to the documentation of this file.
1/*
2* (C) 2024 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#include <botan/internal/pcurves_instance.h>
8
9#include <botan/internal/pcurves_wrap.h>
10
11namespace Botan::PCurve {
12
13namespace {
14
15namespace numsp512d1 {
16
17template <typename Params>
18class Numsp512d1Rep final {
19 public:
20 static constexpr auto P = Params::P;
21 static constexpr size_t N = Params::N;
22 typedef typename Params::W W;
23
24 static constexpr W C = 569;
25
26 constexpr static std::array<W, N> one() { return std::array<W, N>{1}; }
27
28 constexpr static std::array<W, N> redc(const std::array<W, 2 * N>& z) {
29 return redc_crandall<W, N, C>(std::span{z});
30 }
31
32 constexpr static std::array<W, N> to_rep(const std::array<W, N>& x) { return x; }
33
34 constexpr static std::array<W, N> wide_to_rep(const std::array<W, 2 * N>& x) { return redc(x); }
35
36 constexpr static std::array<W, N> from_rep(const std::array<W, N>& z) { return z; }
37};
38
39// clang-format off
40
41class Params final : public EllipticCurveParameters<
42 "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC7",
43 "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC4",
44 "1D99B",
45 "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5B3CA4FB94E7831B4FC258ED97D0BDC63B568B36607CD243CE153F390433555D",
46 "2",
47 "1C282EB23327F9711952C250EA61AD53FCC13031CF6DD336E0B9328433AFBDD8CC5A1C1F0C716FDC724DDE537C2B0ADB00BB3D08DC83755B205CC30D7F83CF28"> {
48};
49
50// clang-format on
51
52class Curve final : public EllipticCurve<Params, Numsp512d1Rep> {
53 public:
54 static constexpr FieldElement fe_invert2(const FieldElement& x) {
55 // Generated by https://github.com/mmcloughlin/addchain
56 auto z = x.square();
57 z *= x;
58 z = z.square();
59 z *= x;
60 auto t0 = z;
61 t0.square_n(3);
62 t0 *= z;
63 t0.square_n(3);
64 auto t1 = t0 * z;
65 t0 = t1;
66 t0.square_n(9);
67 t0 *= t1;
68 t0.square_n(3);
69 t0 *= z;
70 auto t2 = t0;
71 t2.square_n(9);
72 t1 *= t2;
73 t2 = t1;
74 t2.square_n(30);
75 t1 *= t2;
76 t2 = t1;
77 t2.square_n(60);
78 t1 *= t2;
79 t2 = t1;
80 t2.square_n(120);
81 t1 *= t2;
82 t2 = t1;
83 t2.square_n(240);
84 t1 *= t2;
85 t1.square_n(21);
86 t0 *= t1;
87 t0 = t0.square();
88 t0 *= x;
89 t0.square_n(4);
90 z *= t0;
91 z.square_n(4);
92 z *= x;
93 z.square_n(2);
94 return z;
95 }
96
97 static constexpr FieldElement fe_sqrt(const FieldElement& x) {
98 // Generated by https://github.com/mmcloughlin/addchain
99 auto z = x.square();
100 z *= x;
101 z = z.square();
102 z *= x;
103 auto t0 = z;
104 t0.square_n(3);
105 t0 *= z;
106 t0.square_n(3);
107 auto t1 = t0 * z;
108 t0 = t1;
109 t0.square_n(9);
110 t0 *= t1;
111 t0.square_n(3);
112 t0 *= z;
113 auto t2 = t0;
114 t2.square_n(9);
115 t1 *= t2;
116 t2 = t1;
117 t2.square_n(30);
118 t1 *= t2;
119 t2 = t1;
120 t2.square_n(60);
121 t1 *= t2;
122 t2 = t1;
123 t2.square_n(120);
124 t1 *= t2;
125 t2 = t1;
126 t2.square_n(240);
127 t1 *= t2;
128 t1.square_n(21);
129 t0 *= t1;
130 t0 = t0.square();
131 t0 *= x;
132 t0.square_n(4);
133 z *= t0;
134 z.square_n(3);
135 z *= x;
136 z = z.square();
137 return z;
138 }
139};
140
141} // namespace numsp512d1
142
143} // namespace
144
145std::shared_ptr<const PrimeOrderCurve> PCurveInstance::numsp512d1() {
147}
148
149} // namespace Botan::PCurve
static std::shared_ptr< const PrimeOrderCurve > instance()
constexpr std::array< W, N > redc_crandall(std::span< const W, 2 *N > z)
Definition mp_core.h:975