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: non-native zero IsZero edge case #1413

Merged
merged 4 commits into from
Feb 7, 2025
Merged

fix: non-native zero IsZero edge case #1413

merged 4 commits into from
Feb 7, 2025

Conversation

ivokub
Copy link
Collaborator

@ivokub ivokub commented Feb 6, 2025

Description

When the compiler can deduce that non-native element is constant zero, then we represent it on zero limbs. However in IsZero method we initialized the accumulator from first limb without range checking. This PR adds fast path for constant zero.

Fixes #1412

Type of change

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

How has this been tested?

  • Improved IsZeroCircuit test to include the regression

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 Feb 6, 2025
@ivokub ivokub added this to the v0.13.0 milestone Feb 6, 2025
@ivokub ivokub requested a review from yelhousni February 6, 2025 09:37
@ivokub ivokub self-assigned this Feb 6, 2025
@weijiguo
Copy link

weijiguo commented Feb 6, 2025

I have applied the commits and our issues are resolved. Nice job!

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. Fast paths for Div and Sqrt are already implemented in field_ops.go (though the comment here should be when multiplying by 0?).

@ivokub
Copy link
Collaborator Author

ivokub commented Feb 7, 2025

That makes sense. Fast paths for Div and Sqrt are already implemented in field_ops.go (though the comment here should be when multiplying by 0?).

Thanks - changed the comment from "divide by 0" to "divide 0".

@ivokub ivokub merged commit 9c3aee0 into master Feb 7, 2025
5 checks passed
@ivokub ivokub deleted the fix/iszero-zero-limbs branch February 7, 2025 14:41
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: Field not working as expected after recent optimization
3 participants