Kagome
Polkadot Runtime Engine in C++17
mp_utils.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_CRYPTO_MP_UTILS_HPP
7 #define KAGOME_CORE_CRYPTO_MP_UTILS_HPP
8 
9 #include <boost/multiprecision/cpp_int.hpp>
10 #include <gsl/span>
11 
12 namespace kagome::common {
13 
16 
17  std::array<uint8_t, 8> uint64_to_le_bytes(uint64_t number);
18  uint64_t le_bytes_to_uint64(gsl::span<const uint8_t, 8> bytes);
19 
20  std::array<uint8_t, 8> uint64_to_be_bytes(uint64_t number);
21  uint64_t be_bytes_to_uint64(gsl::span<const uint8_t, 8> bytes);
22 
23  std::array<uint8_t, 16> uint128_to_le_bytes(const uint128_t &i);
24  uint128_t le_bytes_to_uint128(gsl::span<const uint8_t, 16> bytes);
25 
26  std::array<uint8_t, 16> uint128_to_be_bytes(const uint128_t &i);
27  uint128_t be_bytes_to_uint128(gsl::span<const uint8_t, 16> bytes);
28 
29  std::array<uint8_t, 32> uint256_to_le_bytes(const uint256_t &i);
30  uint256_t le_bytes_to_uint256(gsl::span<const uint8_t, 32> bytes);
31 
32  std::array<uint8_t, 32> uint256_to_be_bytes(const uint256_t &i);
33  uint256_t be_bytes_to_uint256(gsl::span<const uint8_t, 32> bytes);
34 
35 } // namespace kagome::common
36 
37 #endif // KAGOME_CORE_CRYPTO_MP_UTILS_HPP
boost::multiprecision::uint256_t uint256_t
Definition: mp_utils.hpp:15
uint64_t le_bytes_to_uint64(gsl::span< const uint8_t, 8 > bytes)
Definition: mp_utils.cpp:58
boost::multiprecision::uint256_t be_bytes_to_uint256(gsl::span< const uint8_t, 32 > bytes)
Definition: mp_utils.cpp:111
boost::multiprecision::uint128_t be_bytes_to_uint128(gsl::span< const uint8_t, 16 > bytes)
Definition: mp_utils.cpp:91
boost::multiprecision::uint128_t le_bytes_to_uint128(gsl::span< const uint8_t, 16 > bytes)
Definition: mp_utils.cpp:81
uint64_t be_bytes_to_uint64(gsl::span< const uint8_t, 8 > bytes)
Definition: mp_utils.cpp:70
boost::multiprecision::uint256_t le_bytes_to_uint256(gsl::span< const uint8_t, 32 > bytes)
Definition: mp_utils.cpp:101
std::array< uint8_t, 8 > uint64_to_be_bytes(uint64_t number)
Definition: mp_utils.cpp:64
std::array< uint8_t, 32 > uint256_to_be_bytes(const boost::multiprecision::uint256_t &i)
Definition: mp_utils.cpp:106
std::array< uint8_t, 16 > uint128_to_le_bytes(const boost::multiprecision::uint128_t &i)
Definition: mp_utils.cpp:76
std::array< uint8_t, 8 > uint64_to_le_bytes(uint64_t number)
Definition: mp_utils.cpp:52
boost::multiprecision::uint128_t uint128_t
Definition: mp_utils.hpp:14
std::array< uint8_t, 16 > uint128_to_be_bytes(const boost::multiprecision::uint128_t &i)
Definition: mp_utils.cpp:86
std::array< uint8_t, 32 > uint256_to_le_bytes(const boost::multiprecision::uint256_t &i)
Definition: mp_utils.cpp:96