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

Clean up error handling in compute_secrets #95

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

xoloki
Copy link
Collaborator

@xoloki xoloki commented Nov 21, 2024

Error handling in compute_secret has always been problematic. This PR cleans it up, checking for the same errors in v1 and v2.

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 those DkgPublicShares.

Since we're making API breaking changes to the errors, I also added TryFromInt variants to DkgError and AggregatorError and used them to remove most unwrap calls from v1 and v2.

Fixes #47 and addresses #89

…ngPrivateShares DkgError; add TryFromInt DkgError and remove unwrap call in compute_secret; clean up tests
@xoloki xoloki requested a review from djordon November 21, 2024 06:38
@xoloki xoloki marked this pull request as ready for review November 21, 2024 07:33
src/errors.rs Show resolved Hide resolved
Copy link

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

src/v1.rs Outdated Show resolved Hide resolved
src/v2.rs Outdated Show resolved Hide resolved
src/v2.rs Outdated Show resolved Hide resolved
src/v2.rs Show resolved Hide resolved
…ugh we checked above that the keys should be present
Copy link

@djordon djordon left a 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).

Comment on lines -136 to -138
if shares.len() != polys.len() {
return Err(DkgError::NotEnoughShares(vec![self.id]));
}
Copy link

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?

Copy link
Collaborator Author

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.

Copy link

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?

Copy link
Collaborator Author

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?

@xoloki xoloki self-assigned this Nov 24, 2024
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.

Clean up error handling in compute_secrets
2 participants