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

Optimize Miller loop on fixed pubkeys - expected 37% perf boost #507

Closed
kchalkias opened this issue Mar 15, 2023 · 2 comments
Closed

Optimize Miller loop on fixed pubkeys - expected 37% perf boost #507

kchalkias opened this issue Mar 15, 2023 · 2 comments
Assignees

Comments

@kchalkias
Copy link
Collaborator

kchalkias commented Mar 15, 2023

If any of the G1, G2 arguments in the pairing are fixed(ie the public key is static or a constant parameter in the
system) we can have up to 37% faster Miller loop.
Typically BLST is doing that for the generator G, but in consensus systems where validator keys are fixed per epoch, we might be able to precompute stuff:

  • useful when verifying individual sigs (precompute one part of pairing Miller loop based on individual validator keys)
  • useful even on batch verification - precompute some known combinations (ie against the aggregated pubKey of most dominant validators

We could build that via some LRU on common validator combinations.
FYI @benr-ml who is working on unfolding BLS batch verification for a different purpose.

Related paper: https://eprint.iacr.org/2010/342

@kchalkias kchalkias changed the title Optimize pairing Miller loop on known arguments (ie fixed pubkeys) Optimize Miller loop on known arguments (ie fixed pubkeys) expected 37% boost Mar 15, 2023
@kchalkias kchalkias changed the title Optimize Miller loop on known arguments (ie fixed pubkeys) expected 37% boost Optimize Miller loop on fixed pubkeys - expected 37% perf boost Mar 15, 2023
@benr-ml
Copy link
Contributor

benr-ml commented May 12, 2023

It won't help us too much in case of individual signatures, since we rarely verify those.
As for batch verification - let's first collect some statistics on whether we see common sets of public keys.

@jonas-lj
Copy link
Contributor

jonas-lj commented May 30, 2023

I took a closer look at the BLST api, and it only allows pre computation for the right operand, aka the input element from G2, so it won't help us with fixed public keys in min_sig mode, and, as you say @kchalkias, blst already seems to do the pre computation for the G2 generator.

For future reference, the code to do this is on the https://github.com/MystenLabs/fastcrypto/tree/pairing_precomputation branch, and gives an 13% speed-up compared to an ordinary pairing.

@jonas-lj jonas-lj closed this as completed Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants