12 std::array<std::byte, 32> key_data{std::byte{1}};
15 key_data[31] = std::byte(i);
45 if (hex_characters.size() != 2)
return {};
47 if (idx.size() != 1)
return {};
53 if (mocked_desc.size() < 7)
return {};
57 desc.reserve(mocked_desc.size());
60 for (
size_t i = 0; i < mocked_desc.size();) {
61 if (mocked_desc[i] ==
'%') {
62 if (i + 3 >= mocked_desc.size())
return {};
63 if (
const auto idx =
IdxFromHex(mocked_desc.substr(i + 1, 2))) {
70 desc += mocked_desc[i++];
80 for (
const auto& ch: buff) {
84 }
else if (ch ==
'/') {
85 if (++depth > max_depth)
return true;
94 std::stack<int> counts;
95 for (
const auto& ch: buff) {
97 if (counts.size() > max_nested_subs)
return true;
103 }
else if (ch ==
',' && !counts.empty()) {
106 if (++counts.top() > max_subs)
return true;
107 }
else if (ch ==
')' && !counts.empty()) {
119 std::optional<int>
count;
126 for (
const auto ch: buff | std::views::reverse) {
136 if (ch ==
',' || ch ==
'(' || ch ==
'{') {
138 }
else if (++*
count > max_wrappers) {
An encapsulated private key.
CPubKey GetPubKey() const
Compute the public key from a private key.
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
An encapsulated public key.
bool IdIsUnCompPubKey(uint8_t idx) const
bool IdIsXOnlyPubKey(uint8_t idx) const
void Init()
When initializing the target, populate the list of keys.
static constexpr size_t TOTAL_KEYS_GENERATED
How many keys we'll generate in total.
std::optional< std::string > GetDescriptor(std::string_view mocked_desc) const
Get an actual descriptor string from a descriptor string whose keys were mocked.
bool IdIsXprv(uint8_t idx) const
bool IdIsCompPubKey(uint8_t idx) const
std::array< std::string, TOTAL_KEYS_GENERATED > keys_str
256 keys of various types.
bool IdIsConstPrivKey(uint8_t idx) const
std::optional< uint8_t > IdxFromHex(std::string_view hex_characters) const
Parse an id in the keys vectors from a 2-characters hex string.
std::span< const uint8_t > FuzzBufferType
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::string EncodeExtKey(const CExtKey &key)
std::string EncodeSecret(const CKey &key)
std::string EncodeExtPubKey(const CExtPubKey &key)
std::vector< Byte > ParseHex(std::string_view hex_str)
Like TryParseHex, but returns an empty vector on invalid input.
CExtPubKey Neuter() const
void SetSeed(Span< const std::byte > seed)
bool HasTooManySubFrag(const FuzzBufferType &buff, const int max_subs, const size_t max_nested_subs)
Whether the buffer, if it represents a valid descriptor, contains a fragment with more sub-fragments ...
bool HasTooManyWrappers(const FuzzBufferType &buff, const int max_wrappers)
Whether the buffer, if it represents a valid descriptor, contains a fragment with more wrappers than ...
bool HasDeepDerivPath(const FuzzBufferType &buff, const int max_depth)
Whether the buffer, if it represents a valid descriptor, contains a derivation path deeper than a giv...