brainpool_r1.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_BRAINPOOL_R1_HPP
27 #define CRYPTO3_ALGEBRA_CURVES_BRAINPOOL_R1_HPP
28 
29 #include <nil/crypto3/algebra/curves/detail/brainpool_r1/g1.hpp>
30 #include <nil/crypto3/algebra/curves/detail/brainpool_r1/g2.hpp>
31 
34 
36 
37 namespace nil {
38  namespace crypto3 {
39  namespace algebra {
40  namespace curves {
41 
42  template<std::size_t PBits>
43  struct brainpool_r1 { };
44 
45  template<>
46  struct brainpool_r1<160> {
47 
48  constexpr static const std::size_t base_field_bits = 160;
50  typedef typename base_field_type::integral_type integral_type;
51  constexpr static const integral_type base_field_modulus = base_field_type::modulus;
52 
53  constexpr static const std::size_t scalar_field_bits = 160;
55  constexpr static const integral_type scalar_field_modulus = scalar_field_type::modulus;
56 
57  typedef typename detail::brainpool_r1_g1<160> g1_type;
58  typedef typename detail::brainpool_r1_g2<160> g2_type;
59 
60  typedef typename fields::fp ? ? <base_field_type>::value_type gt_type;
61 
62  constexpr static const integral_type p = base_field_modulus;
63  constexpr static const integral_type q = scalar_field_modulus;
64 
65  constexpr static const integral_type a = 0x340E7BE2A280EB74E2BE61BADA745D97E8F7C300_cppui160;
66  constexpr static const integral_type b = 0x1E589A8595423412134FAA2DBDEC95C8D8675E58_cppui160;
67  constexpr static const integral_type x = 0xBED5AF16EA3F6A4F62938C4631EB5AF7BDBCDBC3_cppui160;
68  constexpr static const integral_type y = 0x1667CB477A1A8EC338F94741669C976316DA6321_cppui160;
69  };
70 
71  template<>
72  struct brainpool_r1<192> {
73 
74  constexpr static const std::size_t base_field_bits = 192;
76  typedef typename base_field_type::integral_type integral_type;
77  constexpr static const integral_type base_field_modulus = base_field_type::modulus;
78 
79  constexpr static const std::size_t scalar_field_bits = 192;
81  constexpr static const integral_type scalar_field_modulus = scalar_field_type::modulus;
82 
83  typedef typename detail::brainpool_r1_g1<192> g1_type;
84  typedef typename detail::brainpool_r1_g2<192> g2_type;
85 
86  typedef typename fields::fp ? ? <base_field_type>::value_type gt_type;
87 
88  constexpr static const integral_type p = base_field_modulus;
89  constexpr static const integral_type q = scalar_field_modulus;
90 
91  constexpr static const integral_type a =
92  0x6A91174076B1E0E19C39C031FE8685C1CAE040E5C69A28EF_cppui192;
93  constexpr static const integral_type b =
94  0x469A28EF7C28CCA3DC721D044F4496BCCA7EF4146FBF25C9_cppui192;
95  constexpr static const integral_type x =
96  0xC0A0647EAAB6A48753B033C56CB0F0900A2F5C4853375FD6_cppui192;
97  constexpr static const integral_type y =
98  0x14B690866ABD5BB88B5F4828C1490002E6773FA2FA299B8F_cppui192;
99  };
100 
101  template<>
102  struct brainpool_r1<224> {
103 
104  constexpr static const std::size_t base_field_bits = 224;
106  typedef typename base_field_type::integral_type integral_type;
107  constexpr static const integral_type base_field_modulus = base_field_type::modulus;
108 
109  constexpr static const std::size_t scalar_field_bits = 224;
111  constexpr static const integral_type scalar_field_modulus = scalar_field_type::modulus;
112 
113  typedef typename detail::brainpool_r1_g1<224> g1_type;
114  typedef typename detail::brainpool_r1_g2<224> g2_type;
115 
116  typedef typename fields::fp ? ? <base_field_type>::value_type gt_type;
117 
118  constexpr static const integral_type p = base_field_modulus;
119  constexpr static const integral_type q = scalar_field_modulus;
120 
121  constexpr static const integral_type a =
122  0x68A5E62CA9CE6C1C299803A6C1530B514E182AD8B0042A59CAD29F43_cppui224;
123  constexpr static const integral_type b =
124  0x2580F63CCFE44138870713B1A92369E33E2135D266DBB372386C400B_cppui224;
125  constexpr static const integral_type x =
126  0xD9029AD2C7E5CF4340823B2A87DC68C9E4CE3174C1E6EFDEE12C07D_cppui224;
127  constexpr static const integral_type y =
128  0x58AA56F772C0726F24C6B89E4ECDAC24354B9E99CAA3F6D3761402CD_cppui224;
129  };
130 
131  template<>
132  struct brainpool_r1<256> {
133 
134  constexpr static const std::size_t base_field_bits = 256;
136  typedef typename base_field_type::integral_type integral_type;
137  constexpr static const integral_type base_field_modulus = base_field_type::modulus;
138 
139  constexpr static const std::size_t scalar_field_bits = 256;
141  constexpr static const integral_type scalar_field_modulus = scalar_field_type::modulus;
142 
143  typedef typename detail::brainpool_r1_g1<256> g1_type;
144  typedef typename detail::brainpool_r1_g2<256> g2_type;
145 
146  typedef typename fields::fp ? ? <base_field_type>::value_type gt_type;
147 
148  constexpr static const integral_type p = base_field_modulus;
149  constexpr static const integral_type q = scalar_field_modulus;
150 
151  constexpr static const integral_type a =
152  0x7D5A0975FC2C3057EEF67530417AFFE7FB8055C126DC5C6CE94A4B44F330B5D9_cppui256;
153  constexpr static const integral_type b =
154  0x26DC5C6CE94A4B44F330B5D9BBD77CBF958416295CF7E1CE6BCCDC18FF8C07B6_cppui256;
155  constexpr static const integral_type x =
156  0x8BD2AEB9CB7E57CB2C4B482FFC81B7AFB9DE27E1E3BD23C23A4453BD9ACE3262_cppui256;
157  constexpr static const integral_type y =
158  0x547EF835C3DAC4FD97F8461A14611DC9C27745132DED8E545C1D54C72F046997_cppui256;
159  };
160 
161  template<>
162  struct brainpool_r1<320> {
163  constexpr static const std::size_t base_field_bits = 320;
165  typedef typename base_field_type::integral_type integral_type;
166  constexpr static const integral_type base_field_modulus = base_field_type::modulus;
167 
168  constexpr static const std::size_t scalar_field_bits = 320;
170  constexpr static const integral_type scalar_field_modulus = scalar_field_type::modulus;
171 
172  typedef typename detail::brainpool_r1_g1<320> g1_type;
173  typedef typename detail::brainpool_r1_g2<320> g2_type;
174 
175  typedef typename fields::fp ? ? <base_field_type>::value_type gt_type;
176 
177  constexpr static const integral_type p = base_field_modulus;
178  constexpr static const integral_type q = scalar_field_modulus;
179 
180  constexpr static const integral_type a =
181  0x3EE30B568FBAB0F883CCEBD46D3F3BB8A2A73513F5EB79DA66190EB085FFA9F492F375A97D860EB4_cppui320;
182  constexpr static const integral_type b =
183  0x520883949DFDBC42D3AD198640688A6FE13F41349554B49ACC31DCCD884539816F5EB4AC8FB1F1A6_cppui320;
184  constexpr static const integral_type x =
185  0x43BD7E9AFB53D8B85289BCC48EE5BFE6F20137D10A087EB6E7871E2A10A599C710AF8D0D39E20611_cppui320;
186  constexpr static const integral_type y =
187  0x14FDD05545EC1CC8AB4093247F77275E0743FFED117182EAA9C77877AAAC6AC7D35245D1692E8EE1_cppui320;
188  };
189 
190  template<>
191  struct brainpool_r1<384> {
192  constexpr static const std::size_t base_field_bits = 384;
194  typedef typename base_field_type::integral_type integral_type;
195  constexpr static const integral_type base_field_modulus = base_field_type::modulus;
196 
197  constexpr static const std::size_t scalar_field_bits = 384;
199  constexpr static const integral_type scalar_field_modulus = scalar_field_type::modulus;
200 
201  typedef typename detail::brainpool_r1_g1<384> g1_type;
202  typedef typename detail::brainpool_r1_g2<384> g2_type;
203 
204  typedef typename fields::fp ? ? <base_field_type>::value_type gt_type;
205 
206  constexpr static const integral_type p = base_field_modulus;
207  constexpr static const integral_type q = scalar_field_modulus;
208 
209  constexpr static const integral_type a =
210  0x7BC382C63D8C150C3C72080ACE05AFA0C2BEA28E4FB22787139165EFBA91F90F8AA5814A503AD4EB04A8C7DD22CE2826_cppui384;
211  constexpr static const integral_type b =
212  0x4A8C7DD22CE28268B39B55416F0447C2FB77DE107DCD2A62E880EA53EEB62D57CB4390295DBC9943AB78696FA504C11_cppui384;
213  constexpr static const integral_type x =
214  0x1D1C64F068CF45FFA2A63A81B7C13F6B8847A3E77EF14FE3DB7FCAFE0CBD10E8E826E03436D646AAEF87B2E247D4AF1E_cppui384;
215  constexpr static const integral_type y =
216  0x8ABE1D7520F9C2A45CB1EB8E95CFD55262B70B29FEEC5864E19C054FF99129280E4646217791811142820341263C5315_cppui384;
217  };
218 
219  template<>
220  struct brainpool_r1<512> {
221  constexpr static const std::size_t base_field_bits = 512;
223  typedef typename base_field_type::integral_type integral_type;
224  constexpr static const integral_type base_field_modulus = base_field_type::modulus;
225 
226  constexpr static const std::size_t scalar_field_bits = 512;
228  constexpr static const integral_type scalar_field_modulus = scalar_field_type::modulus;
229 
230  typedef typename detail::brainpool_r1_g1<512> g1_type;
231  typedef typename detail::brainpool_r1_g2<512> g2_type;
232 
233  typedef typename fields::fp ? ? <base_field_type>::value_type gt_type;
234 
235  constexpr static const integral_type p = base_field_modulus;
236  constexpr static const integral_type q = scalar_field_modulus;
237 
238  constexpr static const integral_type a =
239  0x7830A3318B603B89E2327145AC234CC594CBDD8D3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CA_cppui512;
240  constexpr static const integral_type b =
241  0x3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CADC083E67984050B75EBAE5DD2809BD638016F723_cppui512;
242  constexpr static const integral_type x =
243  0x81AEE4BDD82ED9645A21322E9C4C6A9385ED9F70B5D916C1B43B62EEF4D0098EFF3B1F78E2D0D48D50D1687B93B97D5F7C6D5047406A5E688B352209BCB9F822_cppui512;
244  constexpr static const integral_type y =
245  0x7DDE385D566332ECC0EABFA9CF7822FDF209F70024A57B1AA000C55B881F8111B2DCDE494A5F485E5BCA4BD88A2763AED1CA2B2FA8F0540678CD1E0F3AD80892_cppui512;
246  };
247 
255 
256  } // namespace curves
257  } // namespace algebra
258  } // namespace crypto3
259 } // namespace nil
260 
261 #endif // CRYPTO3_ALGEBRA_CURVES_BRAINPOOL_R1_HPP
brainpool_r1< 512 > brainpool512r1
Definition: brainpool_r1.hpp:254
brainpool_r1< 192 > brainpool192r1
Definition: brainpool_r1.hpp:249
brainpool_r1< 160 > brainpool160r1
Definition: brainpool_r1.hpp:248
brainpool_r1< 256 > brainpool256r1
Definition: brainpool_r1.hpp:251
brainpool_r1< 384 > brainpool384r1
Definition: brainpool_r1.hpp:253
brainpool_r1< 224 > brainpool224r1
Definition: brainpool_r1.hpp:250
brainpool_r1< 320 > brainpool320r1
Definition: brainpool_r1.hpp:252
Definition: pair.hpp:31
base_field_type::integral_type integral_type
Definition: brainpool_r1.hpp:50
detail::brainpool_r1_g1< 160 > g1_type
Definition: brainpool_r1.hpp:57
fields::brainpool_r1_fr< scalar_field_bits > scalar_field_type
Definition: brainpool_r1.hpp:54
detail::brainpool_r1_g2< 160 > g2_type
Definition: brainpool_r1.hpp:58
fields::brainpool_r1_fq< base_field_bits > base_field_type
Definition: brainpool_r1.hpp:49
fields::fp< base_field_type > ::value_type gt_type
Definition: brainpool_r1.hpp:60
fields::brainpool_r1_fq< base_field_bits > base_field_type
Definition: brainpool_r1.hpp:75
base_field_type::integral_type integral_type
Definition: brainpool_r1.hpp:76
fields::fp< base_field_type > ::value_type gt_type
Definition: brainpool_r1.hpp:86
fields::brainpool_r1_fr< scalar_field_bits > scalar_field_type
Definition: brainpool_r1.hpp:80
detail::brainpool_r1_g1< 192 > g1_type
Definition: brainpool_r1.hpp:83
detail::brainpool_r1_g2< 192 > g2_type
Definition: brainpool_r1.hpp:84
detail::brainpool_r1_g1< 224 > g1_type
Definition: brainpool_r1.hpp:113
base_field_type::integral_type integral_type
Definition: brainpool_r1.hpp:106
detail::brainpool_r1_g2< 224 > g2_type
Definition: brainpool_r1.hpp:114
fields::fp< base_field_type > ::value_type gt_type
Definition: brainpool_r1.hpp:116
fields::brainpool_r1_fr< scalar_field_bits > scalar_field_type
Definition: brainpool_r1.hpp:110
fields::brainpool_r1_fq< base_field_bits > base_field_type
Definition: brainpool_r1.hpp:105
base_field_type::integral_type integral_type
Definition: brainpool_r1.hpp:136
fields::fp< base_field_type > ::value_type gt_type
Definition: brainpool_r1.hpp:146
detail::brainpool_r1_g1< 256 > g1_type
Definition: brainpool_r1.hpp:143
detail::brainpool_r1_g2< 256 > g2_type
Definition: brainpool_r1.hpp:144
fields::brainpool_r1_fq< base_field_bits > base_field_type
Definition: brainpool_r1.hpp:135
fields::brainpool_r1_fr< scalar_field_bits > scalar_field_type
Definition: brainpool_r1.hpp:140
detail::brainpool_r1_g1< 320 > g1_type
Definition: brainpool_r1.hpp:172
fields::fp< base_field_type > ::value_type gt_type
Definition: brainpool_r1.hpp:175
fields::brainpool_r1_fq< base_field_bits > base_field_type
Definition: brainpool_r1.hpp:164
fields::brainpool_r1_fr< scalar_field_bits > scalar_field_type
Definition: brainpool_r1.hpp:169
detail::brainpool_r1_g2< 320 > g2_type
Definition: brainpool_r1.hpp:173
base_field_type::integral_type integral_type
Definition: brainpool_r1.hpp:165
fields::fp< base_field_type > ::value_type gt_type
Definition: brainpool_r1.hpp:204
detail::brainpool_r1_g1< 384 > g1_type
Definition: brainpool_r1.hpp:201
fields::brainpool_r1_fr< scalar_field_bits > scalar_field_type
Definition: brainpool_r1.hpp:198
base_field_type::integral_type integral_type
Definition: brainpool_r1.hpp:194
detail::brainpool_r1_g2< 384 > g2_type
Definition: brainpool_r1.hpp:202
fields::brainpool_r1_fq< base_field_bits > base_field_type
Definition: brainpool_r1.hpp:193
base_field_type::integral_type integral_type
Definition: brainpool_r1.hpp:223
fields::brainpool_r1_fq< base_field_bits > base_field_type
Definition: brainpool_r1.hpp:222
detail::brainpool_r1_g1< 512 > g1_type
Definition: brainpool_r1.hpp:230
detail::brainpool_r1_g2< 512 > g2_type
Definition: brainpool_r1.hpp:231
fields::fp< base_field_type > ::value_type gt_type
Definition: brainpool_r1.hpp:233
fields::brainpool_r1_fr< scalar_field_bits > scalar_field_type
Definition: brainpool_r1.hpp:227
Definition: brainpool_r1.hpp:43
IETF IPsec groups.
Definition: brainpool_r1/base_field.hpp:46
IETF IPsec groups.
Definition: brainpool_r1/scalar_field.hpp:46