Skip to content

feat(glv): split scalar strict bounds #686

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

Closed
wants to merge 1 commit into from
Closed

Conversation

yelhousni
Copy link
Collaborator

@yelhousni yelhousni commented May 16, 2025

Description

We re-introduce the original SplitScalar() removed in #213 (now renamed SplitScalarStrict()). For gnark-crypto we continue to use the current SplitScalar() which replaces divisions by right-shifts but we need SplitScalarStrict() for gnark circuits.

Type of change

Please delete options that are not relevant.

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

How has this been tested?

TestSplitting in utils_test.go tests both SplitScalar() and SplitScalarStrict().

How has this been benchmarked?

goos: darwin
goarch: arm64
pkg: github.com/consensys/gnark-crypto/ecc
cpu: Apple M1
BenchmarkSplitting256
BenchmarkSplitting256-8                  4004929               253.8 ns/op
BenchmarkSplittingStrict256
BenchmarkSplittingStrict256-8            1352343               884.2 ns/op

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 May 16, 2025
@yelhousni yelhousni requested a review from ThomasPiellard May 16, 2025 15:26
@yelhousni yelhousni self-assigned this May 16, 2025
@feltroidprime
Copy link
Contributor

feltroidprime commented May 16, 2025

Nice, does this mean the 4 scalars will be i64 in the glv+fakeglv method instead of ~i73 ?

@yelhousni
Copy link
Collaborator Author

Nice, does this mean the 4 scalars will be i64 in the glv+fakeglv method instead of ~i73 ?

unfortunately not. but we can probably save 1 bit.

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.

Looks good. But I'd add randomized testing for better coverage.

@@ -78,7 +78,7 @@ func TestNafDecomposition(t *testing.T) {
func TestSplitting(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we maybe run the test in gopter? Imo having a test with hardcoded values isn't that useful?

@yelhousni yelhousni closed this Jun 12, 2025
@yelhousni yelhousni reopened this Jun 12, 2025
@yelhousni yelhousni closed this Jun 12, 2025
@yelhousni yelhousni deleted the glv/scalar-split branch June 12, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants