miniscript: mark nodes with duplicate keys as insane

As stated on the website, duplicate keys make it hard to reason about
malleability as a single signature may unlock multiple paths.

We use a custom KeyCompare function instead of operator< to be explicit
about the requirement.
This commit is contained in:
Antoine Poinsot
2022-04-14 19:01:26 +02:00
parent 8c0f8bf7bc
commit 7a549c6c59
3 changed files with 150 additions and 69 deletions

View File

@@ -47,6 +47,10 @@ struct TestData {
struct ParserContext {
typedef CPubKey Key;
bool KeyCompare(const Key& a, const Key& b) const {
return a < b;
}
std::optional<std::string> ToString(const Key& key) const
{
auto it = TEST_DATA.dummy_key_idx_map.find(key);
@@ -90,6 +94,10 @@ struct ScriptParserContext {
std::vector<unsigned char> data;
};
bool KeyCompare(const Key& a, const Key& b) const {
return a.data < b.data;
}
const std::vector<unsigned char>& ToPKBytes(const Key& key) const
{
assert(!key.is_hash);