iden3/circom

Different Results for Complement Bitwise Operator

LukiMueller opened this issue · 1 comments

Greetings circom devs,

I found an interesting behavior regarding the bit-wise complement operator ~.
The following minimal example has different results for output a and b.

// circuit.circom

template T() {
    signal output a;
    signal output b;

    signal temporary_signal;
    temporary_signal <-- 1;

    a <-- (~temporary_signal);
    b <-- (~1);
    
    log("a:", a);
    log("b:", b);
}

component main = T();

I compiled with circom --wasm --c circuit.circom on the currently newest version v2.1.9.
Both witness generators produce following output:

a: 7059779437489773633646340506914701874769131765994106666166191815402473914365
b: 6350874878119819312338956282401532410528162663560392320966563075034087161849

Shouldn't the output signals be equal or am I missing something?
The documentation does not say anything about different behaviors for the ~-operator regarding constants or signals.
Is this a bug in the compiler?

Additionally, the CPP generator seems to print the log-statements twice on this instance. At least for me the logs appear two times in the console.