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

perf: optimize class equivalence check for BLS12 final exp #1207

Merged
merged 15 commits into from
Jul 29, 2024

Conversation

yelhousni
Copy link
Contributor

@yelhousni yelhousni commented Jul 17, 2024

Description

Instead of applying Th.1 of https://eprint.iacr.org/2024/640.pdf naively as in #1173 ans #1202 we can scale the miller loop result by some factors:

  • for BLS12-381 by 27th root and p-th root where p=(1-u)/3
  • for BLS12-377 by p'-th root where p'=12(u-1)

and use the optimal exponent q-u instead of r. This is based on a personal communication (and a lot of help) from Andrija Novakovic @akinovak: https://gist.github.com/akinovak/0db531d350b95ccec682666b2257db77

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

pairing tests pass.

How has this been benchmarked?

  • BLS12-381:
    This PR saves 3,369,246 scs for a PairingCheck.
  • BLS12-377:
    This PR saves 21,989 scs in the PairingCheck and in the PLONK native aggregation circuit.

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@yelhousni yelhousni marked this pull request as draft July 17, 2024 15:02
@yelhousni yelhousni changed the title Perf/eliminate final exp bls perf: optimize class equivalence check for BLS12-381 final exp Jul 17, 2024
@yelhousni yelhousni changed the title perf: optimize class equivalence check for BLS12-381 final exp perf: optimize class equivalence check for BLS12 final exp Jul 18, 2024
@yelhousni yelhousni self-assigned this Jul 18, 2024
@yelhousni yelhousni added the perf label Jul 18, 2024
@yelhousni yelhousni added this to the v0.9.0 milestone Jul 18, 2024
@yelhousni yelhousni marked this pull request as ready for review July 18, 2024 16:33
Copy link
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

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

LGTM

@yelhousni yelhousni requested a review from ivokub July 25, 2024 13:14
Copy link
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

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

Changes good. I only now noticed that in FinalExpCheck we have indicated that we return *E12, but always return nil. I think we can change the the function signature to indicate that.

And, now after #1209 is merged, maybe it would make sense to also have methods for other curves for returning the FinalExpCheck result? Long-term this allows us to amend the std/algebra/Pairing interface so that we can also prove that final exponentiation doesn't hold.

std/algebra/emulated/fields_bls12381/e12_pairing.go Outdated Show resolved Hide resolved
std/algebra/native/fields_bls12377/e12_pairing.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

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

Thanks!

@yelhousni yelhousni merged commit aa6efa4 into master Jul 29, 2024
7 checks passed
@yelhousni yelhousni deleted the perf/eliminate-finalExp-bls branch July 29, 2024 14:45
This was referenced Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants