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(bn254): optimize affine pairing with doubleAndAdd #506

Merged
merged 2 commits into from
Jul 3, 2024

Conversation

yelhousni
Copy link
Collaborator

@yelhousni yelhousni commented Jun 5, 2024

Description

In affine pairing (MillerLoopFixedQ), use doubleAndAdd to compute 2P+Q as of P+Q+P. This optimizes the one-time line precomputation for KZG in gnark-crypto, but most importantly matches gnark in-circuit implementation. This is now important since after Consensys/gnark#1143 we need to have the exact same lines so that the witness residue is the same.

Type of change

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

How has this been tested?

pairing tests pass.

How has this been benchmarked?

In gnark-crypto, only the lines precompuation should be affected (faster) but it's just a one-time computation.

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

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 merged commit 5d8b5fa into master Jul 3, 2024
7 checks passed
@yelhousni yelhousni deleted the perf/affine-pairing branch July 3, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consolidate strengthen an existing feature perf
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants