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: NNA quotient length computation edge cases #1340

Merged
merged 6 commits into from
Dec 11, 2024
Merged

Conversation

ivokub
Copy link
Collaborator

@ivokub ivokub commented Dec 9, 2024

Description

This PR fixes edge cases when computing the quotient length. We compute the product length in bits and then to get the quotient length, we subtract the modulus length. But as we work over uints then if the product length is less than the modulus (for example when inputs are short, on one limb), then we get underflow which due to rolling over leads to allocating huge slices. This crashes the prover.

Also fixed a potential edge case in carry computation.

Type of change

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

How has this been tested?

Tested with #1339

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 Dec 9, 2024
@ivokub ivokub added this to the v0.11.N milestone Dec 9, 2024
@ivokub ivokub requested a review from yelhousni December 9, 2024 23:52
@ivokub ivokub self-assigned this Dec 9, 2024
Copy link
Contributor

@yelhousni yelhousni left a comment

Choose a reason for hiding this comment

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

That makes sense 👍 and I confirm it solves the problem I encountered in #1339.

@ivokub ivokub merged commit 1814e60 into master Dec 11, 2024
5 checks passed
@ivokub ivokub deleted the fix/nna-zero-quo branch December 11, 2024 18:47
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.

2 participants