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: subgroup check #557

Merged
merged 2 commits into from
Oct 28, 2024
Merged

perf: subgroup check #557

merged 2 commits into from
Oct 28, 2024

Conversation

yelhousni
Copy link
Collaborator

Description

use mulWindowed instead of ScalarMultiplication is G1 and G2 subgroup membership and cofactor clearing methods.
1- The point is still purported to be in the prime subgroup where GLV applies
2- multiplying by a small constant is faster with mulWindowed

N.B.: multiplying e.g. twice by x0 is faster than multiplying by x0^2 because it has smaller Hamming weight. E.g. for BLS12-381, mul-by-x0 is 64 dbl + 6 mul while mul-by-x0^2 is 128 dbl + 17 mul. There is still room for improvement if needed by specialising mul-by-x0 using a short addition chain.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Same tests.

How has this been benchmarked?

  • BLS12-38
benchmark                        old ns/op     new ns/op     delta
BenchmarkG1JacIsInSubGroup-2     59891         46740         -21.96%
benchmark                        old ns/op     new ns/op     delta
BenchmarkG2JacIsInSubGroup-2     74121         55710          -24.84%
  • BN254
benchmark                        old ns/op     new ns/op     delta
BenchmarkG2JacIsInSubGroup-2     58285         48690        -16.46%
  • BW6-761
benchmark                        old ns/op     new ns/op     delta
BenchmarkG1JacIsInSubGroup-2     410121        322322        -21.41%
benchmark                        old ns/op     new ns/op     delta
BenchmarkG2JacIsInSubGroup-2     410955        322196        -21.60%

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 requested a review from gbotrel October 28, 2024 18:58
@yelhousni yelhousni self-assigned this Oct 28, 2024
@yelhousni yelhousni added the perf label Oct 28, 2024
@yelhousni yelhousni added this to the v0.10.0 milestone Oct 28, 2024
@yelhousni yelhousni merged commit 37b2cbd into master Oct 28, 2024
5 checks passed
@yelhousni yelhousni deleted the perf/subgroup-check branch October 28, 2024 19:58
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