Closed okwme closed 11 months ago
Hi, thank you for reporting!
Circom compiler allows the use of negative inputs in the json file since version 2.1.1.
I could recreate the issue using previous versions, but for any version >=v2.1.1 the behavior is the expected:
a 21888242871839275222246405745257275088548364400416034343698204186575808495616
p_minus_one 21888242871839275222246405745257275088548364400416034343698204186575808495616
Thank you for reporting the issue :-)
Thank you for the reply @clararod9!
zkrepl shows version 2.1.4 being used and the error still occurs. That makes me think it must be an issue on the webapp instead of with circom. Thank you for confirming expected behavior at the circom level!
Reposting this from https://github.com/0xPARC/zkrepl/issues/11 in case it's not a zkrepl issue but a circom issue:
I have been grappling with handling negative numbers in circom and came across this issue. As I understand it circom divides the finite field so that negative numbers span
p / 2
andp - 1
. When confirming some of this behaviour in zkrepl I saw unexpected results for negative input values:https://zkrepl.dev/?gist=c9691b5e248e1b080cc6ea0c532b5c38
The resulting log is:
and the compilation fails on
assert(-1 == a);
Is this expected behaviour?