19#include <cryptonote_basic/cryptonote_basic.h>
37 memwipe(
ptr_.get(),
sizeof(T));
38 delete ptr_.release();
41 operator T&() {
return *
ptr_; }
62 std::vector<std::string>
splitString(
const std::string &input,
const std::string &separator =
"",
size_t fixedWidth = 4);
75 SeedIndices seedIndices(
const unsigned char* bytes,
size_t byte_length,
size_t word_list_length = 1626,
size_t bytes_per_chunk = 4,
size_t words_per_chunk = 3);
78 template<
size_t byte_count>
79 std::array<unsigned char, byte_count>
seedBytes(
81 const size_t word_list_length = 1626,
82 const size_t bytes_per_chunk = 4,
83 const size_t words_per_chunk = 3
87 template<
size_t byte_count>
90 const size_t word_list_length,
91 const size_t bytes_per_chunk,
92 const size_t words_per_chunk
94 size_t words = indices.
size();
95 if (byte_count * words_per_chunk / bytes_per_chunk != words)
98 std::array<unsigned char, byte_count> out;
99 for (
size_t pos = 0; pos < words; pos += words_per_chunk) {
101 uint32_t previous = 0;
102 uint32_t multiplier = 1;
103 for (
size_t word = 0; word < words_per_chunk; word++) {
104 uint32_t current = indices[pos + word];
105 chunk += (multiplier * (((word_list_length - previous) + current) % word_list_length));
107 multiplier *= word_list_length;
110 chunk = SWAP32LE(chunk);
111 memcpy(out.data() + (pos / words_per_chunk) * bytes_per_chunk, &chunk, bytes_per_chunk);
Secure container for seed word indices.
Definition ots.hpp:1613
size_t size() const noexcept
Get vector size.
Definition seedindices.cpp:30
A class to handle a reference copy of a value and zeroize it on destruction.
Definition ots-internal.hpp:30
std::unique_ptr< T > ptr_
Definition ots-internal.hpp:42
ZeroizeReferenceCopy(const T &value)
Definition ots-internal.hpp:32
~ZeroizeReferenceCopy()
Definition ots-internal.hpp:33
a seed could not be encoded
Definition ots-exceptions.hpp:349
Constants for the Monero network to calculate the height from a timestamp and reverse.
The library exists complete only in this namespace.
Definition account.hpp:39
const ots::data::NetworkData * getNetworkData(Network network)
Definition ots.cpp:151
Network
Represents the monero network.
Definition ots.hpp:63
cryptonote::network_type cryptonoteNetwork(Network network) noexcept
Converts the network type from the library network type to cryptonote network type.
Definition ots.cpp:99
SeedIndices seedIndices(const unsigned char *bytes, size_t byte_length, size_t word_list_length=1626, size_t bytes_per_chunk=4, size_t words_per_chunk=3)
Returns the indices of a seed phrase.
Definition ots.cpp:105
const std::map< Network, ots::data::NetworkData > NETWORK_DATA_MAP
Definition ots.cpp:145
std::vector< std::string > splitString(const std::string &input, const std::string &separator="", size_t fixedWidth=4)
Converts a string by a separator or fixed 4 char width.
Definition ots.cpp:126
std::array< unsigned char, byte_count > seedBytes(const SeedIndices &indices, const size_t word_list_length=1626, const size_t bytes_per_chunk=4, const size_t words_per_chunk=3)
Definition ots-internal.hpp:88
Header for the C++ library.