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

Unexpected Result When Dividing Field Elements #1337

Closed
silvesterdrago opened this issue Aug 11, 2023 · 1 comment
Closed

Unexpected Result When Dividing Field Elements #1337

silvesterdrago opened this issue Aug 11, 2023 · 1 comment

Comments

@silvesterdrago
Copy link

silvesterdrago commented Aug 11, 2023

Description:
When dividing certain field elements the result is unexpected. Specifically, dividing 11 by 10 yields a large field element instead of the expected 1 or its equivalent representation in the field.

Code to Reproduce:

field x = 11;
field y = x / 10;
assert(y == 15321770010287492655572484021680092561983855080291224040588742930603065946933);

Expected Behavior:
The division of 11 by 10 should result in 1 or its equivalent representation in the field.

Actual Behavior:
The division results in the field element 15321770010287492655572484021680092561983855080291224040588742930603065946933.

Version:
ZoKrates 0.8.7

@dark64
Copy link
Member

dark64 commented Aug 11, 2023

This behavior is correct, division is defined as multiplication by the inverse modulo p. What you want is integer division, this is being added in #1349

@Schaeff Schaeff closed this as completed Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants