Skip to main content

Crate xark_bits

Crate xark_bits 

Source
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 chained add32s.
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 an N-word array (a constant-indexed copy of arr[t]).
rotl64
Rotate-left by n bits (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 n bits (pure re-wiring, zero gates): out[i] = a[(i+n) % 32].
rotr64
Rotate-right by n bits (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 n bits, zero-filling (pure re-wiring, zero gates): out[i] = a[i+n] for i+n < 32, else 0.
to_bits64
Decompose x into its 64 little-endian bits (boolean-constrained + pinned).
xor32
xor64