solutions/zokrates_prover/.zokrates/stdlib/utils/pack/bool/unpack.zok

12 lines
430 B
Plaintext
Raw Normal View History

2023-12-05 06:06:28 +00:00
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(N >= FIELD_SIZE_IN_BITS \
? bit_array_le(res, [...[false; N - FIELD_SIZE_IN_BITS], ...unpack_unchecked::<FIELD_SIZE_IN_BITS>(-1)]) \
: true);
return res;
}