algebra/include/nil/crypto3/algebra/curves/params/multiexp/mnt6.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_MNT6_MULTIEXP_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_CURVES_MNT6_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  /************************* MNT6-298 ***********************************/
42 
43  template<>
44  struct multiexp_params<typename mnt6<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, 3.96]
48  1,
49  // window 2 is unbeaten in [3.96, 9.67]
50  4,
51  // window 3 is unbeaten in [9.67, 25.13]
52  10,
53  // window 4 is unbeaten in [25.13, 60.31]
54  25,
55  // window 5 is unbeaten in [60.31, 146.07]
56  60,
57  // window 6 is unbeaten in [146.07, 350.09]
58  146,
59  // window 7 is unbeaten in [350.09, 844.54]
60  350,
61  // window 8 is unbeaten in [844.54, 1839.64]
62  845,
63  // window 9 is unbeaten in [1839.64, 3904.26]
64  1840,
65  // window 10 is unbeaten in [3904.26, 11309.42]
66  3904,
67  // window 11 is unbeaten in [11309.42, 24015.57]
68  11309,
69  // window 12 is unbeaten in [24015.57, 72288.57]
70  24016,
71  // window 13 is unbeaten in [72288.57, 138413.22]
72  72289,
73  // window 14 is unbeaten in [138413.22, 156390.30]
74  138413,
75  // window 15 is unbeaten in [156390.30, 562560.50]
76  156390,
77  // window 16 is unbeaten in [562560.50, 1036742.02]
78  562560,
79  // window 17 is unbeaten in [1036742.02, 2053818.86]
80  1036742,
81  // window 18 is unbeaten in [2053818.86, 4370223.95]
82  2053819,
83  // window 19 is unbeaten in [4370223.95, 8215703.81]
84  4370224,
85  // window 20 is unbeaten in [8215703.81, 42682375.43]
86  8215704,
87  // window 21 is never the best
88  0,
89  // window 22 is unbeaten in [42682375.43, inf]
90  42682375};
91  };
92 
93  template<>
94  struct multiexp_params<typename mnt6<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.25]
98  1,
99  // window 2 is unbeaten in [4.25, 10.22]
100  4,
101  // window 3 is unbeaten in [10.22, 24.85]
102  10,
103  // window 4 is unbeaten in [24.85, 60.06]
104  25,
105  // window 5 is unbeaten in [60.06, 143.61]
106  60,
107  // window 6 is unbeaten in [143.61, 345.66]
108  144,
109  // window 7 is unbeaten in [345.66, 818.56]
110  346,
111  // window 8 is unbeaten in [818.56, 1782.06]
112  819,
113  // window 9 is unbeaten in [1782.06, 4002.45]
114  1782,
115  // window 10 is unbeaten in [4002.45, 10870.18]
116  4002,
117  // window 11 is unbeaten in [10870.18, 18022.51]
118  10870,
119  // window 12 is unbeaten in [18022.51, 43160.74]
120  18023,
121  // window 13 is unbeaten in [43160.74, 149743.32]
122  43161,
123  // window 14 is never the best
124  0,
125  // window 15 is unbeaten in [149743.32, 551844.13]
126  149743,
127  // window 16 is unbeaten in [551844.13, 1041827.91]
128  551844,
129  // window 17 is unbeaten in [1041827.91, 1977371.53]
130  1041828,
131  // window 18 is unbeaten in [1977371.53, 3703619.51]
132  1977372,
133  // window 19 is unbeaten in [3703619.51, 7057236.87]
134  3703620,
135  // window 20 is unbeaten in [7057236.87, 38554491.67]
136  7057237,
137  // window 21 is never the best
138  0,
139  // window 22 is unbeaten in [38554491.67, inf]
140  38554492};
141  };
142 
143  /************************* MNT6-298 definitions ***********************************/
144 
145  constexpr std::array<std::size_t, 22> const
146  multiexp_params<typename mnt6<298>::g1_type<>>::fixed_base_exp_window_table;
147  constexpr std::array<std::size_t, 22> const
148  multiexp_params<typename mnt6<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_MNT6_MULTIEXP_PARAMS_HPP
Definition: pair.hpp:31
A struct representing a mnt6 curve.
Definition: algebra/include/nil/crypto3/algebra/curves/mnt6.hpp:46
Definition: curves/params/multiexp/alt_bn128.hpp:39