-
Notifications
You must be signed in to change notification settings - Fork 46
Mark Miniscript with duplicate keys as insane #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bitcoin/script/miniscript.h
Outdated
//! Returns true if the node contains at least one duplicate key. | ||
bool ContainsDuplicateKey() const { | ||
auto upfn = [](const Node& node, Span<std::set<Key>> subs) -> std::optional<std::set<Key>> { | ||
size_t keys_count = node.keys.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add if (node.duplicate_key) return {};
. That way no work is done in recomputing these sets all the time if we already know there is a duplicate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm but the boolean would be uninitialized for the current node. Isn't its value undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, that's a bad idea. For the current node, we obviously don't know yet. But for any child nodes we do.
So what about if (&node != this && node.duplicate_key) return {};
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there isn't any point in actually computing the set for child, right? We just use the duplicate_key
boolean: if one messed up with the keys after the Node
was created they were really looking for troubles..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow.
6518ee3
to
d10a9ca
Compare
I don't follow.
It's because i didn't plug my brain before commenting, sorry about that.
I'm away and back on Sunday, i'll push your optimization then. (If you need it before i think you have access to push to my PRs.)
|
It's ok. I just made coffee without putting a cup in the machine.
No rush. |
d10a9ca
to
e983e05
Compare
As stated on the website, duplicate keys make it hard to reason about malleability as a single signature may unlock multiple paths.
e983e05
to
13edbef
Compare
Rebased on #114 |
utACK 13edbef |
Based off a rebased #114