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

Fix: Bandersnatch GLV scalar multiplication #1271

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

yelhousni
Copy link
Contributor

@yelhousni yelhousni commented Sep 6, 2024

Description

Fixes #268

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How has this been tested?

TestCurve for Bandersnatch pass when using scalarMulGLV.

How has this been benchmarked?

Bandersnatch in R1CS:
2-bit windowed double-and-add: 3,314
GLV: 2,735
Bandersnatch in SCS:
2-bit windowed double-and-add: 5,991
GLV: 6,077

So the GLV saves 579 r1cs but adds 86 scs, which is because of the non-native scalar decomposition check. In this PR we use GLV only if endomorphism + R1CS.

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 marked this pull request as draft September 6, 2024 00:07
@yelhousni yelhousni marked this pull request as ready for review September 6, 2024 15:00
@yelhousni yelhousni self-assigned this Sep 6, 2024
@yelhousni yelhousni added the bug Something isn't working label Sep 6, 2024
@yelhousni yelhousni added this to the v0.9.0 milestone Sep 6, 2024
Copy link
Collaborator

@gbotrel gbotrel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A remark, that probably applies to other neighbor pacakges;

I checked the call graph to see how it is tested, and it seems we just test with testData --> with random scalars.

Should we add some edge cases tests ? (i.e. scalar at 0, p-1, 1, ...),

@yelhousni
Copy link
Contributor Author

A remark, that probably applies to other neighbor pacakges;

I checked the call graph to see how it is tested, and it seems we just test with testData --> with random scalars.

Should we add some edge cases tests ? (i.e. scalar at 0, p-1, 1, ...),

Yes indeed we should test edge cases. We already do so for emulated and native SW packages. Here it should be easier because formulas are complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hinted scalar decomposition in a gadget
2 participants