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 Field(number) in snarkyjs #10960

Closed
mitschabaude opened this issue May 14, 2022 · 1 comment · Fixed by #11053
Closed

Fix Field(number) in snarkyjs #10960

mitschabaude opened this issue May 14, 2022 · 1 comment · Fixed by #11053

Comments

@mitschabaude
Copy link
Member

mitschabaude commented May 14, 2022

Behaves wrong when number is an integer outside the int32 range. Demonstration:

Welcome to Node.js v17.7.2.
Type ".help" for more information.
> let {Field} = require('snarkyjs');
undefined
> let MAX_UINT32 = 2**31 - 1
undefined
> MAX_UINT32
2147483647
> Field(MAX_UINT32).toString()
'2147483647'
> Field(MAX_UINT32 + 1).toString()
'28948022309329048855892746252171976963363056481941560715936230020278405562369'
> 

I believe the error is caused by int32 coercion happening in Ocaml, when converting float to int in this line:

let value = Float.to_int value in

@mitschabaude
Copy link
Member Author

closing since it's already merged into snarkyjs

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

Successfully merging a pull request may close this issue.

1 participant