secp_r1/256/short_weierstrass_params.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2020-2021 Mikhail Komarov <nemo@nil.foundation>
3 // Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
4 //
5 // MIT License
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 //---------------------------------------------------------------------------//
25 
26 #ifndef CRYPTO3_ALGEBRA_CURVES_SECP_R1_256_SHORT_WEIERSTRASS_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_CURVES_SECP_R1_256_SHORT_WEIERSTRASS_PARAMS_HPP
28 
31 
33 
34 namespace nil {
35  namespace crypto3 {
36  namespace algebra {
37  namespace curves {
38  namespace detail {
39  template<>
40  struct secp_r1_params<160, forms::short_weierstrass> {
41 
44 
45  constexpr static const typename secp_r1_types<160>::integral_type a =
47  0xffffffffffffffffffffffffffffffff7ffffffc_cppui160);
53  constexpr static const typename secp_r1_types<160>::integral_type b =
55  0x1c97befc54bd7a8b65acf89f81d4d4adc565fa45_cppui160);
61  };
62 
63  template<>
64  struct secp_r1_g1_params<160, forms::short_weierstrass>
65  : public secp_r1_params<160, forms::short_weierstrass> {
66 
68 
69  template<typename Coordinates>
71 
72  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
73  field_type::value_type::zero(), field_type::value_type::one()};
74 
75  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
76  typename field_type::value_type(0x4a96b5688ef573284664698968c38bb913cbfc82_cppui160),
77  typename field_type::value_type(0x23a628553168947d59dcc912042351377ac5fb32_cppui160)};
78  };
79 
80  constexpr typename secp_r1_types<160>::integral_type const
82  constexpr typename secp_r1_types<160>::integral_type const
84 
85  constexpr std::array<
86  typename secp_r1_g1_params<160, forms::short_weierstrass>::field_type::value_type, 2> const
88  constexpr std::array<
89  typename secp_r1_g1_params<160, forms::short_weierstrass>::field_type::value_type, 2> const
91 
92  template<>
93  struct secp_r1_params<192, forms::short_weierstrass> {
94 
97 
98  constexpr static const typename secp_r1_types<192>::integral_type a =
100  0xfffffffffffffffffffffffffffffffefffffffffffffffc_cppui192);
106  constexpr static const typename secp_r1_types<192>::integral_type b =
108  0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1_cppui192);
114  };
115 
116  template<>
117  struct secp_r1_g1_params<192, forms::short_weierstrass>
118  : public secp_r1_params<192, forms::short_weierstrass> {
119 
121 
122  template<typename Coordinates>
124 
125  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
126  field_type::value_type::zero(), field_type::value_type::one()};
127 
128  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
129  typename field_type::value_type(
130  0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012_cppui192),
131  typename field_type::value_type(
132  0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811_cppui192)};
133  };
134 
135  constexpr typename secp_r1_types<192>::integral_type const
137  constexpr typename secp_r1_types<192>::integral_type const
139 
140  constexpr std::array<
141  typename secp_r1_g1_params<192, forms::short_weierstrass>::field_type::value_type, 2> const
143  constexpr std::array<
144  typename secp_r1_g1_params<192, forms::short_weierstrass>::field_type::value_type, 2> const
146 
147  template<>
148  struct secp_r1_params<224, forms::short_weierstrass> {
149 
152 
153  constexpr static const typename secp_r1_types<224>::integral_type a =
155  0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffe_cppui224);
161  constexpr static const typename secp_r1_types<224>::integral_type b =
163  0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4_cppui224);
169  };
170 
171  template<>
172  struct secp_r1_g1_params<224, forms::short_weierstrass>
173  : public secp_r1_params<224, forms::short_weierstrass> {
174 
176 
177  template<typename Coordinates>
179 
180  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
181  field_type::value_type::zero(), field_type::value_type::one()};
182 
183  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
184  typename field_type::value_type(
185  0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21_cppui224),
186  typename field_type::value_type(
187  0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34_cppui224)};
188  };
189 
190  constexpr typename secp_r1_types<224>::integral_type const
192  constexpr typename secp_r1_types<224>::integral_type const
194 
195  constexpr std::array<
196  typename secp_r1_g1_params<224, forms::short_weierstrass>::field_type::value_type, 2> const
198  constexpr std::array<
199  typename secp_r1_g1_params<224, forms::short_weierstrass>::field_type::value_type, 2> const
201 
202  template<>
203  struct secp_r1_params<256, forms::short_weierstrass> {
204 
207 
208  constexpr static const typename secp_r1_types<256>::integral_type a =
210  0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc_cppui256);
216  constexpr static const typename secp_r1_types<256>::integral_type b =
218  0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b_cppui256);
224  };
225 
226  template<>
227  struct secp_r1_g1_params<256, forms::short_weierstrass>
228  : public secp_r1_params<256, forms::short_weierstrass> {
229 
231 
232  template<typename Coordinates>
234 
235  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
236  field_type::value_type::zero(), field_type::value_type::one()};
237 
238  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
239  typename field_type::value_type(
240  0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296_cppui256),
241  typename field_type::value_type(
242  0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5_cppui256)};
243  };
244 
245  constexpr typename secp_r1_types<256>::integral_type const
247  constexpr typename secp_r1_types<256>::integral_type const
249 
250  constexpr std::array<
251  typename secp_r1_g1_params<256, forms::short_weierstrass>::field_type::value_type, 2> const
253  constexpr std::array<
254  typename secp_r1_g1_params<256, forms::short_weierstrass>::field_type::value_type, 2> const
256 
257  template<>
258  struct secp_r1_params<384, forms::short_weierstrass> {
259 
262 
263  constexpr static const typename secp_r1_types<384>::integral_type a =
265  0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc_cppui384);
271  constexpr static const typename secp_r1_types<384>::integral_type b =
273  0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef_cppui384);
279  };
280 
281  template<>
282  struct secp_r1_g1_params<384, forms::short_weierstrass>
283  : public secp_r1_params<384, forms::short_weierstrass> {
284 
286 
287  template<typename Coordinates>
289 
290  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
291  field_type::value_type::zero(), field_type::value_type::one()};
292 
293  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
294  typename field_type::value_type(
295  0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7_cppui384),
296  typename field_type::value_type(
297  0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f_cppui384)};
298  };
299 
300  constexpr typename secp_r1_types<384>::integral_type const
302  constexpr typename secp_r1_types<384>::integral_type const
304 
305  constexpr std::array<
306  typename secp_r1_g1_params<384, forms::short_weierstrass>::field_type::value_type, 2> const
308  constexpr std::array<
309  typename secp_r1_g1_params<384, forms::short_weierstrass>::field_type::value_type, 2> const
311 
312  template<>
313  struct secp_r1_params<521, forms::short_weierstrass> {
314 
317 
318  constexpr static const typename secp_r1_types<521>::integral_type a =
320  0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc_cppui521);
326  constexpr static const typename secp_r1_types<521>::integral_type b =
328  0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00_cppui521);
334  };
335 
336  template<>
337  struct secp_r1_g1_params<521, forms::short_weierstrass>
338  : public secp_r1_params<521, forms::short_weierstrass> {
339 
341 
342  template<typename Coordinates>
344 
345  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
346  field_type::value_type::zero(), field_type::value_type::one()};
347 
348  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
349  typename field_type::value_type(
350  0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66_cppui521),
351  typename field_type::value_type(
352  0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650_cppui521)};
353  };
354 
355  constexpr typename secp_r1_types<521>::integral_type const
357  constexpr typename secp_r1_types<521>::integral_type const
359 
360  constexpr std::array<
361  typename secp_r1_g1_params<521, forms::short_weierstrass>::field_type::value_type, 2> const
363  constexpr std::array<
364  typename secp_r1_g1_params<521, forms::short_weierstrass>::field_type::value_type, 2> const
366  } // namespace detail
367  } // namespace curves
368  } // namespace algebra
369  } // namespace crypto3
370 } // namespace nil
371 
372 #endif // CRYPTO3_ALGEBRA_CURVES_SECP_R1_256_SHORT_WEIERSTRASS_PARAMS_HPP
Definition: pair.hpp:31
typename secp_r1_types< 160 >::g1_field_type field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:67
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: secp_r1/256/short_weierstrass_params.hpp:72
secp_r1_types< 160 >::g1_type< forms::short_weierstrass, Coordinates > group_type
Definition: secp_r1/256/short_weierstrass_params.hpp:70
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: secp_r1/256/short_weierstrass_params.hpp:75
typename secp_r1_types< 192 >::g1_field_type field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:120
secp_r1_types< 192 >::g1_type< forms::short_weierstrass, Coordinates > group_type
Definition: secp_r1/256/short_weierstrass_params.hpp:123
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: secp_r1/256/short_weierstrass_params.hpp:125
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: secp_r1/256/short_weierstrass_params.hpp:128
typename secp_r1_types< 224 >::g1_field_type field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:175
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: secp_r1/256/short_weierstrass_params.hpp:183
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: secp_r1/256/short_weierstrass_params.hpp:180
secp_r1_types< 224 >::g1_type< forms::short_weierstrass, Coordinates > group_type
Definition: secp_r1/256/short_weierstrass_params.hpp:178
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: secp_r1/256/short_weierstrass_params.hpp:238
typename secp_r1_types< 256 >::g1_field_type field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:230
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: secp_r1/256/short_weierstrass_params.hpp:235
secp_r1_types< 256 >::g1_type< forms::short_weierstrass, Coordinates > group_type
Definition: secp_r1/256/short_weierstrass_params.hpp:233
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: secp_r1/256/short_weierstrass_params.hpp:293
secp_r1_types< 384 >::g1_type< forms::short_weierstrass, Coordinates > group_type
Definition: secp_r1/256/short_weierstrass_params.hpp:288
typename secp_r1_types< 384 >::g1_field_type field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:285
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: secp_r1/256/short_weierstrass_params.hpp:290
typename secp_r1_types< 521 >::g1_field_type field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:340
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: secp_r1/256/short_weierstrass_params.hpp:345
secp_r1_types< 521 >::g1_type< forms::short_weierstrass, Coordinates > group_type
Definition: secp_r1/256/short_weierstrass_params.hpp:343
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: secp_r1/256/short_weierstrass_params.hpp:348
Definition: curves/detail/secp_r1/types.hpp:45
constexpr static const secp_r1_types< 160 >::integral_type a
Definition: secp_r1/256/short_weierstrass_params.hpp:45
typename secp_r1_types< 160 >::base_field_type base_field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:42
typename secp_r1_types< 160 >::scalar_field_type scalar_field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:43
constexpr static const secp_r1_types< 160 >::integral_type b
Definition: secp_r1/256/short_weierstrass_params.hpp:53
constexpr static const secp_r1_types< 192 >::integral_type a
Definition: secp_r1/256/short_weierstrass_params.hpp:98
typename secp_r1_types< 192 >::base_field_type base_field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:95
constexpr static const secp_r1_types< 192 >::integral_type b
Definition: secp_r1/256/short_weierstrass_params.hpp:106
typename secp_r1_types< 192 >::scalar_field_type scalar_field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:96
typename secp_r1_types< 224 >::scalar_field_type scalar_field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:151
constexpr static const secp_r1_types< 224 >::integral_type a
Definition: secp_r1/256/short_weierstrass_params.hpp:153
typename secp_r1_types< 224 >::base_field_type base_field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:150
constexpr static const secp_r1_types< 224 >::integral_type b
Definition: secp_r1/256/short_weierstrass_params.hpp:161
typename secp_r1_types< 256 >::base_field_type base_field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:205
typename secp_r1_types< 256 >::scalar_field_type scalar_field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:206
constexpr static const secp_r1_types< 256 >::integral_type b
Definition: secp_r1/256/short_weierstrass_params.hpp:216
constexpr static const secp_r1_types< 256 >::integral_type a
Definition: secp_r1/256/short_weierstrass_params.hpp:208
typename secp_r1_types< 384 >::scalar_field_type scalar_field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:261
typename secp_r1_types< 384 >::base_field_type base_field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:260
constexpr static const secp_r1_types< 384 >::integral_type b
Definition: secp_r1/256/short_weierstrass_params.hpp:271
constexpr static const secp_r1_types< 384 >::integral_type a
Definition: secp_r1/256/short_weierstrass_params.hpp:263
constexpr static const secp_r1_types< 521 >::integral_type b
Definition: secp_r1/256/short_weierstrass_params.hpp:326
typename secp_r1_types< 521 >::scalar_field_type scalar_field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:316
typename secp_r1_types< 521 >::base_field_type base_field_type
Definition: secp_r1/256/short_weierstrass_params.hpp:315
constexpr static const secp_r1_types< 521 >::integral_type a
Definition: secp_r1/256/short_weierstrass_params.hpp:318
Definition: curves/detail/secp_r1/types.hpp:42
A struct representing details about base and scalar fields.
Definition: curves/detail/secp_r1/types.hpp:53
typename base_field_type::integral_type integral_type
Definition: curves/detail/secp_r1/types.hpp:59
Definition: forms.hpp:34