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(bls12-381): eliminate finalexp ~naively #1173

Merged
merged 2 commits into from
Jul 3, 2024

Conversation

yelhousni
Copy link
Contributor

@yelhousni yelhousni commented Jun 14, 2024

Description

Applying https://eprint.iacr.org/2024/640.pdf as in #1143 and #1155 for BLS12-381 doesn't work (#1143 (comment)). Alternatively we can apply theorem 1 of that paper to check f == c^r instead. @feltroidprime suggested to check instead that f^k == c^(q-u) where k=(u-1)^2/3 using a Frobenius map and 2 optimized addition chains. This PR implements their idea after pushing f to the cyclotomic subgroup. The exponentiation are done then using Granger--Scott algorithm.

TODO:

  • use Karabina12345 instead of Granger--Scott.
  • include c^(-u) in the the Miller loop computation.
  • do both

Type of change

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

How has this been tested?

The existing TestPairingCheckTestSolve works for this.

How has this been benchmarked?

This PR saves 681,769 scs or 199,105 R1CS in a BLS12-381 pairing.

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 June 14, 2024 12:42
@yelhousni yelhousni self-assigned this Jun 14, 2024
@yelhousni yelhousni added the perf label Jun 14, 2024
@yelhousni yelhousni added this to the v0.10.0 milestone Jun 14, 2024
@yelhousni yelhousni marked this pull request as ready for review June 14, 2024 16:01
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.

I don't get the math, but the implementation looks good :)

@yelhousni yelhousni merged commit 2b49686 into master Jul 3, 2024
7 checks passed
@yelhousni yelhousni deleted the perf/eliminate-finalExp-bls12381 branch July 3, 2024 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants