Expand description
xark-bits: word-level bit gadgets written entirely in the Field subset.
Single-element primitives (booleanity, to_bits/from_bits, and the boolean
AND/OR/XOR/NOT) now live as methods on xark::Field; this crate keeps
only the WORD-level layers ([Field; N] arrays), built on those methods.
Build with -Zalways-encode-mir so the compiler can read this crate’s MIR
across the crate boundary (the workspace .cargo/config.toml sets this).
Functions§
- add3
(a + b + c) mod 2^32— a three-input modular add done as a SINGLE 34-bit range-check instead of two chainedadd32s.- add32
- Modular addition mod 2^32.
- and32
- and64
- from_
bits64 - Recompose 64 little-endian bits into a field element (no gates).
- not32
- not64
- or32
- read_n
- Read the
t-th 32-bit word out of anN-word array (a constant-indexed copy ofarr[t]). - rotl64
- Rotate-left by
nbits (pure re-wiring, zero gates): in little-endian,out[i] = a[(i + 64 - (n % 64)) % 64]. This is Keccak’s rho rotation. - rotr32
- Rotate-right by
nbits (pure re-wiring, zero gates):out[i] = a[(i+n) % 32]. - rotr64
- Rotate-right by
nbits (pure re-wiring):out[i] = a[(i + n) % 64]. - sha256_
iv - The SHA-256 initialization vector (8 words), reused as the BLAKE2s/BLAKE3 chaining IV.
- shr32
- Shift-right by
nbits, zero-filling (pure re-wiring, zero gates):out[i] = a[i+n]fori+n < 32, else0. - to_
bits64 - Decompose
xinto its 64 little-endian bits (boolean-constrained + pinned). - xor32
- xor64