edwards_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_EDWARDS_183_EDWARDS_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_CURVES_EDWARDS_183_EDWARDS_PARAMS_HPP
28 
31 
33 
34 namespace nil {
35  namespace crypto3 {
36  namespace algebra {
37  namespace curves {
38  namespace detail {
39 
40  template<>
41  struct edwards_params<183, forms::edwards> {
42 
45 
46  constexpr static const typename edwards_types<183>::integral_type c =
47  typename edwards_types<183>::integral_type(0x01);
48  constexpr static const typename edwards_types<183>::integral_type d =
50  0x64536D55979879327CF1306BB5A6277D254EF9776CE70_cppui179);
51  };
52 
53  template<>
54  struct edwards_g1_params<183, forms::edwards> : public edwards_params<183, forms::edwards> {
55 
57 
58  template<typename Coordinates>
60 
61  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
62  field_type::value_type::zero(), field_type::value_type::one()};
63 
64  private:
65  constexpr static const std::array<typename field_type::value_type, 3> inverted_one_fill = {
66  typename field_type::value_type(0x32d83d8aaa0c500f57b15fda90b1ad111067f812c7dd27_cppui182),
67  typename field_type::value_type(0x26c5df4587aa6a5d345efc9f2d47f8b1656517ef618f7a_cppui182),
68  typename field_type::value_type(0x3c6395f7eeafc1d930f0234a46e4a4806b953f0c3374ac_cppui182)};
69 
70  public:
71  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
72  inverted_one_fill[2] * inverted_one_fill[0].inversed(),
73  inverted_one_fill[2] * inverted_one_fill[1].inversed()};
74  };
75 
76  template<>
77  struct edwards_g2_params<183, forms::edwards> : public edwards_params<183, forms::edwards> {
78 
80 
81  template<typename Coordinates>
83 
84  constexpr static const typename field_type::value_type twist =
85  typename field_type::value_type(0x00, 0x01, 0x00);
86 
87  private:
88  constexpr static const typename field_type::value_type::underlying_type g1_c =
89  typename field_type::value_type::underlying_type(c);
90  constexpr static const typename field_type::value_type::underlying_type g1_d =
91  typename field_type::value_type::underlying_type(d);
92 
93  public:
94  constexpr static const typename field_type::value_type c = g1_c * twist;
95  constexpr static const typename field_type::value_type d = g1_d * twist;
96 
97  constexpr static const std::array<typename field_type::value_type, 2> zero_fill = {
98  field_type::value_type::zero(), field_type::value_type::one()};
99 
100  private:
101  constexpr static const std::array<typename field_type::value_type, 3> inverted_one_fill = {
102  typename field_type::value_type(0x3CE954C85AD30F53B1BB4C4F87029780F4141927FEB19_cppui178,
103  0x2214EB976DE3A4D9DF9C8D5F7AEDFEC337E03A20B32FFF_cppui182,
104  0x249774AB0EDC7FE2E665DDBFE08594F3071E0B3AC994C3_cppui182),
105  typename field_type::value_type(0x2F501F9482C0D0D6E80AC55A79FD4D4594CAF187952660_cppui182,
106  0x37BF8F1B1CDA11A81E8BB8F41B5FF462C9A13DC7DE1578_cppui182,
107  0x2962F0DA0C7928B2CFBBACE3D0354652B6922A764C12D8_cppui182),
108  typename field_type::value_type(0x3b6ad5c355d8b231b16e97b5c6f635357993efdc248101_cppui182,
109  0x2e8b3daf5fa18f9d9c6fa2ca0603fd0c9b09eeece8fd0d_cppui182,
110  0x3c3baf061e62a04a4e9d1db335b8779c70384ae2933a73_cppui182)};
111 
112  public:
113  constexpr static const std::array<typename field_type::value_type, 2> one_fill = {
114  inverted_one_fill[2] * inverted_one_fill[0].inversed(),
115  inverted_one_fill[2] * inverted_one_fill[1].inversed()};
116  };
117 
120 
121  constexpr std::array<typename edwards_g1_params<183, forms::edwards>::field_type::value_type,
123  constexpr std::array<typename edwards_g1_params<183, forms::edwards>::field_type::value_type,
125 
126  constexpr std::array<typename edwards_g2_params<183, forms::edwards>::field_type::value_type,
128  constexpr std::array<typename edwards_g2_params<183, forms::edwards>::field_type::value_type,
130 
131  } // namespace detail
132  } // namespace curves
133  } // namespace algebra
134  } // namespace crypto3
135 } // namespace nil
136 
137 #endif // CRYPTO3_ALGEBRA_CURVES_EDWARDS_183_EDWARDS_PARAMS_HPP
edwards_base_field< Version > edwards
Definition: edwards/base_field.hpp:86
Definition: pair.hpp:31
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: edwards_params.hpp:61
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: edwards_params.hpp:71
edwards_types< 183 >::g1_type< forms::edwards, Coordinates > group_type
Definition: edwards_params.hpp:59
typename edwards_types< 183 >::g1_field_type field_type
Definition: edwards_params.hpp:56
Definition: curves/detail/edwards/types.hpp:51
typename edwards_types< 183 >::g2_field_type field_type
Definition: edwards_params.hpp:79
constexpr static const std::array< typename field_type::value_type, 2 > zero_fill
Definition: edwards_params.hpp:97
edwards_types< 183 >::g2_type< forms::edwards, Coordinates > group_type
Definition: edwards_params.hpp:82
constexpr static const std::array< typename field_type::value_type, 2 > one_fill
Definition: edwards_params.hpp:113
Definition: curves/detail/edwards/types.hpp:54
typename edwards_types< 183 >::scalar_field_type scalar_field_type
Definition: edwards_params.hpp:44
typename edwards_types< 183 >::base_field_type base_field_type
Definition: edwards_params.hpp:43
constexpr static const edwards_types< 183 >::integral_type c
Definition: edwards_params.hpp:46
constexpr static const edwards_types< 183 >::integral_type d
Definition: edwards_params.hpp:48
Definition: curves/detail/edwards/types.hpp:48
A struct representing details about base and scalar fields.
Definition: curves/detail/edwards/types.hpp:61
typename base_field_type::integral_type integral_type
Definition: curves/detail/edwards/types.hpp:69
A struct representing a Edwards curve, providing 128 bits of security.
Definition: curves/edwards.hpp:51
Definition: forms.hpp:34