Skip to content
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

Merged
merged 8 commits into from
Jun 8, 2022

Conversation

jonasnick
Copy link
Owner

Fixes #5 and #2.

Based on #8.

@real-or-random
Copy link
Collaborator

Concept ACK on having InvalidContributionErrors

@Roasbeef
Copy link

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.

@jonasnick
Copy link
Owner Author

Just realized that this doesn't fully address #5 because there are still no tests for nonce generation.

Copy link
Collaborator

@real-or-random real-or-random left a 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.

Copy link
Collaborator

@robot-dreams robot-dreams left a 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.

Copy link
Collaborator

@robot-dreams robot-dreams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 8d79d3b

@real-or-random
Copy link
Collaborator

real-or-random commented Jun 8, 2022

Initially, I thought that we should document that None means the aggregator is faulty.

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 InvalidContributionError for the aggregator may convey the wrong impression that a honest can identify the disruptive party even when an aggregator is used, and that a malicious aggregator can be identified reliably.

Maybe it would be clearer to simply raise a ValueError instead? This will clearly separate the guaranteed ability to identify disruptive signers (identifiable abort) from other errors, and I think that's cleaner. Yet another alternative is to have a separate exception for the aggregator but this seems overkill to me.


In any case, the BIP text can be made clearer here.

  • For example, it currently doesn't say anything about blaming the aggregator. If we keep the InvalidContributionError, then we should elaborate in the text.
  • Also, it currently says "This standard specifies a partial signature verification algorithm to identify disruptive signers. It is incompatible with third-party nonce aggregation because the individual nonce is required for partial verification." That's not entirely true. The aggregator can still identify disruptive parties. We could also refer to ROAST now for a more formal discussion of IA.
  • "All the aggregator node can do is prevent the signing session from succeeding by sending out incorrect aggregate nonces." It can also send a wrong final sig.

But all of this should be done in a separate PR.

Copy link
Collaborator

@real-or-random real-or-random left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some (micro)-nits

Comment on lines 109 to 110
# - InvalidContributionError for indicating that a participant (or the
# aggregator) is misbehaving in the protocol
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# - 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.

Comment on lines 114 to 115
# output of a hash function is 0), and can't be manually triggered by any
# participant
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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.

# 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# representation doesn't have the correct format)
# representation doesn't have the correct format).

@@ -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`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# examine it with`except_fn`.
# examine it with `except_fn`.

@real-or-random
Copy link
Collaborator

Do you want to merge this or #20 first? This will affect some of the test vectors here.

Maybe it would be clearer to simply raise a ValueError instead?

Hm on a second thought, I don't know... ValueError is not a good idea either because then signers could crash. Maybe a separate exception is really better?

@jonasnick
Copy link
Owner Author

Do you want to merge this or #20 first?

I'd like to merge this first, since other PRs (separate tweaking from keyagg) are based on it.

@jonasnick
Copy link
Owner Author

Fixed nits

Copy link
Collaborator

@real-or-random real-or-random left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add more test vectors
4 participants