12 lines
No EOL
404 B
Text
12 lines
No EOL
404 B
Text
import "./unpack_unchecked.zok"
|
|
from "field" import FIELD_SIZE_IN_BITS
|
|
from "EMBED" import bit_array_le
|
|
|
|
// Unpack a field element as N big endian bits
|
|
def main<N>(field i) -> bool[N]:
|
|
|
|
bool[N] res = unpack_unchecked(i)
|
|
|
|
assert(if N >= FIELD_SIZE_IN_BITS then bit_array_le(res, [...[false; N - FIELD_SIZE_IN_BITS], ...unpack_unchecked::<FIELD_SIZE_IN_BITS>(-1)]) else true fi)
|
|
|
|
return res |