detail/extension_params/mnt4/fp2.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_MNT4_FP2_EXTENSION_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_FIELDS_MNT4_FP2_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 fp2;
41  namespace detail {
42 
43  template<typename BaseField>
44  struct fp2_extension_params;
45 
46  /************************* MNT4 ***********************************/
47 
48  template<std::size_t Version>
49  class fp2_extension_params<fields::mnt4_base_field<Version>>
50  : public params<fields::mnt4_base_field<Version>> {
51 
54 
55  public:
57 
60 
61  constexpr static const integral_type modulus = policy_type::modulus;
62 
64  typedef typename non_residue_field_type::value_type non_residue_type;
66  typedef typename underlying_field_type::value_type underlying_type;
67 
68  constexpr static const std::size_t s = 0x12;
69  constexpr static const extended_integral_type t =
70  0x37E52CE842B39321A34D7BA62E2C735153C68D35F7A312CDB18451030CB297F3B772167A8487033D5772A0EF6BEA9BCA60190FFE1CDB642F88A0FF2EFF7A6A3A80FD00203385638B3_cppui578;
71  constexpr static const extended_integral_type t_minus_1_over_2 =
72  0x1BF296742159C990D1A6BDD3171639A8A9E3469AFBD18966D8C2288186594BF9DBB90B3D4243819EABB95077B5F54DE5300C87FF0E6DB217C4507F977FBD351D407E801019C2B1C59_cppui577;
73  constexpr static const std::array<integral_type, 2> nqr = {0x08, 0x01};
74  constexpr static const std::array<integral_type, 2> nqr_to_t = {
75  0x00,
76  0x3B1F45391287A9CB585B8E5504C24BF1EC2010553885078C85899ACD708205080134A9BE6A_cppui294};
77 
78  constexpr static const extended_integral_type group_order =
79  0x6FCA59D085672643469AF74C5C58E6A2A78D1A6BEF46259B6308A20619652FE76EE42CF5090E067AAEE541DED7D53794C0321FFC39B6C85F1141FE5DFEF4D47501FA0040670AC71660000_cppui595;
80 
81  /*constexpr static const std::array<non_residue_type, 2> Frobenius_coeffs_c1 =
82  {non_residue_type(0x01),
83  non_residue_type(0x3BCF7BCD473A266249DA7B0548ECAEEC9635D1330EA41A9E35E51200E12C90CD65A71660000_cppui298)};*/
84 
85  constexpr static const std::array<integral_type, 2> Frobenius_coeffs_c1 = {
86  0x01,
87  0x3BCF7BCD473A266249DA7B0548ECAEEC9635D1330EA41A9E35E51200E12C90CD65A71660000_cppui298};
88 
89  constexpr static const non_residue_type non_residue = non_residue_type(0x11);
90  };
91 
92  template<std::size_t Version>
93  constexpr typename fp2_extension_params<mnt4_base_field<Version>>::non_residue_type const
95 
96  template<std::size_t Version>
97  constexpr typename std::size_t const fp2_extension_params<mnt4_base_field<Version>>::s;
98 
99  template<std::size_t Version>
100  constexpr typename fp2_extension_params<mnt4_base_field<Version>>::extended_integral_type const
102 
103  template<std::size_t Version>
104  constexpr typename fp2_extension_params<mnt4_base_field<Version>>::extended_integral_type const
106 
107  template<std::size_t Version>
108  constexpr std::array<typename fp2_extension_params<mnt4_base_field<Version>>::integral_type,
110 
111  template<std::size_t Version>
112  constexpr std::array<typename fp2_extension_params<mnt4_base_field<Version>>::integral_type,
114 
115  template<std::size_t Version>
116  constexpr typename fp2_extension_params<mnt4_base_field<Version>>::extended_integral_type const
118 
119  template<std::size_t Version>
120  constexpr typename fp2_extension_params<mnt4_base_field<Version>>::integral_type const
122 
123  template<std::size_t Version>
124  constexpr std::array<typename fp2_extension_params<mnt4_base_field<Version>>::integral_type,
125  2> const fp2_extension_params<mnt4_base_field<Version>>::Frobenius_coeffs_c1;
126  } // namespace detail
127  } // namespace fields
128  } // namespace algebra
129  } // namespace crypto3
130 } // namespace nil
131 
132 #endif // CRYPTO3_ALGEBRA_FIELDS_MNT4_FP2_EXTENSION_PARAMS_HPP
base_field_type non_residue_field_type
Definition: detail/extension_params/mnt4/fp2.hpp:63
policy_type::extended_integral_type extended_integral_type
Definition: detail/extension_params/mnt4/fp2.hpp:59
non_residue_field_type::value_type non_residue_type
Definition: detail/extension_params/mnt4/fp2.hpp:64
policy_type::integral_type integral_type
Definition: detail/extension_params/mnt4/fp2.hpp:58
underlying_field_type::value_type underlying_type
Definition: detail/extension_params/mnt4/fp2.hpp:66
base_field_type underlying_field_type
Definition: detail/extension_params/mnt4/fp2.hpp:65
Definition: pair.hpp:31
Definition: detail/extension_params/alt_bn128/fp2.hpp:44
IETF IPsec groups.
Definition: mnt4/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