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: optimize curve membership test #487

Merged
merged 3 commits into from
Feb 13, 2024
Merged

perf: optimize curve membership test #487

merged 3 commits into from
Feb 13, 2024

Conversation

yelhousni
Copy link
Collaborator

@yelhousni yelhousni commented Feb 13, 2024

Description

This PR optimizes the curve membership test IsOnCurve() for all curves on both G1 and G2, by:

  • saving 1 Fp mul
  • specializing the multiplication by the curve coefficient b

Type of change

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

How has this been tested?

Old TestG1AffineIsOnCurve and TestG2AffineIsOnCurve

How has this been benchmarked?

e.g. BLS12-381 on AWS z1d.large:

G1 335 ns vs. 190.6 ns
G2 624 ns vs. 495.3 ns

Compared to geth/kilic (cc @asanso, @MariusVanDerWijden):
G1 320.7 ns vs. 190.6 ns
G2 917.9 ns vs. 495.3 ns

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 this to the v0.10.0 milestone Feb 13, 2024
@yelhousni yelhousni requested a review from gbotrel February 13, 2024 22:00
@yelhousni yelhousni self-assigned this Feb 13, 2024
@yelhousni yelhousni requested a review from gbotrel February 13, 2024 22:39
@yelhousni yelhousni merged commit 5a54be6 into master Feb 13, 2024
7 checks passed
@yelhousni yelhousni deleted the perf/IsOnCurve branch February 13, 2024 22:51
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