algebra/include/nil/crypto3/algebra/curves/params/multiexp/mnt4.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_MNT4_MULTIEXP_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_CURVES_MNT4_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  /************************* MNT4-298 ***********************************/
42 
43  template<>
44  struct multiexp_params<typename mnt4<298>::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, 5.09]
48  1,
49  // window 2 is unbeaten in [5.09, 9.64]
50  5,
51  // window 3 is unbeaten in [9.64, 24.79]
52  10,
53  // window 4 is unbeaten in [24.79, 60.29]
54  25,
55  // window 5 is unbeaten in [60.29, 144.37]
56  60,
57  // window 6 is unbeaten in [144.37, 344.90]
58  144,
59  // window 7 is unbeaten in [344.90, 855.00]
60  345,
61  // window 8 is unbeaten in [855.00, 1804.62]
62  855,
63  // window 9 is unbeaten in [1804.62, 3912.30]
64  1805,
65  // window 10 is unbeaten in [3912.30, 11264.50]
66  3912,
67  // window 11 is unbeaten in [11264.50, 27897.51]
68  11265,
69  // window 12 is unbeaten in [27897.51, 57596.79]
70  27898,
71  // window 13 is unbeaten in [57596.79, 145298.71]
72  57597,
73  // window 14 is unbeaten in [145298.71, 157204.59]
74  145299,
75  // window 15 is unbeaten in [157204.59, 601600.62]
76  157205,
77  // window 16 is unbeaten in [601600.62, 1107377.25]
78  601601,
79  // window 17 is unbeaten in [1107377.25, 1789646.95]
80  1107377,
81  // window 18 is unbeaten in [1789646.95, 4392626.92]
82  1789647,
83  // window 19 is unbeaten in [4392626.92, 8221210.60]
84  4392627,
85  // window 20 is unbeaten in [8221210.60, 42363731.19]
86  8221211,
87  // window 21 is never the best
88  0,
89  // window 22 is unbeaten in [42363731.19, inf]
90  42363731};
91  };
92 
93  template<>
94  struct multiexp_params<typename mnt4<298>::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.17]
98  1,
99  // window 2 is unbeaten in [4.17, 10.12]
100  4,
101  // window 3 is unbeaten in [10.12, 24.65]
102  10,
103  // window 4 is unbeaten in [24.65, 60.03]
104  25,
105  // window 5 is unbeaten in [60.03, 143.16]
106  60,
107  // window 6 is unbeaten in [143.16, 344.73]
108  143,
109  // window 7 is unbeaten in [344.73, 821.24]
110  345,
111  // window 8 is unbeaten in [821.24, 1793.92]
112  821,
113  // window 9 is unbeaten in [1793.92, 3919.59]
114  1794,
115  // window 10 is unbeaten in [3919.59, 11301.46]
116  3920,
117  // window 11 is unbeaten in [11301.46, 18960.09]
118  11301,
119  // window 12 is unbeaten in [18960.09, 44198.62]
120  18960,
121  // window 13 is unbeaten in [44198.62, 150799.57]
122  44199,
123  // window 14 is never the best
124  0,
125  // window 15 is unbeaten in [150799.57, 548694.81]
126  150800,
127  // window 16 is unbeaten in [548694.81, 1051769.08]
128  548695,
129  // window 17 is unbeaten in [1051769.08, 2023925.59]
130  1051769,
131  // window 18 is unbeaten in [2023925.59, 3787108.68]
132  2023926,
133  // window 19 is unbeaten in [3787108.68, 7107480.30]
134  3787109,
135  // window 20 is unbeaten in [7107480.30, 38760027.14]
136  7107480,
137  // window 21 is never the best
138  0,
139  // window 22 is unbeaten in [38760027.14, inf]
140  38760027};
141  };
142 
143  /************************* MNT4-298 definitions ***********************************/
144 
145  constexpr std::array<std::size_t, 22> const
146  multiexp_params<typename mnt4<298>::g1_type<>>::fixed_base_exp_window_table;
147  constexpr std::array<std::size_t, 22> const
148  multiexp_params<typename mnt4<298>::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_MNT4_MULTIEXP_PARAMS_HPP
Definition: pair.hpp:31
A struct representing a mnt4 curve.
Definition: algebra/include/nil/crypto3/algebra/curves/mnt4.hpp:46
Definition: curves/params/multiexp/alt_bn128.hpp:39