-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add a lot of test vectors and improve handling of invalid contributions in reference code #9
Conversation
Concept ACK on having |
I ported the existing test vectors to JSON in this PR: #10 Once this PR is stable/merged, I can update my PR to include those new test vectors. |
Just realized that this doesn't fully address #5 because there are still no tests for nonce generation. |
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.
This is a very clean approach, I think.
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.
Overall looks great—I like the InvalidContributionError
approach.
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.
ACK 8d79d3b
Initially, I thought that we should document that But this gets complicated because the guarantees are different. The aggregator is trusted for robustness/identifiable aborts, so the ability to blame aggregator is of limited use, and a malicious aggregator could always claim that someone else is wrong. So having an Maybe it would be clearer to simply raise a In any case, the BIP text can be made clearer here.
But all of this should be done in a separate PR. |
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.
some (micro)-nits
bip-musig2/reference.py
Outdated
# - InvalidContributionError for indicating that a participant (or the | ||
# aggregator) is misbehaving in the protocol |
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.
# - InvalidContributionError for indicating that a participant (or the | |
# aggregator) is misbehaving in the protocol | |
# - InvalidContributionError for indicating that a signer (or the | |
# aggregator) is misbehaving in the protocol. |
bip-musig2/reference.py
Outdated
# output of a hash function is 0), and can't be manually triggered by any | ||
# participant |
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.
# output of a hash function is 0), and can't be manually triggered by any | |
# participant | |
# output of a hash function is 0) and can't be manually triggered by any | |
# signer. |
bip-musig2/reference.py
Outdated
# There are two types of exceptions that can be raised by this implementation: | ||
# - ValueError for indicating that an input doesn't conform to some function | ||
# precondition (e.g. an input array is the wrong length, a serialized | ||
# representation doesn't have the correct format) |
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.
# representation doesn't have the correct format) | |
# representation doesn't have the correct format). |
bip-musig2/reference.py
Outdated
@@ -336,6 +361,15 @@ def partial_sig_agg(psigs: List[bytes], session_ctx: SessionContext) -> Optional | |||
def fromhex_all(l): | |||
return [bytes.fromhex(l_i) for l_i in l] | |||
|
|||
# Check that calling `try_fn` raises a `exception`. If `exception` is raised, | |||
# examine it with`except_fn`. |
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.
# examine it with`except_fn`. | |
# examine it with `except_fn`. |
Do you want to merge this or #20 first? This will affect some of the test vectors here.
Hm on a second thought, I don't know... |
I'd like to merge this first, since other PRs (separate tweaking from keyagg) are based on it. |
Fixed nits |
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.
ACK 141919e
let's keep the InvalidContributionError, and I can open a PR that improves the explanations
Fixes #5 and #2.
Based on #8.