detail/extension_params/mnt6/fp3.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_FIELDS_MNT6_FP3_EXTENSION_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_FIELDS_MNT6_FP3_EXTENSION_PARAMS_HPP
28 
31 
33 
34 namespace nil {
35  namespace crypto3 {
36  namespace algebra {
37  namespace fields {
38 
39  template<typename BaseField>
40  struct fp3;
41  namespace detail {
42 
43  template<typename BaseField>
44  struct fp3_extension_params;
45 
46  /************************* MNT6 ***********************************/
47 
48  template<std::size_t Version>
49  class fp3_extension_params<fields::mnt6_base_field<Version>>
50  : public params<fields::mnt6_base_field<Version>> {
51 
54 
55  public:
58 
59  constexpr static const integral_type modulus = policy_type::modulus;
60 
62  typedef typename non_residue_field_type::value_type non_residue_type;
64  typedef typename underlying_field_type::value_type underlying_type;
65 
66  constexpr static const std::size_t s = 0x22;
67  constexpr static const extended_integral_type t =
68  0xD0F1EB0C5D321E87BF885ACDEBEDB4C0D6B30E63AB6E7BF6417A7990679AA640A7D58FB90CC708D572D32DFD6443366D2F92F48FF1A02FDB0CC11573BAB71F8E5E05B07DEA208A7E11F3E61C9968CC65F379EFCEF9472C7FC6DEE40194CA1DF9F801DC0D24656EACC72677B_cppui860;
69  constexpr static const extended_integral_type t_minus_1_over_2 =
70  0x6878F5862E990F43DFC42D66F5F6DA606B598731D5B73DFB20BD3CC833CD532053EAC7DC8663846AB96996FEB2219B3697C97A47F8D017ED86608AB9DD5B8FC72F02D83EF510453F08F9F30E4CB46632F9BCF7E77CA3963FE36F7200CA650EFCFC00EE069232B75663933BD_cppui859;
71  constexpr static const std::array<integral_type, 3> nqr = {0x05, 0x00, 0x00};
72  constexpr static const std::array<integral_type, 3> nqr_to_t = {
73  0x1366271F76AB41CEEEE8C1E5E972F3CEC14A25F18B3F4B93642FAD4972356D977470E0FA674_cppui297,
74  0x00, 0x00};
75 
76  constexpr static const extended_integral_type group_order =
77  0x1A1E3D618BA643D0F7F10B59BD7DB6981AD661CC756DCF7EC82F4F320CF354C814FAB1F72198E11AAE5A65BFAC8866CDA5F25E91FE3405FB619822AE7756E3F1CBC0B60FBD44114FC23E7CC3932D198CBE6F3DF9DF28E58FF8DBDC80329943BF3F003B81A48CADD598E4CEF600000000_cppui893;
78 
79  /*constexpr static const std::array<non_residue_type, 3> Frobenius_coeffs_c1 =
80  {non_residue_type(0x01),
81  non_residue_type(0x3B48E50A1662E26F0E834E15FAF68204A9845655F46B277A6D05B75068AD3F6801655344BEC_cppui298),
82  non_residue_type(0x8696C330D743F33B572CEF4DF62CE7ECB178EE24E48D1A53736E86448E74CB48DAACBB414_cppui292)};
83 
84  constexpr static const std::array<non_residue_type, 3> Frobenius_coeffs_c2 =
85  {non_residue_type(0x01),
86  non_residue_type(0x8696C330D743F33B572CEF4DF62CE7ECB178EE24E48D1A53736E86448E74CB48DAACBB414_cppui292),
87  non_residue_type(0x3B48E50A1662E26F0E834E15FAF68204A9845655F46B277A6D05B75068AD3F6801655344BEC_cppui298)};*/
88 
89  constexpr static const std::array<integral_type, 3> Frobenius_coeffs_c1 = {
90  0x01,
91  0x3B48E50A1662E26F0E834E15FAF68204A9845655F46B277A6D05B75068AD3F6801655344BEC_cppui298,
92  0x8696C330D743F33B572CEF4DF62CE7ECB178EE24E48D1A53736E86448E74CB48DAACBB414_cppui292};
93 
94  constexpr static const std::array<integral_type, 3> Frobenius_coeffs_c2 = {
95  0x01, 0x8696C330D743F33B572CEF4DF62CE7ECB178EE24E48D1A53736E86448E74CB48DAACBB414_cppui292,
96  0x3B48E50A1662E26F0E834E15FAF68204A9845655F46B277A6D05B75068AD3F6801655344BEC_cppui298};
97 
98  constexpr static const non_residue_type non_residue = non_residue_type(0x05);
99  };
100 
101  template<std::size_t Version>
102  constexpr typename fp3_extension_params<mnt6_base_field<Version>>::non_residue_type const
104 
105  template<std::size_t Version>
106  constexpr typename std::size_t const fp3_extension_params<mnt6_base_field<Version>>::s;
107 
108  template<std::size_t Version>
109  constexpr typename fp3_extension_params<mnt6_base_field<Version>>::extended_integral_type const
111 
112  template<std::size_t Version>
113  constexpr typename fp3_extension_params<mnt6_base_field<Version>>::extended_integral_type const
115 
116  template<std::size_t Version>
117  constexpr std::array<typename fp3_extension_params<mnt6_base_field<Version>>::integral_type,
119 
120  template<std::size_t Version>
121  constexpr std::array<typename fp3_extension_params<mnt6_base_field<Version>>::integral_type,
123 
124  template<std::size_t Version>
125  constexpr typename fp3_extension_params<mnt6_base_field<Version>>::extended_integral_type const
127 
128  template<std::size_t Version>
129  constexpr typename fp3_extension_params<mnt6_base_field<Version>>::integral_type const
131 
132  template<std::size_t Version>
133  constexpr std::array<typename fp3_extension_params<mnt6_base_field<Version>>::integral_type,
134  3> const fp3_extension_params<mnt6_base_field<Version>>::Frobenius_coeffs_c1;
135 
136  template<std::size_t Version>
137  constexpr std::array<typename fp3_extension_params<mnt6_base_field<Version>>::integral_type,
138  3> const fp3_extension_params<mnt6_base_field<Version>>::Frobenius_coeffs_c2;
139 
140  } // namespace detail
141  } // namespace fields
142  } // namespace algebra
143  } // namespace crypto3
144 } // namespace nil
145 
146 #endif // CRYPTO3_ALGEBRA_FIELDS_MNT6_FP3_EXTENSION_PARAMS_HPP
base_field_type non_residue_field_type
Definition: detail/extension_params/mnt6/fp3.hpp:61
non_residue_field_type::value_type non_residue_type
Definition: detail/extension_params/mnt6/fp3.hpp:62
underlying_field_type::value_type underlying_type
Definition: detail/extension_params/mnt6/fp3.hpp:64
policy_type::integral_type integral_type
Definition: detail/extension_params/mnt6/fp3.hpp:56
policy_type::extended_integral_type extended_integral_type
Definition: detail/extension_params/mnt6/fp3.hpp:57
base_field_type underlying_field_type
Definition: detail/extension_params/mnt6/fp3.hpp:63
Definition: pair.hpp:31
Definition: detail/extension_params/edwards/fp3.hpp:44
IETF IPsec groups.
Definition: mnt6/base_field.hpp:46
Definition: fields/params.hpp:35
field_type::integral_type integral_type
Definition: fields/params.hpp:42
field_type::extended_integral_type extended_integral_type
Definition: fields/params.hpp:44