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

Mod Builtin Constraints #1835

Closed
JulianGCalderon opened this issue Sep 9, 2024 · 1 comment · Fixed by #1841
Closed

Mod Builtin Constraints #1835

JulianGCalderon opened this issue Sep 9, 2024 · 1 comment · Fixed by #1841
Labels
bug Something isn't working

Comments

@JulianGCalderon
Copy link
Contributor

Right now, modulo builtin constraints are not always fulfilled.

  • Given a sub mod gate (for example: x3 = x2 - x1), then it must always be true that x3 + x1 - x2 = 0 or p.

Take, for example, x2 = p + 1 and x1 = 1. Our current implementation will calculate x3 = 0 as a result of the operation (x2 - x1) % p. The expected output is p, as it's the minimum value that meets the constraint (p + 1 - (p + 1) = 0). (the other possible value is 2p.

See starkware-libs/cairo-lang#196 and cairo-lang implementation as reference.

@JulianGCalderon JulianGCalderon added the bug Something isn't working label Sep 9, 2024
@JulianGCalderon
Copy link
Contributor Author

Although I haven't verified it, we may have similar bugs in the mul mod builtin implementation.

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 a pull request may close this issue.

1 participant