ffdhe_ietf.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_FFDHE_IETF_HPP
27 #define CRYPTO3_ALGEBRA_FIELDS_FFDHE_IETF_HPP
28 
30 
33 
35 
36 namespace nil {
37  namespace crypto3 {
38  namespace algebra {
39  namespace fields {
40 
45  template<std::size_t Version>
46  struct ffdhe_ietf : public field<Version> { };
47 
48  template<>
49  struct ffdhe_ietf<2048> : public field<2048> {
51 
52  constexpr static const std::size_t modulus_bits = policy_type::modulus_bits;
54 
56 
57  constexpr static const std::size_t number_bits = policy_type::number_bits;
58 
59  constexpr static const integral_type modulus =
60  0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B423861285C97FFFFFFFFFFFFFFFF_cppui2048;
61 
63  constexpr static const modular_params_type modulus_params = modulus;
64  typedef nil::crypto3::multiprecision::number<
65  nil::crypto3::multiprecision::backends::modular_adaptor<modular_backend, nil::crypto3::multiprecision::backends::modular_params_ct<modular_backend, modulus_params>>>
67 
68  constexpr static const integral_type mul_generator = 0x02;
69 
71  constexpr static const std::size_t value_bits = modulus_bits;
72 
73  constexpr static const std::size_t arity = 1;
74  };
75 
76  template<>
77  struct ffdhe_ietf<3072> : public field<3072> {
79 
80  constexpr static const std::size_t modulus_bits = policy_type::modulus_bits;
82 
83  constexpr static const integral_type modulus =
84  0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C023861B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91CAEFE130985139270B4130C93BC437944F4FD4452E2D74DD364F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0DABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF3C1B20EE3FD59D7C25E41D2B66C62E37FFFFFFFFFFFFFFFF_cppui3072;
85 
86  constexpr static const integral_type mul_generator = 0x02;
87 
89 
90  constexpr static const std::size_t value_bits = modulus_bits;
91  constexpr static const std::size_t arity = 1;
92  };
93 
94  template<>
95  struct ffdhe_ietf<4096> : public field<4096> {
97 
98  constexpr static const std::size_t modulus_bits = policy_type::modulus_bits;
100 
101  constexpr static const integral_type modulus =
102  0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C023861B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91CAEFE130985139270B4130C93BC437944F4FD4452E2D74DD364F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0DABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB7930E9E4E58857B6AC7D5F42D69F6D187763CF1D5503400487F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832A907600A918130C46DC778F971AD0038092999A333CB8B7A1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E655F6AFFFFFFFFFFFFFFFF_cppui4096;
103 
104  constexpr static const integral_type mul_generator = 0x02;
105 
107 
108  constexpr static const std::size_t value_bits = modulus_bits;
109  constexpr static const std::size_t arity = 1;
110  };
111 
112  template<>
113  struct ffdhe_ietf<6144> : public field<6144> {
115 
116  constexpr static const std::size_t modulus_bits = policy_type::modulus_bits;
118 
119  constexpr static const integral_type modulus =
120  0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C023861B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91CAEFE130985139270B4130C93BC437944F4FD4452E2D74DD364F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0DABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB7930E9E4E58857B6AC7D5F42D69F6D187763CF1D5503400487F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832A907600A918130C46DC778F971AD0038092999A333CB8B7A1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD9020BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA63BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3ACDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477A52471F7A9A96910B855322EDB6340D8A00EF092350511E30ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538CD72B03746AE77F5E62292C311562A846505DC82DB854338AE49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B045B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1A41D570D7938DAD4A40E329CD0E40E65FFFFFFFFFFFFFFFF_cppui6144;
121 
122  constexpr static const integral_type mul_generator = 0x02;
123 
125 
126  constexpr static const std::size_t value_bits = modulus_bits;
127  constexpr static const std::size_t arity = 1;
128  };
129 
130  template<>
131  struct ffdhe_ietf<8192> : public field<8192> {
133 
134  constexpr static const std::size_t modulus_bits = policy_type::modulus_bits;
136 
137  constexpr static const integral_type modulus =
138  0xFFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF97D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD65612433F51F5F066ED0856365553DED1AF3B557135E7F57C935984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE73530ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FBB96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB190B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F619172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD733BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C023861B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91CAEFE130985139270B4130C93BC437944F4FD4452E2D74DD364F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0DABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB7930E9E4E58857B6AC7D5F42D69F6D187763CF1D5503400487F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832A907600A918130C46DC778F971AD0038092999A333CB8B7A1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD9020BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA63BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3ACDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477A52471F7A9A96910B855322EDB6340D8A00EF092350511E30ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538CD72B03746AE77F5E62292C311562A846505DC82DB854338AE49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B045B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1A41D570D7938DAD4A40E329CCFF46AAA36AD004CF600C8381E425A31D951AE64FDB23FCEC9509D43687FEB69EDD1CC5E0B8CC3BDF64B10EF86B63142A3AB8829555B2F747C932665CB2C0F1CC01BD70229388839D2AF05E454504AC78B7582822846C0BA35C35F5C59160CC046FD8251541FC68C9C86B022BB7099876A460E7451A8A93109703FEE1C217E6C3826E52C51AA691E0E423CFC99E9E31650C1217B624816CDAD9A95F9D5B8019488D9C0A0A1FE3075A577E23183F81D4A3F2FA4571EFC8CE0BA8A4FE8B6855DFE72B0A66EDED2FBABFBE58A30FAFABE1C5D71A87E2F741EF8C1FE86FEA6BBFDE530677F0D97D11D49F7A8443D0822E506A9F4614E011E2A94838FF88CD68C8BB7C5C6424CFFFFFFFFFFFFFFFF_cppui8192;
139 
140  constexpr static const integral_type mul_generator = 0x02;
141 
143 
144  constexpr static const std::size_t value_bits = modulus_bits;
145  constexpr static const std::size_t arity = 1;
146  };
147 
153 
159 
160  } // namespace fields
161  } // namespace algebra
162  } // namespace crypto3
163 } // namespace nil
164 
165 #endif // CRYPTO3_ALGEBRA_FIELDS_FFDHE_IETF_HPP
Definition: pair.hpp:31
nil::crypto3::multiprecision::number< nil::crypto3::multiprecision::backends::modular_adaptor< modular_backend, nil::crypto3::multiprecision::backends::modular_params_ct< modular_backend, modulus_params > > > modular_type
Definition: ffdhe_ietf.hpp:66
detail::element_fp< params< ffdhe_ietf< modulus_bits > > > value_type
Definition: ffdhe_ietf.hpp:70
policy_type::modular_backend modular_backend
Definition: ffdhe_ietf.hpp:62
field< 2048 > policy_type
Definition: ffdhe_ietf.hpp:50
policy_type::integral_type integral_type
Definition: ffdhe_ietf.hpp:53
policy_type::extended_integral_type extended_integral_type
Definition: ffdhe_ietf.hpp:55
field< 3072 > policy_type
Definition: ffdhe_ietf.hpp:78
detail::element_fp< params< ffdhe_ietf< modulus_bits > > > value_type
Definition: ffdhe_ietf.hpp:88
policy_type::integral_type integral_type
Definition: ffdhe_ietf.hpp:81
field< 4096 > policy_type
Definition: ffdhe_ietf.hpp:96
detail::element_fp< params< ffdhe_ietf< modulus_bits > > > value_type
Definition: ffdhe_ietf.hpp:106
policy_type::integral_type integral_type
Definition: ffdhe_ietf.hpp:99
field< 6144 > policy_type
Definition: ffdhe_ietf.hpp:114
detail::element_fp< params< ffdhe_ietf< modulus_bits > > > value_type
Definition: ffdhe_ietf.hpp:124
policy_type::integral_type integral_type
Definition: ffdhe_ietf.hpp:117
policy_type::integral_type integral_type
Definition: ffdhe_ietf.hpp:135
field< 8192 > policy_type
Definition: ffdhe_ietf.hpp:132
detail::element_fp< params< ffdhe_ietf< modulus_bits > > > value_type
Definition: ffdhe_ietf.hpp:142
TLS FFDHE groups.
Definition: ffdhe_ietf.hpp:46
Definition: field.hpp:47
nil::crypto3::multiprecision::number< nil::crypto3::multiprecision::backends::cpp_int_backend< modulus_bits, modulus_bits, nil::crypto3::multiprecision::unsigned_magnitude, nil::crypto3::multiprecision::unchecked, void > > integral_type
Definition: field.hpp:54
nil::crypto3::multiprecision::modular_params< modular_backend > modular_params_type
Definition: field.hpp:72
constexpr static const std::size_t modulus_bits
Definition: field.hpp:49
nil::crypto3::multiprecision::backends::cpp_int_backend< modulus_bits, modulus_bits, nil::crypto3::multiprecision::signed_magnitude, nil::crypto3::multiprecision::unchecked, void > modular_backend
Definition: field.hpp:66
nil::crypto3::multiprecision::number< nil::crypto3::multiprecision::backends::cpp_int_backend< 16 *modulus_bits, 16 *modulus_bits, nil::crypto3::multiprecision::unsigned_magnitude, nil::crypto3::multiprecision::unchecked, void > > extended_integral_type
Definition: field.hpp:60
constexpr static const std::size_t number_bits
Definition: field.hpp:62