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

10 lines
No EOL
251 B
Text

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