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(ecc): optimize affine Add, Sub and Double #509

Merged
merged 3 commits into from
Jun 11, 2024

Conversation

yelhousni
Copy link
Collaborator

@yelhousni yelhousni commented Jun 11, 2024

Description

Currently for affine Add, Sub and Double, we convert both points to Jacobian coordinates and do the arithmetic there. Instead, in this PR, we convert only one point and do mixed arithmetic. Formulas for AddMixed are already implemented in gnark-crypto and here we add the implementation of DoubleMixed as per EFD.

Type of change

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

How has this been tested?

  • Added a test for 2*P == double(P) + P - P which checks all the Add, Sub and Double affine methods.

How has this been benchmarked?

e.g. BLS12-381 G1 and G2 additions on a M1 macbook Air:

benchmark                  old ns/op     new ns/op     delta
BenchmarkG1AffineAdd-8     4359          4207          -3.49%
BenchmarkG2AffineAdd-8     6195          5681          -8.30%

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 added the perf label Jun 11, 2024
@yelhousni yelhousni requested a review from gbotrel June 11, 2024 12:29
@yelhousni yelhousni self-assigned this Jun 11, 2024
@yelhousni yelhousni added this to the v0.10.0 milestone Jun 11, 2024
@yelhousni yelhousni merged commit 364bbce into master Jun 11, 2024
7 checks passed
@yelhousni yelhousni deleted the perf/affine-arithmetic branch June 11, 2024 15:19
@yelhousni yelhousni mentioned this pull request Jun 12, 2024
9 tasks
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