You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

43 lines
638 B

template AND() {
signal input a;
signal input b;
signal output c;
c <== a*b;
}
template AND3() {
signal input in1;
signal input in2;
signal input in3;
signal output out;
component and1 = AND();
component and2 = AND();
in1 ==> and1.a;
in2 ==> and1.b;
in3 ==> and2.a;
and1.c ==> and2.b;
and2.c ==> out;
}
template ToBin() {
signal input in;
signal output out[32];
var lc = 0;
for (var i=0; i<32; i++) {
out[i] <-- (in >> i) & 1;
lc = lc + out[i] * 2**i;
out[i]*(out[i]-1) === 0;
}
lc === in;
}
component main = ToBin();