fields/arithmetic_params/edwards.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_FIELDS_EDWARDS_ARITHMETIC_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_FIELDS_EDWARDS_ARITHMETIC_PARAMS_HPP
28 
30 
34 
36 
37 namespace nil {
38  namespace crypto3 {
39  namespace algebra {
40  namespace fields {
41 
42  template<std::size_t Version>
43  struct arithmetic_params<edwards_base_field<Version>> : public params<edwards_base_field<Version>> {
44  private:
46 
47  public:
51 
52  constexpr static const std::size_t s = 0x1F;
53  constexpr static const integral_type t = 0x81ABF93A5472B62717249DAC685A836DD6D217_cppui152;
54  constexpr static const integral_type t_minus_1_over_2 =
55  0x40D5FC9D2A395B138B924ED6342D41B6EB690B_cppui151;
56  constexpr static const integral_type arithmetic_generator = 0x01;
57  constexpr static const integral_type geometric_generator = 0x02;
58  constexpr static const integral_type multiplicative_generator = 0x3D;
59  constexpr static const integral_type root_of_unity =
60  0x30FEC8F966ACFB3EC66B728E26AE7A5C00AAE9A96D8FE8_cppui182;
61  constexpr static const integral_type nqr = 0x17;
62  constexpr static const integral_type nqr_to_t =
63  0x1B6CA5BFFDB95045F86768636493E1C6488D1BD4605D82_cppui181;
64  constexpr static const integral_type Rsquared =
65  0x3E0DBC8EEC1F76E0BF35FF926AC105F6D1824A80E54068_cppui182;
66  constexpr static const integral_type Rcubed =
67  0xB4AC1B77CA0D59F20E4D04D7048823FE112E6248253AD_cppui180;
68 
69  constexpr static const integral_type modulus = policy_type::modulus;
70  constexpr static const integral_type group_order =
71  0x206AFE4E951CAD89C5C9276B1A16A0DB75B485C0000000_cppui182;
72  };
73 
74  template<std::size_t Version>
76  : public params<edwards_base_field<Version>> {
77  private:
79 
80  public:
85 
86  constexpr static const std::size_t s = 0x1F;
87  constexpr static const extended_integral_type t =
88  0x8514C337908664095AA1E4077718C1F93B49FEBD3E1DE5A3BF284A7BC8C90EE457BC1D3D59409F6A8049FB3D3B1E20915D50941493A9E2B4B0685ACA3C9847645_cppui516;
89  constexpr static const extended_integral_type t_minus_1_over_2 =
90  0x428A619BC8433204AD50F203BB8C60FC9DA4FF5E9F0EF2D1DF94253DE46487722BDE0E9EACA04FB54024FD9E9D8F1048AEA84A0A49D4F15A58342D651E4C23B22_cppui515;
91  constexpr static const std::array<integral_type, 3> nqr = {0x17, 0x00, 0x00};
92  constexpr static const std::array<integral_type, 3> nqr_to_t = {
93  0x118228ECB464A2F6EB8DACC18FA757E45B3989330150C_cppui177, 0x00, 0x00};
94 
95  constexpr static const integral_type modulus = policy_type::modulus;
96  constexpr static const extended_integral_type group_order =
97  0x214530CDE421990256A87901DDC6307E4ED27FAF4F877968EFCA129EF23243B915EF074F565027DAA0127ECF4EC788245754250524EA78AD2C1A16B28F2611D9140000000_cppui546;
98  };
99 
100  template<std::size_t Version>
101  struct arithmetic_params<edwards_scalar_field<Version>> : public params<edwards_scalar_field<Version>> {
102  private:
104 
105  public:
109 
110  constexpr static const std::size_t s = 0x1F;
111  constexpr static const integral_type t = 0x206AFE4E951CAD89C5C927725C25983BCAA64F_cppui150;
112  constexpr static const integral_type t_minus_1_over_2 =
113  0x10357F274A8E56C4E2E493B92E12CC1DE55327_cppui149;
114  constexpr static const integral_type arithmetic_generator = 0x01;
115  constexpr static const integral_type geometric_generator = 0x02;
116  constexpr static const integral_type multiplicative_generator = 0x13;
117  constexpr static const integral_type root_of_unity =
118  0x74269BCA66AFEC88761200401AECDBB2F967D2689CEE0_cppui179;
119  constexpr static const integral_type nqr = 0x0B;
120  constexpr static const integral_type nqr_to_t =
121  0xDD9F9CD9D463B4BE2359BF98F83964B0CA0C9B9EB2CA9_cppui180;
122  constexpr static const integral_type Rsquared =
123  0x67DC2BC868E4573FB10E45FEF0D1D70518837BA19AB13_cppui179;
124  constexpr static const integral_type Rcubed =
125  0x96567C1A3452F0CC48A73504E02D6B598A5139B464B62_cppui180;
126 
127  constexpr static const integral_type modulus = policy_type::modulus;
128  constexpr static const integral_type group_order =
129  0x81ABF93A5472B62717249DC9709660EF2A993C0000000_cppui181;
130  };
131 
132  constexpr std::size_t const arithmetic_params<edwards_base_field<183>>::s;
133  constexpr std::size_t const arithmetic_params<fp3<edwards_base_field<183>>>::s;
134  constexpr std::size_t const arithmetic_params<edwards_scalar_field<183>>::s;
135 
136  constexpr typename arithmetic_params<edwards_base_field<183>>::integral_type const
138  constexpr typename arithmetic_params<fp3<edwards_base_field<183>>>::extended_integral_type const
140  constexpr typename arithmetic_params<edwards_scalar_field<183>>::integral_type const
142 
143  constexpr typename arithmetic_params<edwards_base_field<183>>::integral_type const
145  constexpr typename arithmetic_params<fp3<edwards_base_field<183>>>::extended_integral_type const
147  constexpr typename arithmetic_params<edwards_scalar_field<183>>::integral_type const
149 
150  constexpr typename arithmetic_params<edwards_base_field<183>>::integral_type const
151  arithmetic_params<edwards_base_field<183>>::arithmetic_generator;
152  constexpr typename arithmetic_params<edwards_scalar_field<183>>::integral_type const
153  arithmetic_params<edwards_scalar_field<183>>::arithmetic_generator;
154 
155  constexpr typename arithmetic_params<edwards_base_field<183>>::integral_type const
156  arithmetic_params<edwards_base_field<183>>::geometric_generator;
157  constexpr typename arithmetic_params<edwards_scalar_field<183>>::integral_type const
158  arithmetic_params<edwards_scalar_field<183>>::geometric_generator;
159 
160  constexpr typename arithmetic_params<edwards_base_field<183>>::integral_type const
161  arithmetic_params<edwards_base_field<183>>::multiplicative_generator;
162  constexpr typename arithmetic_params<edwards_scalar_field<183>>::integral_type const
163  arithmetic_params<edwards_scalar_field<183>>::multiplicative_generator;
164 
165  constexpr typename arithmetic_params<edwards_base_field<183>>::integral_type const
167  constexpr typename arithmetic_params<edwards_scalar_field<183>>::integral_type const
169 
170  constexpr typename arithmetic_params<edwards_base_field<183>>::integral_type const
172  constexpr std::array<typename arithmetic_params<fp3<edwards_base_field<183>>>::integral_type, 3> const
174  constexpr typename arithmetic_params<edwards_scalar_field<183>>::integral_type const
176 
177  constexpr typename arithmetic_params<edwards_base_field<183>>::integral_type const
179  constexpr std::array<typename arithmetic_params<fp3<edwards_base_field<183>>>::integral_type, 3> const
181  constexpr typename arithmetic_params<edwards_scalar_field<183>>::integral_type const
183 
184  constexpr typename arithmetic_params<edwards_base_field<183>>::integral_type const
186  constexpr typename arithmetic_params<edwards_scalar_field<183>>::integral_type const
188 
189  constexpr typename arithmetic_params<edwards_base_field<183>>::integral_type const
191  constexpr typename arithmetic_params<edwards_scalar_field<183>>::integral_type const
193 
194  constexpr typename arithmetic_params<edwards_base_field<183>>::integral_type const
196  constexpr typename arithmetic_params<fp3<edwards_base_field<183>>>::integral_type const
198  constexpr typename arithmetic_params<edwards_scalar_field<183>>::integral_type const
200 
201  constexpr typename arithmetic_params<edwards_base_field<183>>::integral_type const
203  constexpr typename arithmetic_params<fp3<edwards_base_field<183>>>::extended_integral_type const
205  constexpr typename arithmetic_params<edwards_scalar_field<183>>::integral_type const
207 
208  } // namespace fields
209  } // namespace algebra
210  } // namespace crypto3
211 } // namespace nil
212 
213 #endif // CRYPTO3_ALGEBRA_FIELDS_EDWARDS_ARITHMETIC_PARAMS_HPP
Definition: pair.hpp:31
policy_type::integral_type integral_type
Definition: fields/arithmetic_params/edwards.hpp:50
policy_type::modular_backend modular_backend
Definition: fields/arithmetic_params/edwards.hpp:49
policy_type::modular_type modular_type
Definition: fields/arithmetic_params/edwards.hpp:48
policy_type::modular_backend modular_backend
Definition: fields/arithmetic_params/edwards.hpp:107
policy_type::integral_type integral_type
Definition: fields/arithmetic_params/edwards.hpp:108
policy_type::modular_type modular_type
Definition: fields/arithmetic_params/edwards.hpp:106
policy_type::integral_type integral_type
Definition: fields/arithmetic_params/edwards.hpp:83
policy_type::modular_backend modular_backend
Definition: fields/arithmetic_params/edwards.hpp:82
policy_type::extended_integral_type extended_integral_type
Definition: fields/arithmetic_params/edwards.hpp:84
policy_type::modular_type modular_type
Definition: fields/arithmetic_params/edwards.hpp:81
Definition: fields/params.hpp:58
IETF IPsec groups.
Definition: edwards/base_field.hpp:46
IETF IPsec groups.
Definition: edwards/scalar_field.hpp:46
Definition: fields/params.hpp:35
field_type::modular_backend modular_backend
Definition: fields/params.hpp:38
field_type::integral_type integral_type
Definition: fields/params.hpp:42
field_type::modular_type modular_type
Definition: fields/params.hpp:37
field_type::extended_integral_type extended_integral_type
Definition: fields/params.hpp:44