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

11 lines
254 B
Plaintext
Raw Permalink Normal View History

2023-12-05 06:06:28 +00:00
from "EMBED" import u32_to_bits;
def main(u32 i) -> field {
bool[32] bits = u32_to_bits(i);
field mut res = 0;
for u32 j in 0..32 {
u32 exponent = 32 - j - 1;
res = res + (bits[j] ? 2 ** exponent : 0);
}
return res;
}