keccak_policy.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2018-2020 Mikhail Komarov <nemo@nil.foundation>
3 // Copyright (c) 2020 Alexander Sokolov <asokolov@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_KECCAK_POLICY_HPP
27 #define CRYPTO3_KECCAK_POLICY_HPP
28 
29 #include <nil/crypto3/detail/basic_functions.hpp>
30 
31 namespace nil {
32  namespace crypto3 {
33  namespace hashes {
34  namespace detail {
35  template<std::size_t DigestBits>
37 
38  constexpr static const std::size_t digest_bits = DigestBits;
40 
41  constexpr static const std::size_t state_bits = 1600;
42  constexpr static const std::size_t state_words = state_bits / word_bits;
43  typedef typename std::array<word_type, state_words> state_type;
44 
45  constexpr static const std::size_t block_bits = state_bits - 2 * digest_bits;
46  constexpr static const std::size_t block_words = block_bits / word_bits;
47  typedef std::array<word_type, block_words> block_type;
48 
49  constexpr static const std::size_t length_bits = 0;
50 
52 
53  constexpr static const std::size_t rounds = 24;
54 
55  struct iv_generator {
56  state_type const &operator()() const {
57  static state_type const H0 = {UINT64_C(0x0000000000000000), UINT64_C(0x0000000000000000),
58  UINT64_C(0x0000000000000000), UINT64_C(0x0000000000000000),
59  UINT64_C(0x0000000000000000), UINT64_C(0x0000000000000000),
60  UINT64_C(0x0000000000000000), UINT64_C(0x0000000000000000),
61  UINT64_C(0x0000000000000000), UINT64_C(0x0000000000000000),
62  UINT64_C(0x0000000000000000), UINT64_C(0x0000000000000000),
63  UINT64_C(0x0000000000000000), UINT64_C(0x0000000000000000),
64  UINT64_C(0x0000000000000000), UINT64_C(0x0000000000000000),
65  UINT64_C(0x0000000000000000), UINT64_C(0x0000000000000000),
66  UINT64_C(0x0000000000000000), UINT64_C(0x0000000000000000),
67  UINT64_C(0x0000000000000000), UINT64_C(0x0000000000000000),
68  UINT64_C(0x0000000000000000), UINT64_C(0x0000000000000000),
69  UINT64_C(0x0000000000000000)};
70  return H0;
71  }
72  };
73  };
74  } // namespace detail
75  } // namespace hashes
76  } // namespace crypto3
77 } // namespace nil
78 
79 #endif // CRYPTO3_KECCAK_POLICY_HPP
Definition: block/include/nil/crypto3/detail/static_digest.hpp:72
Definition: pair.hpp:31
Definition: block/include/nil/crypto3/detail/basic_functions.hpp:37
constexpr static const std::size_t word_bits
Definition: block/include/nil/crypto3/detail/basic_functions.hpp:41
state_type const & operator()() const
Definition: keccak_policy.hpp:56
Definition: keccak_policy.hpp:36
constexpr static const std::size_t block_words
Definition: keccak_policy.hpp:46
constexpr static const std::size_t digest_bits
Definition: keccak_policy.hpp:38
stream_endian::big_octet_big_bit digest_endian
Definition: keccak_policy.hpp:51
constexpr static const std::size_t rounds
Definition: keccak_policy.hpp:53
std::array< word_type, state_words > state_type
Definition: keccak_policy.hpp:43
constexpr static const std::size_t length_bits
Definition: keccak_policy.hpp:49
std::array< word_type, block_words > block_type
Definition: keccak_policy.hpp:47
static_digest< digest_bits > digest_type
Definition: keccak_policy.hpp:39
constexpr static const std::size_t state_words
Definition: keccak_policy.hpp:42
constexpr static const std::size_t state_bits
Definition: keccak_policy.hpp:41
constexpr static const std::size_t block_bits
Definition: keccak_policy.hpp:45
Definition: algebra/include/nil/crypto3/detail/stream_endian.hpp:39