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(bn254): optimize Miller loop #1254

Merged
merged 7 commits into from
Sep 3, 2024
Merged

perf(bn254): optimize Miller loop #1254

merged 7 commits into from
Sep 3, 2024

Conversation

yelhousni
Copy link
Contributor

Description

In non-native arithmetic subtractions are costlier than additions. In this PR we re-arrange some subs into adds.

Type of change

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

How has this been tested?

All pairing tests pass.

How has this been benchmarked?

This PR saves 22,462 scs in the ECPAIR precompile of size 4. The bigger the size the more it saves (given that new points are added to the multi-Miller loop).

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
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! One small comment about refactor only.

std/algebra/emulated/sw_bn254/pairing.go Outdated Show resolved Hide resolved
std/algebra/emulated/sw_bn254/pairing.go Outdated Show resolved Hide resolved
std/algebra/emulated/sw_bw6761/pairing.go Show resolved Hide resolved
@yelhousni yelhousni requested a review from ivokub August 22, 2024 15:15
Copy link
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.

Perfect! Thanks for addressing the comments.

@yelhousni yelhousni merged commit 1f7f38f into master Sep 3, 2024
7 checks passed
@yelhousni yelhousni deleted the perf/ML branch September 3, 2024 22:14
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