Skip to content

perf(bls12-381): eliminate finalexp ~naively#1173

Merged
yelhousni merged 2 commits intomasterfrom
perf/eliminate-finalExp-bls12381
Jul 3, 2024
Merged

perf(bls12-381): eliminate finalexp ~naively#1173
yelhousni merged 2 commits intomasterfrom
perf/eliminate-finalExp-bls12381

Conversation

@yelhousni
Copy link
Copy Markdown
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 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
Copy Markdown
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
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants