iden3/circom

"\" operator causes downstream verification failure despite witness+proof generation success

nanaknihal opened this issue · 2 comments

using circom compiler 2.1.2
code to replicate:

git pull https://github.com/nanaknihal/quotient-circom-replication.git
cd quotient-circom-replication
sh test.sh

Witness + proof generation succeeds, but verification fails. The witness and proof are generated without error, so this failure shouldn't happen.

However, when you change main.circom by replacing line signal y <== x \ 30; to signal y <== x / 30; verification succeeds.

main.circom for reference:

include "./node_modules/circomlib/circuits/bitify.circom";

template ReplicateBug() {
    signal input x;
    // This line works:
    // signal y <== x / 30;
    // Replacing it with this means it works for witness+proof generation but causes proof verification failure
    signal y <== x \ 30;
    component asBits = Num2Bits(254);
    asBits.in <== y;
    
}

component main { public [x] } = ReplicateBug();

There was a bug with the handling of integer division "\" with constants in some cases. That was fixed in the release 2.1.3. Please, update your version (the current one is 2.1.5) and check it.

Thanks, that worked