Module halo2_gadgets::utilities
source · Expand description
Utility gadgets.
Modules
- Gadget and chip for a conditional swap utility.
- Decomposes an $n$-bit field element $\alpha$ into $W$ windows, each window being a $K$-bit word, using a running sum $z$. We constrain $K \leq 3$ for this helper. $$\alpha = k_0 + (2^K) k_1 + (2^{2K}) k_2 + … + (2^{(W-1)K}) k_{W-1}$$
- Make use of a K-bit lookup table to decompose a field element into K-bit words.
Structs
- A type representing a range-constrained field element.
Traits
- A type that has a value at either keygen or proving time.
- Trait for utilities used across circuits.
- Trait for a variable in the circuit.
Functions
- Takes a specified subsequence of the little-endian bit representation of a field element. The bits are numbered from 0 for the LSB.
- Checks that an expression is either 1 or 0.
- Decompose a word
alpha
intowindow_num_bits
bits (little-endian) For a window size ofw
, this returns [k_0, …, k_n] where eachk_i
is aw
-bit value, andscalar = k_0 + k_1 * w + k_n * w^n
. - The sequence of bits representing a u64 in little-endian order.
- The u64 integer represented by an L-bit little-endian bitstring.
- Check that an expression is in the small range [0..range), i.e. 0 ≤ word < range.
- If
a
thenb
, elsec
. Returns (a * b) + (1 - a) * c.