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

Cache public key group membership status #4075

Merged
merged 2 commits into from
Jun 11, 2021

Conversation

benjaminion
Copy link
Contributor

@benjaminion benjaminion commented Jun 10, 2021

PR Description

Group membership checks for elliptic curve points (public keys and signatures) are very expensive and we want to do them as little as possible, ideally checking each point we use in verification exactly once.

When aggregating public keys using Blst's blst.P1.aggregate() method, the keys' group membership is always checked, even if it was checked previously. With this PR, we lazily check a public key's group membership and cache the result. We can then avoid the repeated group membership checks by using blst.P1.add() instead of aggregate().

Remarks:

  • This only helps if BLSPublicKey objects are well-cached and not created anew: we lose the cached group check status in that case.
  • By design, the aggregated public key will be in the group. Nevertheless Blst's core_verify() still checks group membership of the aggregated key. Not a lot we can do about that.
  • As for signatures, we don't expect to be seeing the same signature time and time again, so there is likely little to be gained by applying the group membership caching to signatures.

Fixed Issue(s)

Closes #4032

Documentation

  • I thought about documentation and added the documentation label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

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

LGTM.

@benjaminion benjaminion merged commit 8c6a18e into Consensys:master Jun 11, 2021
@benjaminion benjaminion deleted the bls-cache-group-check branch June 11, 2021 06:50
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.

Lazily evaluate and cache the group membership status for public keys and signatures
2 participants