Created
May 19, 2020 11:18
-
-
Save jbaylina/3eb9f6593b305e9c66dd87622dd9855a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template Num2Bits5(n) { | |
signal input in; | |
signal output out[n]; | |
signal a[n]; | |
signal b[n]; | |
signal c[n]; | |
var lc = 0; | |
var r = in; | |
for (var i=0; i<n; i++) { | |
out[i] <-- r % 5; | |
lc += out[i]* 5**i; | |
// (x-4)(x-3)(x-2)(x-1)x === 0 | |
a[i] <== (out[i]-4)*(out[i]-3); | |
b[i] <== (out[i]-2)*(out[i]-1); | |
c[i] <== a[i]*b[i]; | |
c[i]*out[i] === 0; | |
r = r \ 5; | |
} | |
in === lc; | |
} | |
component main = Num2Bits5(6); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment