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: conditional check in non-native IsZero for applying optimization #1145

Merged
merged 3 commits into from
Jul 18, 2024

Conversation

ivokub
Copy link
Collaborator

@ivokub ivokub commented May 27, 2024

Description

In non-native IsZero check we previously checked that every limb is zero, then multiplied the results and returned it. However, as the limbs are significantly smaller than the native field, then we can use the optimization that we add the limbs and perform only a single IsZero check.

However, the optimization we had implemented checks the condition wrong way. This prevents the optimized path to be taken.

This could lead to a underconstrained circuit in extreme cases which are not possible with the emulated parameters defined in gnark (number of limbs has to be greater than the maximal allowed overflow. This means having approximately 190 limbs, but in our parameters the maximum number of limbs is 64).

Type of change

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

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 May 27, 2024
@ivokub ivokub self-assigned this May 27, 2024
@ivokub ivokub requested a review from gbotrel July 18, 2024 20:47
@ivokub ivokub merged commit d738f08 into master Jul 18, 2024
7 checks passed
@ivokub ivokub deleted the fix/nonnative-iszero-optim branch July 18, 2024 21:22
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