I have the following block of code in golang
in the clear.
for i := 0; i < 10; i++ {
if val[i]>=0{
postcheck[i] = val[i]
bitpostcheck[i] = 1
} else {
postcheck[i] = 0
bitpostcheck[i] = 0
}
}
val[i]
can be a negative or positive integer in the clear.
I translated the above code into gnark
as follows:
for i := 0; i < 10; i++ {
postcheck[i] = api.Select(val[i], val[i], frontend.Variable(0))
bitpostcheck[i] = api.Select(val[i], frontend.Variable(1), frontend.Variable(0))
}
Here val
, postcheck and bitpostcheck are all [10]frontend.Variable.
But I am getting an assertIsBoolean error
, since in gnark
the first variable of Select
should be either 0
or 1
but val[i]
can basically be any unsigned integer.
Since gnark
only deals with unsigned integers, negative integers are represented as huge positive numbers like this in gnark
.
Given all this information, how do I implement the golang
clear code in gnark
? basically the check val[i]>=0
?