Skip to content

perf(bn254): optimize affine pairing with doubleAndAdd#506

Merged
yelhousni merged 2 commits intomasterfrom
perf/affine-pairing
Jul 3, 2024
Merged

perf(bn254): optimize affine pairing with doubleAndAdd#506
yelhousni merged 2 commits intomasterfrom
perf/affine-pairing

Conversation

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

LGTM

@yelhousni yelhousni merged commit 5d8b5fa into master Jul 3, 2024
@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

type: consolidate strengthen an existing feature type: perf

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants