rippled
Loading...
Searching...
No Matches
Seed.h
1#pragma once
2
3#include <xrpl/basics/Slice.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/protocol/tokens.h>
6
7#include <array>
8#include <optional>
9
10namespace xrpl {
11
13class Seed
14{
15private:
17
18public:
20
21 Seed() = delete;
22
23 Seed(Seed const&) = default;
24 Seed&
25 operator=(Seed const&) = default;
26
30 ~Seed();
31
34 explicit Seed(Slice const& slice);
35 explicit Seed(uint128 const& seed);
38 std::uint8_t const*
39 data() const
40 {
41 return buf_.data();
42 }
43
45 size() const
46 {
47 return buf_.size();
48 }
49
51 begin() const noexcept
52 {
53 return buf_.begin();
54 }
55
57 cbegin() const noexcept
58 {
59 return buf_.cbegin();
60 }
61
63 end() const noexcept
64 {
65 return buf_.end();
66 }
67
69 cend() const noexcept
70 {
71 return buf_.cend();
72 }
73};
74
75//------------------------------------------------------------------------------
76
78Seed
80
92Seed
93generateSeed(std::string const& passPhrase);
94
96template <>
98parseBase58(std::string const& s);
99
106parseGenericSeed(std::string const& str, bool rfc1751 = true);
107
110seedAs1751(Seed const& seed);
111
113inline std::string
114toBase58(Seed const& seed)
115{
116 return encodeBase58Token(TokenType::FamilySeed, seed.data(), seed.size());
117}
118
119} // namespace xrpl
T begin(T... args)
Seeds are used to generate deterministic secret keys.
Definition Seed.h:14
Seed(Seed const &)=default
const_iterator begin() const noexcept
Definition Seed.h:51
const_iterator cend() const noexcept
Definition Seed.h:69
Seed()=delete
const_iterator end() const noexcept
Definition Seed.h:63
const_iterator cbegin() const noexcept
Definition Seed.h:57
std::array< uint8_t, 16 > buf_
Definition Seed.h:16
~Seed()
Destroy the seed.
Definition Seed.cpp:25
std::size_t size() const
Definition Seed.h:45
std::array< uint8_t, 16 >::const_iterator const_iterator
Definition Seed.h:19
Seed & operator=(Seed const &)=default
std::uint8_t const * data() const
Definition Seed.h:39
An immutable linear range of bytes.
Definition Slice.h:26
Integers of any length that is a multiple of 32-bits.
Definition base_uint.h:66
T data(T... args)
T end(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::optional< AccountID > parseBase58(std::string const &s)
Parse AccountID from checked, base58 string.
Seed randomSeed()
Create a seed using secure random numbers.
Definition Seed.cpp:47
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition AccountID.cpp:92
std::string seedAs1751(Seed const &seed)
Encode a Seed in RFC1751 format.
Definition Seed.cpp:114
Seed generateSeed(std::string const &passPhrase)
Generate a seed deterministically.
Definition Seed.cpp:57
std::string encodeBase58Token(TokenType type, void const *token, std::size_t size)
Encode data in Base58Check format using XRPL alphabet.
Definition tokens.cpp:176
std::optional< Seed > parseGenericSeed(std::string const &str, bool rfc1751=true)
Attempt to parse a string as a seed.
Definition Seed.cpp:78
T size(T... args)