curves/params/multiexp/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_CURVES_EDWARDS_MULTIEXP_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_CURVES_EDWARDS_MULTIEXP_PARAMS_HPP
28 
30 
32 
33 namespace nil {
34  namespace crypto3 {
35  namespace algebra {
36  namespace curves {
37 
38  template<typename GroupType>
39  struct multiexp_params;
40 
41  /************************* EDWARDS-183 ***********************************/
42 
43  template<>
44  struct multiexp_params<typename edwards<183>::g1_type<>> {
45 
46  constexpr static const std::array<std::size_t, 22> fixed_base_exp_window_table = {
47  // window 1 is unbeaten in [-inf, 4.10]
48  1,
49  // window 2 is unbeaten in [4.10, 9.69]
50  4,
51  // window 3 is unbeaten in [9.69, 25.21]
52  10,
53  // window 4 is unbeaten in [25.21, 60.00]
54  25,
55  // window 5 is unbeaten in [60.00, 149.33]
56  60,
57  // window 6 is unbeaten in [149.33, 369.61]
58  149,
59  // window 7 is unbeaten in [369.61, 849.07]
60  370,
61  // window 8 is unbeaten in [849.07, 1764.94]
62  849,
63  // window 9 is unbeaten in [1764.94, 4429.59]
64  1765,
65  // window 10 is unbeaten in [4429.59, 13388.78]
66  4430,
67  // window 11 is unbeaten in [13388.78, 15368.00]
68  13389,
69  // window 12 is unbeaten in [15368.00, 74912.07]
70  15368,
71  // window 13 is unbeaten in [74912.07, 438107.20]
72  74912,
73  // window 14 is never the best
74  0,
75  // window 15 is unbeaten in [438107.20, 1045626.18]
76  438107,
77  // window 16 is never the best
78  0,
79  // window 17 is unbeaten in [1045626.18, 1577434.48]
80  1045626,
81  // window 18 is unbeaten in [1577434.48, 17350594.23]
82  1577434,
83  // window 19 is never the best
84  0,
85  // window 20 is never the best
86  0,
87  // window 21 is unbeaten in [17350594.23, inf]
88  17350594,
89  // window 22 is never the best
90  0};
91  };
92 
93  template<>
94  struct multiexp_params<typename edwards<183>::g2_type<>> {
95 
96  constexpr static const std::array<std::size_t, 22> fixed_base_exp_window_table = {
97  // window 1 is unbeaten in [-inf, 4.74]
98  1,
99  // window 2 is unbeaten in [4.74, 10.67]
100  5,
101  // window 3 is unbeaten in [10.67, 25.53]
102  11,
103  // window 4 is unbeaten in [25.53, 60.67]
104  26,
105  // window 5 is unbeaten in [60.67, 145.77]
106  61,
107  // window 6 is unbeaten in [145.77, 356.76]
108  146,
109  // window 7 is unbeaten in [356.76, 823.08]
110  357,
111  // window 8 is unbeaten in [823.08, 1589.45]
112  823,
113  // window 9 is unbeaten in [1589.45, 4135.70]
114  1589,
115  // window 10 is unbeaten in [4135.70, 14297.74]
116  4136,
117  // window 11 is unbeaten in [14297.74, 16744.85]
118  14298,
119  // window 12 is unbeaten in [16744.85, 51768.98]
120  16745,
121  // window 13 is unbeaten in [51768.98, 99811.01]
122  51769,
123  // window 14 is unbeaten in [99811.01, 193306.72]
124  99811,
125  // window 15 is unbeaten in [193306.72, 907184.68]
126  193307,
127  // window 16 is never the best
128  0,
129  // window 17 is unbeaten in [907184.68, 1389682.59]
130  907185,
131  // window 18 is unbeaten in [1389682.59, 6752695.74]
132  1389683,
133  // window 19 is never the best
134  0,
135  // window 20 is unbeaten in [6752695.74, 193642894.51]
136  6752696,
137  // window 21 is unbeaten in [193642894.51, 226760202.29]
138  193642895,
139  // window 22 is unbeaten in [226760202.29, inf]
140  226760202};
141  };
142 
143  /************************* EDWARDS-183 definitions ***********************************/
144 
145  constexpr std::array<std::size_t, 22> const
146  multiexp_params<typename edwards<183>::g1_type<>>::fixed_base_exp_window_table;
147  constexpr std::array<std::size_t, 22> const
148  multiexp_params<typename edwards<183>::g2_type<>>::fixed_base_exp_window_table;
149 
150  } // namespace curves
151  } // namespace algebra
152  } // namespace crypto3
153 } // namespace nil
154 
155 #endif // CRYPTO3_ALGEBRA_CURVES_EDWARDS_MULTIEXP_PARAMS_HPP
Definition: pair.hpp:31
A struct representing a Edwards curve, providing 128 bits of security.
Definition: curves/edwards.hpp:51
Definition: curves/params/multiexp/alt_bn128.hpp:39