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

Adds validity checks to BLS public keys #81

Merged
merged 6 commits into from
Mar 26, 2024
Merged

Adds validity checks to BLS public keys #81

merged 6 commits into from
Mar 26, 2024

Conversation

brunoffranca
Copy link
Member

What ❔

Added checks for the validity of our BLS public keys as recommended by this spec. Namely we check that the public key is not zero and that it is in the correct subgroup.

We do it redundantly in two places (when we decode a public key and when we verify a signature).

Why ❔

Invalid public keys are a security risk.

@brunoffranca brunoffranca self-assigned this Mar 25, 2024
@pompon0
Copy link
Collaborator

pompon0 commented Mar 25, 2024

Please add a test for the constructor.

Copy link
Contributor

@dnkolegov dnkolegov left a comment

Choose a reason for hiding this comment

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

Great work @brunoffranca. Thanks.

@brunoffranca
Copy link
Member Author

@pompon0 I don't see a way of creating a point outside the correct subgroup. If I think of anything meanwhile, I'll add it.

@brunoffranca brunoffranca changed the title Adds validity checks to BLS public keys. Adds validity checks to BLS public keys Mar 26, 2024
@brunoffranca
Copy link
Member Author

brunoffranca commented Mar 26, 2024

So, there was a fatal flaw in the subgroup check. To check that a given point is in the correct subgroup, we don't multiply by the cofactor, we multiply by the order. I fixed that and found a way of testing it appropriately.
Another bug is that we were not doing the validity checks for aggregate signature verification. Also fixed it.
Finally, refactored it a bit to make it more readable.

@brunoffranca brunoffranca merged commit f35f2bc into main Mar 26, 2024
5 checks passed
@brunoffranca brunoffranca deleted the bf-bls-checks branch March 26, 2024 17:13
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.

4 participants