curves/params/multiexp/alt_bn128.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_ALT_BN128_MULTIEXP_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_CURVES_ALT_BN128_MULTIEXP_PARAMS_HPP
28 
30 
32 
33 namespace nil {
34  namespace crypto3 {
35  namespace algebra {
36  namespace curves {
37 
38  template<typename GroupType>
40 
41  /************************* ALT_BN128-254 ***********************************/
42 
43  template<>
44  struct multiexp_params<typename alt_bn128<254>::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 alt_bn128<254>::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  /************************* ALT_BN128-254 definitions ***********************************/
144 
145  constexpr std::array<std::size_t, 22> const
146  multiexp_params<typename alt_bn128<254>::g1_type<>>::fixed_base_exp_window_table;
147  constexpr std::array<std::size_t, 22> const
148  multiexp_params<typename alt_bn128<254>::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_ALT_BN128_MULTIEXP_PARAMS_HPP
A struct representing a Barreto-Naehrig curve.
Definition: curves/alt_bn128.hpp:48
Definition: pair.hpp:31
Definition: curves/params/multiexp/alt_bn128.hpp:39