1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00
ZoKrates/zokrates_stdlib/stdlib/utils/casts/u64_to_field.zok

10 lines
No EOL
257 B
Text

from "EMBED" import u64_to_bits
def main(u64 i) -> field:
bool[64] bits = u64_to_bits(i)
field res = 0
for u32 j in 0..64 do
u32 exponent = 64 - j - 1
res = res + if bits[j] then 2 ** exponent else 0 fi
endfor
return res