solutions/zokrates_prover/.zokrates/stdlib/utils/pack/bool/pack.zok

9 lines
181 B
Plaintext
Raw Permalink Normal View History

2023-12-05 06:06:28 +00:00
def main<N>(bool[N] bits) -> field {
field mut out = 0;
for u32 j in 0..N {
u32 i = N - (j + 1);
out = out + (bits[i] ? 2 ** j : 0);
}
return out;
}