xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
protocol
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 <
cstddef
>
9
#include <
cstdint
>
10
#include <
optional
>
11
#include <
string
>
12
13
namespace
xrpl
{
14
18
class
Seed
19
{
20
private
:
21
std::array<uint8_t, 16>
buf_
{};
22
23
public
:
24
using
const_iterator
= std::array<uint8_t, 16>::const_iterator;
25
26
Seed
() =
delete
;
27
28
Seed
(
Seed
const
&) =
default
;
29
Seed
&
30
operator=
(
Seed
const
&) =
default
;
31
36
~Seed
();
37
42
explicit
Seed
(
Slice
const
& slice);
43
explicit
Seed
(
UInt128
const
& seed);
45
46
[[nodiscard]]
std::uint8_t
const
*
47
data
()
const
48
{
49
return
buf_
.data();
50
}
51
52
[[nodiscard]]
std::size_t
53
size
()
const
54
{
55
return
buf_
.size();
56
}
57
58
[[nodiscard]]
const_iterator
59
begin
() const noexcept
60
{
61
return
buf_
.begin();
62
}
63
64
[[nodiscard]]
const_iterator
65
cbegin
() const noexcept
66
{
67
return
buf_
.cbegin();
68
}
69
70
[[nodiscard]]
const_iterator
71
end
() const noexcept
72
{
73
return
buf_
.end();
74
}
75
76
[[nodiscard]]
const_iterator
77
cend
() const noexcept
78
{
79
return
buf_
.cend();
80
}
81
};
82
83
//------------------------------------------------------------------------------
84
88
Seed
89
randomSeed
();
90
103
Seed
104
generateSeed
(
std::string
const
& passPhrase);
105
109
template
<>
110
std::optional<Seed>
111
parseBase58
(
std::string
const
& s);
112
119
std::optional<Seed>
120
parseGenericSeed
(
std::string
const
& str,
bool
rfc1751 =
true
);
121
125
std::string
126
seedAs1751
(Seed
const
& seed);
127
131
inline
std::string
132
toBase58
(
Seed
const
& seed)
133
{
134
return
encodeBase58Token
(
TokenType::FamilySeed
, seed.
data
(), seed.
size
());
135
}
136
137
}
// namespace xrpl
array
std::string
xrpl::Seed
Seeds are used to generate deterministic secret keys.
Definition
Seed.h:19
xrpl::Seed::Seed
Seed(Seed const &)=default
xrpl::Seed::begin
const_iterator begin() const noexcept
Definition
Seed.h:59
xrpl::Seed::cend
const_iterator cend() const noexcept
Definition
Seed.h:77
xrpl::Seed::Seed
Seed()=delete
xrpl::Seed::end
const_iterator end() const noexcept
Definition
Seed.h:71
xrpl::Seed::cbegin
const_iterator cbegin() const noexcept
Definition
Seed.h:65
xrpl::Seed::buf_
std::array< uint8_t, 16 > buf_
Definition
Seed.h:21
xrpl::Seed::~Seed
~Seed()
Destroy the seed.
Definition
Seed.cpp:26
xrpl::Seed::size
std::size_t size() const
Definition
Seed.h:53
xrpl::Seed::const_iterator
std::array< uint8_t, 16 >::const_iterator const_iterator
Definition
Seed.h:24
xrpl::Seed::operator=
Seed & operator=(Seed const &)=default
xrpl::Seed::data
std::uint8_t const * data() const
Definition
Seed.h:47
xrpl::Slice
An immutable linear range of bytes.
Definition
Slice.h:28
cstddef
cstdint
std::uint8_t
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::parseBase58
std::optional< AccountID > parseBase58(std::string const &s)
Parse AccountID from checked, base58 string.
Definition
AccountID.cpp:105
xrpl::randomSeed
Seed randomSeed()
Create a seed using secure random numbers.
Definition
Seed.cpp:48
xrpl::UInt128
BaseUInt< 128 > UInt128
Definition
base_uint.h:578
xrpl::toBase58
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition
AccountID.cpp:95
xrpl::seedAs1751
std::string seedAs1751(Seed const &seed)
Encode a Seed in RFC1751 format.
Definition
Seed.cpp:116
xrpl::generateSeed
Seed generateSeed(std::string const &passPhrase)
Generate a seed deterministically.
Definition
Seed.cpp:58
xrpl::const_iterator
Dir::ConstIterator const_iterator
Definition
Dir.cpp:16
xrpl::TokenType::FamilySeed
@ FamilySeed
Definition
tokens.h:27
xrpl::encodeBase58Token
std::string encodeBase58Token(TokenType type, void const *token, std::size_t size)
Encode data in Base58Check format using XRPL alphabet.
Definition
tokens.cpp:181
xrpl::parseGenericSeed
std::optional< Seed > parseGenericSeed(std::string const &str, bool rfc1751=true)
Attempt to parse a string as a seed.
Definition
Seed.cpp:79
optional
std::size_t
string
Generated by
1.17.0