1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00
ZoKrates/zokrates_stdlib/stdlib/utils/multiplexer/lookup3bitSigned.zok
2022-05-11 21:33:57 +02:00

9 lines
No EOL
321 B
Text

import "./lookup2bit" as lookup;
// Three-bit window lookup (2bits + signature bit) in 2bit table
// using two constraints. Maps the bits `b` to a list of constants `c`
def main(bool[3] b, field[4] c) -> field {
field alpha = lookup([b[0], b[1]], c);
field out = alpha - 2 * (b[2] ? alpha : 0);
return out;
}