mirror of
https://github.com/arnaucube/circom.git
synced 2026-02-08 03:36:45 +01:00
Readme, License Fixes and another test added
This commit is contained in:
20
circuits/tobin.circom
Normal file
20
circuits/tobin.circom
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
|
||||
|
||||
template toBin(n) {
|
||||
signal input inp;
|
||||
signal output out[n];
|
||||
var lc1=0;
|
||||
|
||||
for (var i = 0; i<n; i++) {
|
||||
out[i] <-- (inp >> i) & 1;
|
||||
out[i] * (out[i] -1 ) === 0;
|
||||
lc1 += out[i] * 2**i;
|
||||
}
|
||||
|
||||
lc1 === inp;
|
||||
|
||||
}
|
||||
|
||||
|
||||
component toBin(3) main;
|
||||
Reference in New Issue
Block a user