-
Notifications
You must be signed in to change notification settings - Fork 13
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
Clean up error handling in compute_secrets #95
base: main
Are you sure you want to change the base?
Conversation
…ngPrivateShares DkgError; add TryFromInt DkgError and remove unwrap call in compute_secret; clean up tests
…g API breaking changes anyway
…n't have to worry about getting anything other than bad private shares from compute secrets
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.
Looks good, had some minor comments.
…ugh we checked above that the keys should be present
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 had one last question (probably).
if shares.len() != polys.len() { | ||
return Err(DkgError::NotEnoughShares(vec![self.id])); | ||
} |
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.
Do we need an equivalent check for this?
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.
The MissingPrivateShares
check covers this case, and also provides more information.
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.
Hmmm, I think it covers one case, but what if private_shares
is longer than public_shares
? I imaging that case is caught elsewhere?
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’d argue that we aren’t considering that an error anymore, since it doesn’t stop us from computing the secrets.
Maybe log a warning?
Error handling in
compute_secret
has always been problematic. This PR cleans it up, checking for the same errors inv1
andv2
.One issue is that if there is any non-overlap between public and private shares, we didn't have a good way to determine which should be treated as canonical. But the network state machines give a good hint; since
DkgEngBegin
will specify which are the signers taking part, we should expect to have exactly thoseDkgPublicShares
.Since we're making API breaking changes to the errors, I also added
TryFromInt
variants toDkgError
andAggregatorError
and used them to remove mostunwrap
calls fromv1
andv2
.Fixes #47 and addresses #89