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: fix OR computation in case one input is constant and other variable #1181

Merged
merged 2 commits into from
Jul 11, 2024

Conversation

ivokub
Copy link
Collaborator

@ivokub ivokub commented Jun 27, 2024

Description

See the added regression tests. If we had

api.Or(x, 1)

then the result was incorrectly computed for both x=0 and x=1. This was because we used a*(1-b) for computation not a+b-ab for OR. Furthermore, if we know that one input is constant then we do not have to add constraints as the result is always constant 1 if constant input is 1 and x if constant input is 0.

Reported by @wuestholz using gnark fuzzer. Thanks!

Type of change

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

How has this been tested?

  • TestRegressionOr

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 self-assigned this Jun 27, 2024
@ivokub ivokub added bug Something isn't working fuzzing Issue found using a fuzzing tool labels Jun 27, 2024
Copy link
Collaborator

@gbotrel gbotrel left a comment

Choose a reason for hiding this comment

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

lgtm

@gbotrel gbotrel merged commit 111a078 into master Jul 11, 2024
7 checks passed
@gbotrel gbotrel deleted the fix/plonk-or branch July 11, 2024 09: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 fuzzing Issue found using a fuzzing tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants