-
Notifications
You must be signed in to change notification settings - Fork 34
/
int_serialization.hpp
38 lines (25 loc) · 1.05 KB
/
int_serialization.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <boost/multiprecision/cpp_int.hpp>
#include <span>
#include "common/buffer_view.hpp"
namespace kagome::common {
using uint128_t = boost::multiprecision::uint128_t;
using uint256_t = boost::multiprecision::uint256_t;
std::array<uint8_t, 8> uint64_to_le_bytes(uint64_t number);
uint64_t le_bytes_to_uint64(BufferView bytes);
std::array<uint8_t, 8> uint64_to_be_bytes(uint64_t number);
uint64_t be_bytes_to_uint64(BufferView bytes);
std::array<uint8_t, 16> uint128_to_le_bytes(const uint128_t &i);
uint128_t le_bytes_to_uint128(BufferView bytes);
std::array<uint8_t, 16> uint128_to_be_bytes(const uint128_t &i);
uint128_t be_bytes_to_uint128(BufferView bytes);
std::array<uint8_t, 32> uint256_to_le_bytes(const uint256_t &i);
uint256_t le_bytes_to_uint256(BufferView bytes);
std::array<uint8_t, 32> uint256_to_be_bytes(const uint256_t &i);
uint256_t be_bytes_to_uint256(BufferView bytes);
} // namespace kagome::common