Hello,
I found following weird behavior in circom when working with the bn128 field prime.
template Example() {
var prime = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
log("prime = ", prime);
log("prime | 1 =", prime | 1);
log("prime & 1 =", prime & 1);
}
/**
OUTPUT:
prime = 0
prime | 1 = 0
prime & 1 = 1
*/
It seems that the modulo is only applied after the | and & evaluation.
By further playing around with the expressions, I found out that the modulo is only applied if assigned to a signal or used in an arithmetic expression. Following snippets yield expected results:
Hello, I found following weird behavior in circom when working with the
bn128
field prime.It seems that the modulo is only applied after the
|
and&
evaluation. By further playing around with the expressions, I found out that the modulo is only applied if assigned to a signal or used in an arithmetic expression. Following snippets yield expected results:Arithmetic Example:
Signal Example:
Finally, the modulo is not applied on conditional expressions if they are constant, but it is applied if the condition is a signal:
Conditional Example: