secp_k1/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_K1_256_SHORT_WEIERSTRASS_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_CURVES_SECP_K1_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_k1_params<160, forms::short_weierstrass> {
41 
44 
45  constexpr static const typename secp_k1_types<160>::integral_type a =
47  0x00);
48  constexpr static const typename secp_k1_types<160>::integral_type b =
50  0x07);
51  };
52 
53  template<>
54  struct secp_k1_g1_params<160, forms::short_weierstrass>
55  : public secp_k1_params<160, forms::short_weierstrass> {
56 
58 
59  template<typename Coordinates>
61 
62  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
63  field_type::value_type::zero(), field_type::value_type::one()};
64 
65  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
66  typename field_type::value_type(0x3b4c382ce37aa192a4019e763036f4f5dd4d7ebb_cppui160),
67  typename field_type::value_type(0x938cf935318fdced6bc28286531733c3f03c4fee_cppui160)};
68  };
69 
70  constexpr typename secp_k1_types<160>::integral_type const
72  constexpr typename secp_k1_types<160>::integral_type const
74 
75  constexpr std::array<
76  typename secp_k1_g1_params<160, forms::short_weierstrass>::field_type::value_type, 2> const
78  constexpr std::array<
79  typename secp_k1_g1_params<160, forms::short_weierstrass>::field_type::value_type, 2> const
81 
82  template<>
83  struct secp_k1_params<192, forms::short_weierstrass> {
84 
87 
88  constexpr static const typename secp_k1_types<192>::integral_type a =
90  0x00);
91  constexpr static const typename secp_k1_types<192>::integral_type b =
93  0x3);
94  };
95 
96  template<>
97  struct secp_k1_g1_params<192, forms::short_weierstrass>
98  : public secp_k1_params<192, forms::short_weierstrass> {
99 
101 
102  template<typename Coordinates>
104 
105  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
106  field_type::value_type::zero(), field_type::value_type::one()};
107 
108  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
109  typename field_type::value_type(
110  0xdb4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d_cppui192),
111  typename field_type::value_type(
112  0x9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d_cppui192)};
113  };
114 
115  constexpr typename secp_k1_types<192>::integral_type const
117  constexpr typename secp_k1_types<192>::integral_type const
119 
120  constexpr std::array<
121  typename secp_k1_g1_params<192, forms::short_weierstrass>::field_type::value_type, 2> const
123  constexpr std::array<
124  typename secp_k1_g1_params<192, forms::short_weierstrass>::field_type::value_type, 2> const
126 
127  template<>
128  struct secp_k1_params<224, forms::short_weierstrass> {
129 
132 
133  constexpr static const typename secp_k1_types<224>::integral_type a =
135  0x00);
136  constexpr static const typename secp_k1_types<224>::integral_type b =
138  0x5);
139  };
140 
141  template<>
142  struct secp_k1_g1_params<224, forms::short_weierstrass>
143  : public secp_k1_params<224, forms::short_weierstrass> {
144 
146 
147  template<typename Coordinates>
149 
150  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
151  field_type::value_type::zero(), field_type::value_type::one()};
152 
153  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
154  typename field_type::value_type(
155  0xa1455b334df099df30fc28a169a467e9e47075a90f7e650eb6b7a45c_cppui224),
156  typename field_type::value_type(
157  0x7e089fed7fba344282cafbd6f7e319f7c0b0bd59e2ca4bdb556d61a5_cppui224)};
158  };
159 
160  constexpr typename secp_k1_types<224>::integral_type const
162  constexpr typename secp_k1_types<224>::integral_type const
164 
165  constexpr std::array<
166  typename secp_k1_g1_params<224, forms::short_weierstrass>::field_type::value_type, 2> const
168  constexpr std::array<
169  typename secp_k1_g1_params<224, forms::short_weierstrass>::field_type::value_type, 2> const
171 
172  template<>
173  struct secp_k1_params<256, forms::short_weierstrass> {
174 
177 
178  constexpr static const typename secp_k1_types<256>::integral_type a =
180  0x00);
181  constexpr static const typename secp_k1_types<256>::integral_type b =
183  0x07);
184  };
185 
186  template<>
187  struct secp_k1_g1_params<256, forms::short_weierstrass>
188  : public secp_k1_params<256, forms::short_weierstrass> {
189 
191 
192  template<typename Coordinates>
194 
195  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
196  field_type::value_type::zero(), field_type::value_type::one()};
197 
198  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
199  typename field_type::value_type(
200  0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798_cppui256),
201  typename field_type::value_type(
202  0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8_cppui256)};
203  };
204 
205  constexpr typename secp_k1_types<256>::integral_type const
207  constexpr typename secp_k1_types<256>::integral_type const
209 
210  constexpr std::array<
211  typename secp_k1_g1_params<256, forms::short_weierstrass>::field_type::value_type, 2> const
213  constexpr std::array<
214  typename secp_k1_g1_params<256, forms::short_weierstrass>::field_type::value_type, 2> const
216  } // namespace detail
217  } // namespace curves
218  } // namespace algebra
219  } // namespace crypto3
220 } // namespace nil
221 
222 #endif // CRYPTO3_ALGEBRA_CURVES_SECP_K1_256_SHORT_WEIERSTRASS_PARAMS_HPP
Definition: pair.hpp:31
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: secp_k1/256/short_weierstrass_params.hpp:65
typename secp_k1_types< 160 >::g1_field_type field_type
Definition: secp_k1/256/short_weierstrass_params.hpp:57
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: secp_k1/256/short_weierstrass_params.hpp:62
secp_k1_types< 160 >::g1_type< forms::short_weierstrass, Coordinates > group_type
Definition: secp_k1/256/short_weierstrass_params.hpp:60
secp_k1_types< 192 >::g1_type< forms::short_weierstrass, Coordinates > group_type
Definition: secp_k1/256/short_weierstrass_params.hpp:103
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: secp_k1/256/short_weierstrass_params.hpp:105
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: secp_k1/256/short_weierstrass_params.hpp:108
typename secp_k1_types< 192 >::g1_field_type field_type
Definition: secp_k1/256/short_weierstrass_params.hpp:100
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: secp_k1/256/short_weierstrass_params.hpp:153
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: secp_k1/256/short_weierstrass_params.hpp:150
secp_k1_types< 224 >::g1_type< forms::short_weierstrass, Coordinates > group_type
Definition: secp_k1/256/short_weierstrass_params.hpp:148
typename secp_k1_types< 224 >::g1_field_type field_type
Definition: secp_k1/256/short_weierstrass_params.hpp:145
typename secp_k1_types< 256 >::g1_field_type field_type
Definition: secp_k1/256/short_weierstrass_params.hpp:190
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: secp_k1/256/short_weierstrass_params.hpp:195
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: secp_k1/256/short_weierstrass_params.hpp:198
secp_k1_types< 256 >::g1_type< forms::short_weierstrass, Coordinates > group_type
Definition: secp_k1/256/short_weierstrass_params.hpp:193
Definition: curves/detail/secp_k1/types.hpp:45
typename secp_k1_types< 160 >::base_field_type base_field_type
Definition: secp_k1/256/short_weierstrass_params.hpp:42
constexpr static const secp_k1_types< 160 >::integral_type a
coefficient of short Weierstrass curve $y^2=x^3+a*x+b$
Definition: secp_k1/256/short_weierstrass_params.hpp:45
typename secp_k1_types< 160 >::scalar_field_type scalar_field_type
Definition: secp_k1/256/short_weierstrass_params.hpp:43
constexpr static const secp_k1_types< 160 >::integral_type b
coefficient of short Weierstrass curve $y^2=x^3+a*x+b$
Definition: secp_k1/256/short_weierstrass_params.hpp:48
typename secp_k1_types< 192 >::base_field_type base_field_type
Definition: secp_k1/256/short_weierstrass_params.hpp:85
typename secp_k1_types< 192 >::scalar_field_type scalar_field_type
Definition: secp_k1/256/short_weierstrass_params.hpp:86
constexpr static const secp_k1_types< 192 >::integral_type a
coefficient of short Weierstrass curve $y^2=x^3+a*x+b$
Definition: secp_k1/256/short_weierstrass_params.hpp:88
constexpr static const secp_k1_types< 192 >::integral_type b
coefficient of short Weierstrass curve $y^2=x^3+a*x+b$
Definition: secp_k1/256/short_weierstrass_params.hpp:91
typename secp_k1_types< 224 >::scalar_field_type scalar_field_type
Definition: secp_k1/256/short_weierstrass_params.hpp:131
typename secp_k1_types< 224 >::base_field_type base_field_type
Definition: secp_k1/256/short_weierstrass_params.hpp:130
constexpr static const secp_k1_types< 224 >::integral_type a
coefficient of short Weierstrass curve $y^2=x^3+a*x+b$
Definition: secp_k1/256/short_weierstrass_params.hpp:133
constexpr static const secp_k1_types< 224 >::integral_type b
coefficient of short Weierstrass curve $y^2=x^3+a*x+b$
Definition: secp_k1/256/short_weierstrass_params.hpp:136
typename secp_k1_types< 256 >::base_field_type base_field_type
Definition: secp_k1/256/short_weierstrass_params.hpp:175
constexpr static const secp_k1_types< 256 >::integral_type b
coefficient of short Weierstrass curve $y^2=x^3+a*x+b$
Definition: secp_k1/256/short_weierstrass_params.hpp:181
typename secp_k1_types< 256 >::scalar_field_type scalar_field_type
Definition: secp_k1/256/short_weierstrass_params.hpp:176
constexpr static const secp_k1_types< 256 >::integral_type a
coefficient of short Weierstrass curve $y^2=x^3+a*x+b$
Definition: secp_k1/256/short_weierstrass_params.hpp:178
Definition: curves/detail/secp_k1/types.hpp:42
A struct representing details about base and scalar fields.
Definition: curves/detail/secp_k1/types.hpp:52
typename base_field_type::integral_type integral_type
Definition: curves/detail/secp_k1/types.hpp:58
Definition: forms.hpp:34