17 std::array<std::byte, 32> key_data{std::byte{1}};
20 key_data[31] = std::byte(i);
50 if (hex_characters.size() != 2)
return {};
52 if (idx.size() != 1)
return {};
58 if (mocked_desc.size() < 7)
return {};
62 desc.reserve(mocked_desc.size());
65 for (
size_t i = 0; i < mocked_desc.size();) {
66 if (mocked_desc[i] ==
'%') {
67 if (i + 3 >= mocked_desc.size())
return {};
68 if (
const auto idx =
IdxFromHex(mocked_desc.substr(i + 1, 2))) {
75 desc += mocked_desc[i++];
85 for (
const auto& ch: buff) {
89 }
else if (ch ==
'/') {
90 if (++depth > max_depth)
return true;
96bool HasTooManySubFrag(std::span<const uint8_t> buff,
const int max_subs,
const size_t max_nested_subs)
99 std::stack<int> counts;
100 for (
const auto& ch: buff) {
102 if (counts.size() > max_nested_subs)
return true;
108 }
else if (ch ==
',' && !counts.empty()) {
111 if (++counts.top() > max_subs)
return true;
112 }
else if (ch ==
')' && !counts.empty()) {
124 std::optional<int>
count;
131 for (
const auto ch: buff | std::views::reverse) {
141 if (ch ==
',' || ch ==
'(' || ch ==
'{') {
143 }
else if (++*
count > max_wrappers) {
154 uint32_t leaf_len{0};
155 for (
auto c : buff) {
156 if (c ==
'(' || c ==
')' || c ==
',' || c ==
'{' || c ==
'}') {
164 if (++leaf_len > max_leaf_size) {
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::string HexStr(const std::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(std::span< const std::byte > seed)
bool HasTooManySubFrag(std::span< const uint8_t > 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 HasTooLargeLeafSize(std::span< const uint8_t > buff, const uint32_t max_leaf_size)
Whether the expanded buffer (after calling GetDescriptor() in MockedDescriptorConverter) has a leaf s...
bool HasDeepDerivPath(std::span< const uint8_t > buff, const int max_depth)
Whether the buffer, if it represents a valid descriptor, contains a derivation path deeper than a giv...
bool HasTooManyWrappers(std::span< const uint8_t > buff, const int max_wrappers)
Whether the buffer, if it represents a valid descriptor, contains a fragment with more wrappers than ...