Skip to content

perf: subgroup check#557

Merged
yelhousni merged 2 commits intomasterfrom
perf/subgroup-check
Oct 28, 2024
Merged

perf: subgroup check#557
yelhousni merged 2 commits intomasterfrom
perf/subgroup-check

Conversation

@yelhousni
Copy link
Copy Markdown
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 this to the v0.10.0 milestone Oct 28, 2024
@yelhousni yelhousni merged commit 37b2cbd into master Oct 28, 2024
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants