detail/extension_params/edwards/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_EDWARDS_FP3_EXTENSION_PARAMS_HPP
27 #define CRYPTO3_ALGEBRA_FIELDS_EDWARDS_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>
45 
46  /************************* EDWARDS ***********************************/
47 
48  template<std::size_t Version>
49  class fp3_extension_params<fields::edwards_base_field<Version>>
50  : public params<fields::edwards_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 = 0x1F;
67  constexpr static const extended_integral_type t =
68  0x8514C337908664095AA1E4077718C1F93B49FEBD3E1DE5A3BF284A7BC8C90EE457BC1D3D59409F6A8049FB3D3B1E20915D50941493A9E2B4B0685ACA3C9847645_cppui516;
69  constexpr static const extended_integral_type t_minus_1_over_2 =
70  0x428A619BC8433204AD50F203BB8C60FC9DA4FF5E9F0EF2D1DF94253DE46487722BDE0E9EACA04FB54024FD9E9D8F1048AEA84A0A49D4F15A58342D651E4C23B22_cppui515;
71  constexpr static const std::array<integral_type, 3> nqr = {0x17, 0x00, 0x00};
72  constexpr static const std::array<integral_type, 3> nqr_to_t = {
73  0x118228ECB464A2F6EB8DACC18FA757E45B3989330150C_cppui177, 0x00, 0x00};
74 
75  constexpr static const extended_integral_type group_order =
76  0x214530CDE421990256A87901DDC6307E4ED27FAF4F877968EFCA129EF23243B915EF074F565027DAA0127ECF4EC788245754250524EA78AD2C1A16B28F2611D9140000000_cppui546;
77 
78  /*constexpr static const std::array<non_residue_type, 3> Frobenius_coeffs_c1 =
79  {non_residue_type(0x01),
80  non_residue_type(0xB35E3665A18365954D018902935D4419423F84321BC3D_cppui180),
81  non_residue_type(0x35A01936D02124BA36C236460AF76D755745133CDE43C3_cppui182)};
82 
83  constexpr static const std::array<non_residue_type, 3> Frobenius_coeffs_c2 =
84  {non_residue_type(0x01),
85  non_residue_type(0x35A01936D02124BA36C236460AF76D755745133CDE43C3_cppui182),
86  non_residue_type(0xB35E3665A18365954D018902935D4419423F84321BC3D_cppui180)};*/
87 
88  constexpr static const std::array<integral_type, 3> Frobenius_coeffs_c1 = {
89  0x01, 0xB35E3665A18365954D018902935D4419423F84321BC3D_cppui180,
90  0x35A01936D02124BA36C236460AF76D755745133CDE43C3_cppui182};
91 
92  constexpr static const std::array<integral_type, 3> Frobenius_coeffs_c2 = {
93  0x01, 0x35A01936D02124BA36C236460AF76D755745133CDE43C3_cppui182,
94  0xB35E3665A18365954D018902935D4419423F84321BC3D_cppui180};
95 
96  constexpr static const non_residue_type non_residue = non_residue_type(0x3D);
97  };
98 
99  template<std::size_t Version>
100  constexpr typename fp3_extension_params<edwards_base_field<Version>>::non_residue_type const
102 
103  template<std::size_t Version>
104  constexpr typename std::size_t const fp3_extension_params<edwards_base_field<Version>>::s;
105 
106  template<std::size_t Version>
107  constexpr typename fp3_extension_params<edwards_base_field<Version>>::extended_integral_type const
109 
110  template<std::size_t Version>
111  constexpr typename fp3_extension_params<edwards_base_field<Version>>::extended_integral_type const
113 
114  template<std::size_t Version>
115  constexpr std::array<typename fp3_extension_params<edwards_base_field<Version>>::integral_type,
117 
118  template<std::size_t Version>
119  constexpr std::array<typename fp3_extension_params<edwards_base_field<Version>>::integral_type,
121 
122  template<std::size_t Version>
123  constexpr typename fp3_extension_params<edwards_base_field<Version>>::extended_integral_type const
125 
126  template<std::size_t Version>
127  constexpr typename fp3_extension_params<edwards_base_field<Version>>::integral_type const
129 
130  template<std::size_t Version>
131  constexpr std::array<typename fp3_extension_params<edwards_base_field<Version>>::integral_type,
132  3> const
134  template<std::size_t Version>
135  constexpr std::array<typename fp3_extension_params<edwards_base_field<Version>>::integral_type,
136  3> const
138 
139  } // namespace detail
140  } // namespace fields
141  } // namespace algebra
142  } // namespace crypto3
143 } // namespace nil
144 
145 #endif // CRYPTO3_ALGEBRA_FIELDS_EDWARDS_FP3_EXTENSION_PARAMS_HPP
policy_type::integral_type integral_type
Definition: detail/extension_params/edwards/fp3.hpp:56
underlying_field_type::value_type underlying_type
Definition: detail/extension_params/edwards/fp3.hpp:64
policy_type::extended_integral_type extended_integral_type
Definition: detail/extension_params/edwards/fp3.hpp:57
base_field_type non_residue_field_type
Definition: detail/extension_params/edwards/fp3.hpp:61
base_field_type underlying_field_type
Definition: detail/extension_params/edwards/fp3.hpp:63
non_residue_field_type::value_type non_residue_type
Definition: detail/extension_params/edwards/fp3.hpp:62
Definition: pair.hpp:31
Definition: detail/extension_params/edwards/fp3.hpp:44
IETF IPsec groups.
Definition: edwards/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