2020-01-22 19:35:31 +03:00
|
|
|
template Num2Bits(n) {
|
|
|
|
signal input in;
|
2020-04-27 14:22:31 +03:00
|
|
|
signal intermediate[n];
|
2020-01-22 19:35:31 +03:00
|
|
|
signal output out[n];
|
|
|
|
var lc1=0;
|
|
|
|
|
|
|
|
for (var i = 0; i<n; i++) {
|
|
|
|
out[i] <-- (in >> i) & 1;
|
|
|
|
out[i] * (out[i] -1 ) === 0;
|
2020-04-27 14:22:31 +03:00
|
|
|
intermediate[i] <== out[i] * out[i];
|
2020-01-22 19:35:31 +03:00
|
|
|
lc1 += out[i] * 2**i;
|
|
|
|
}
|
|
|
|
|
|
|
|
lc1 === in;
|
|
|
|
}
|
|
|
|
|
2020-04-27 14:22:31 +03:00
|
|
|
component main = Num2Bits(253);
|