solutions/zokrates_prover/.zokrates/stdlib/utils/pack/u32/pack256.zok

20 lines
627 B
Plaintext
Executable File

import "../../casts/u32_to_bits";
import "../bool/pack256";
// pack 256 big-endian bits into one field element
// Note: This is not a injective operation as `p` is smaller than `2**256 - 1 for bn128
// For example, `[0, 0,..., 0]` and `bits(p)` both point to `0`
def main(u32[8] input) -> field {
bool[256] bits = [
...u32_to_bits(input[0]),
...u32_to_bits(input[1]),
...u32_to_bits(input[2]),
...u32_to_bits(input[3]),
...u32_to_bits(input[4]),
...u32_to_bits(input[5]),
...u32_to_bits(input[6]),
...u32_to_bits(input[7])
];
return pack256(bits);
}