Closed vck3000 closed 2 years ago
Thanks @vck3000 for the feedback.
I have traced the bug down to the way constraint system builder handles constants. The way select
works is by computing (1-b) * x + b * y
. If all of the inputs were constants, then no constraints are recorded in the constraint system and the value was computed directly. However the computed constant value was not reduced by the modulus of the scalars and the returned value corresponded to 2 + Fr
(instead of just 2
) and thus the binary decomposition was unexpected. In computations this shouldn't have made a difference as 2 + Fr == 2 (mod Fr)
.
I have proposed a fix for that and hopefully it lands soon in develop and then in v.0.5.3
.
Hi @ivokub,
Thanks for the speedy reply, fix, and explanations. Appreciate your efforts!
Hi there,
I'm having some issues with reliability in my circuits. I've narrowed it down to some unexpected behaviour in
api.Select()
andapi.ToBinary()
.Here's the minimal reproducible code for the issue:
The output of the above code is: (Please scroll right to see the other unexpected
1
bits set)For some reason, when
api.Select()
takes the 1st option (i.e. the first argument is1
), any subsequentapi.ToBinary()
will result in weird outputs. However, whenapi.Select()
takes the 2nd option, the subsequentapi.ToBinary()
calls are as expected.My
go.mod
file looks like:Any ideas on what is causing this or how I could get around this?