solutions/zokrates_prover/.zokrates/stdlib/utils/casts/bool_array_to_u32_array.zok

15 lines
365 B
Plaintext
Executable File

from "EMBED" import u32_from_bits;
// convert an array of bool to an array of u32
// the sizes must match (one u32 for 32 bool) otherwise an error will happen
def main<N, P>(bool[N] bits) -> u32[P] {
assert(N == 32 * P);
u32[P] mut res = [0; P];
for u32 i in 0..P {
res[i] = u32_from_bits(bits[32 * i..32 * (i + 1)]);
}
return res;
}