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: variable modulus subtraction padding #1200

Merged
merged 5 commits into from
Jul 24, 2024
Merged

fix: variable modulus subtraction padding #1200

merged 5 commits into from
Jul 24, 2024

Conversation

ivokub
Copy link
Collaborator

@ivokub ivokub commented Jul 15, 2024

Description

This PR fixes some of the methods used in testing the variable modulus case in field emulation:

  • correctly set the next overflow
  • assert that the subtraction padding is big enough
  • check that the next overflow wouldn't the native field

We currently only panic when the next overflow would overflow the native field, in contrast to the behaviour with fixed emulated modulus where we then would mod-reduce the value automatically. As modSub is not directly exposed and used in equality assertion (which is then only used in tests), then it should be sufficient for now.

Fixes #1152

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How has this been tested?

Existing tests pass.

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

@ivokub ivokub added the bug Something isn't working label Jul 15, 2024
@ivokub ivokub requested a review from gbotrel July 15, 2024 12:45
@ivokub ivokub self-assigned this Jul 15, 2024
@ivokub ivokub changed the title Fix/modsub padding fix: variable modulus subtraction padding Jul 15, 2024
std/math/emulated/hints.go Outdated Show resolved Hide resolved
@gbotrel gbotrel self-requested a review July 24, 2024 00:26
@ivokub ivokub merged commit c36ff9e into master Jul 24, 2024
7 checks passed
@ivokub ivokub deleted the fix/modsub-padding branch July 24, 2024 06:31
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.

bug: subtraction padding in variable-modulus non-native arithmetic does not enforce underflow protection
2 participants