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

11 lines
254 B
Plaintext

from "EMBED" import u64_to_bits;
def main(u64 i) -> field {
bool[64] bits = u64_to_bits(i);
field mut res = 0;
for u32 j in 0..64 {
u32 exponent = 64 - j - 1;
res = res + (bits[j] ? 2 ** exponent : 0);
}
return res;
}