curves/params/multiexp/bls12.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_BLS12_MULTIEXP_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_CURVES_BLS12_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  /************************* BLS12-381 ***********************************/
42 
43  template<>
44  struct multiexp_params<typename bls12<381>::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.99]
48  1,
49  // window 2 is unbeaten in [4.99, 10.99]
50  5,
51  // window 3 is unbeaten in [10.99, 32.29]
52  11,
53  // window 4 is unbeaten in [32.29, 55.23]
54  32,
55  // window 5 is unbeaten in [55.23, 162.03]
56  55,
57  // window 6 is unbeaten in [162.03, 360.15]
58  162,
59  // window 7 is unbeaten in [360.15, 815.44]
60  360,
61  // window 8 is unbeaten in [815.44, 2373.07]
62  815,
63  // window 9 is unbeaten in [2373.07, 6977.75]
64  2373,
65  // window 10 is unbeaten in [6977.75, 7122.23]
66  6978,
67  // window 11 is unbeaten in [7122.23, 57818.46]
68  7122,
69  // window 12 is never the best
70  0,
71  // window 13 is unbeaten in [57818.46, 169679.14]
72  57818,
73  // window 14 is never the best
74  0,
75  // window 15 is unbeaten in [169679.14, 439758.91]
76  169679,
77  // window 16 is unbeaten in [439758.91, 936073.41]
78  439759,
79  // window 17 is unbeaten in [936073.41, 4666554.74]
80  936073,
81  // window 18 is never the best
82  0,
83  // window 19 is unbeaten in [4666554.74, 7580404.42]
84  4666555,
85  // window 20 is unbeaten in [7580404.42, 34552892.20]
86  7580404,
87  // window 21 is never the best
88  0,
89  // window 22 is unbeaten in [34552892.20, inf]
90  34552892};
91  };
92 
93  template<>
94  struct multiexp_params<typename bls12<381>::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, 5.10]
98  1,
99  // window 2 is unbeaten in [5.10, 10.43]
100  5,
101  // window 3 is unbeaten in [10.43, 25.28]
102  10,
103  // window 4 is unbeaten in [25.28, 59.00]
104  25,
105  // window 5 is unbeaten in [59.00, 154.03]
106  59,
107  // window 6 is unbeaten in [154.03, 334.25]
108  154,
109  // window 7 is unbeaten in [334.25, 742.58]
110  334,
111  // window 8 is unbeaten in [742.58, 2034.40]
112  743,
113  // window 9 is unbeaten in [2034.40, 4987.56]
114  2034,
115  // window 10 is unbeaten in [4987.56, 8888.27]
116  4988,
117  // window 11 is unbeaten in [8888.27, 26271.13]
118  8888,
119  // window 12 is unbeaten in [26271.13, 39768.20]
120  26271,
121  // window 13 is unbeaten in [39768.20, 106275.75]
122  39768,
123  // window 14 is unbeaten in [106275.75, 141703.40]
124  106276,
125  // window 15 is unbeaten in [141703.40, 462422.97]
126  141703,
127  // window 16 is unbeaten in [462422.97, 926871.84]
128  462423,
129  // window 17 is unbeaten in [926871.84, 4873049.17]
130  926872,
131  // window 18 is never the best
132  0,
133  // window 19 is unbeaten in [4873049.17, 5706707.88]
134  4873049,
135  // window 20 is unbeaten in [5706707.88, 31673814.95]
136  5706708,
137  // window 21 is never the best
138  0,
139  // window 22 is unbeaten in [31673814.95, inf]
140  31673815};
141  };
142 
143  /************************* BLS12-377 ***********************************/
144 
145  template<>
146  struct multiexp_params<typename bls12<377>::g1_type<>> {
147 
148  constexpr static const std::array<std::size_t, 22> fixed_base_exp_window_table = {
149  // window 1 is unbeaten in [-inf, 4.99]
150  1,
151  // window 2 is unbeaten in [4.99, 10.99]
152  5,
153  // window 3 is unbeaten in [10.99, 32.29]
154  11,
155  // window 4 is unbeaten in [32.29, 55.23]
156  32,
157  // window 5 is unbeaten in [55.23, 162.03]
158  55,
159  // window 6 is unbeaten in [162.03, 360.15]
160  162,
161  // window 7 is unbeaten in [360.15, 815.44]
162  360,
163  // window 8 is unbeaten in [815.44, 2373.07]
164  815,
165  // window 9 is unbeaten in [2373.07, 6977.75]
166  2373,
167  // window 10 is unbeaten in [6977.75, 7122.23]
168  6978,
169  // window 11 is unbeaten in [7122.23, 57818.46]
170  7122,
171  // window 12 is never the best
172  0,
173  // window 13 is unbeaten in [57818.46, 169679.14]
174  57818,
175  // window 14 is never the best
176  0,
177  // window 15 is unbeaten in [169679.14, 439758.91]
178  169679,
179  // window 16 is unbeaten in [439758.91, 936073.41]
180  439759,
181  // window 17 is unbeaten in [936073.41, 4666554.74]
182  936073,
183  // window 18 is never the best
184  0,
185  // window 19 is unbeaten in [4666554.74, 7580404.42]
186  4666555,
187  // window 20 is unbeaten in [7580404.42, 34552892.20]
188  7580404,
189  // window 21 is never the best
190  0,
191  // window 22 is unbeaten in [34552892.20, inf]
192  34552892};
193  };
194 
195  template<>
196  struct multiexp_params<typename bls12<377>::g2_type<>> {
197 
198  constexpr static const std::array<std::size_t, 22> fixed_base_exp_window_table = {
199  // window 1 is unbeaten in [-inf, 5.10]
200  1,
201  // window 2 is unbeaten in [5.10, 10.43]
202  5,
203  // window 3 is unbeaten in [10.43, 25.28]
204  10,
205  // window 4 is unbeaten in [25.28, 59.00]
206  25,
207  // window 5 is unbeaten in [59.00, 154.03]
208  59,
209  // window 6 is unbeaten in [154.03, 334.25]
210  154,
211  // window 7 is unbeaten in [334.25, 742.58]
212  334,
213  // window 8 is unbeaten in [742.58, 2034.40]
214  743,
215  // window 9 is unbeaten in [2034.40, 4987.56]
216  2034,
217  // window 10 is unbeaten in [4987.56, 8888.27]
218  4988,
219  // window 11 is unbeaten in [8888.27, 26271.13]
220  8888,
221  // window 12 is unbeaten in [26271.13, 39768.20]
222  26271,
223  // window 13 is unbeaten in [39768.20, 106275.75]
224  39768,
225  // window 14 is unbeaten in [106275.75, 141703.40]
226  106276,
227  // window 15 is unbeaten in [141703.40, 462422.97]
228  141703,
229  // window 16 is unbeaten in [462422.97, 926871.84]
230  462423,
231  // window 17 is unbeaten in [926871.84, 4873049.17]
232  926872,
233  // window 18 is never the best
234  0,
235  // window 19 is unbeaten in [4873049.17, 5706707.88]
236  4873049,
237  // window 20 is unbeaten in [5706707.88, 31673814.95]
238  5706708,
239  // window 21 is never the best
240  0,
241  // window 22 is unbeaten in [31673814.95, inf]
242  31673815};
243  };
244 
245  /************************* BLS12-381 definitions ***********************************/
246 
247  constexpr std::array<std::size_t, 22> const
248  multiexp_params<typename bls12<381>::g1_type<>>::fixed_base_exp_window_table;
249  constexpr std::array<std::size_t, 22> const
250  multiexp_params<typename bls12<381>::g2_type<>>::fixed_base_exp_window_table;
251 
252  /************************* BLS12-377 definitions ***********************************/
253 
254  constexpr std::array<std::size_t, 22> const
255  multiexp_params<typename bls12<377>::g1_type<>>::fixed_base_exp_window_table;
256  constexpr std::array<std::size_t, 22> const
257  multiexp_params<typename bls12<377>::g2_type<>>::fixed_base_exp_window_table;
258 
259  } // namespace curves
260  } // namespace algebra
261  } // namespace crypto3
262 } // namespace nil
263 
264 #endif // CRYPTO3_ALGEBRA_CURVES_BLS12_MULTIEXP_PARAMS_HPP
A struct representing a BLS12-381 and BLS12-377 curve.
Definition: curves/bls12.hpp:49
Definition: pair.hpp:31
Definition: curves/params/multiexp/alt_bn128.hpp:39