Index Mathematics Conjectures nbv lettuce Widgets

field_bit_width!

The number of bits needed to represent any element of the field, as a static scalar. Integer and field arithmetic

field_bit_width!

Returns floor(log2(p)) + 1 for the field the program is compiled in: 32 for milli, 61 for Mersenne61, 23 for the dilithium field. Use it to write gadgets that work in several fields.

Arguments

None. It is written without arguments: field_bit_width!.

Returns

A static scalar. field_bit_width! is an expression.

Constraints

None.

Example

(let x)
static width = field_bit_width!
let w = width
w

Notes

It can be used directly in arithmetic and as a precompile argument: static n = field_bit_width! - 2, assert_lt! 22, field_bit_width!. to_bits uses it to decompose an element into all of its bits.

Used in the standard library

bits/to_bits, dilithium/lattice/lattice_permutation, lattice/lattice_absorb, lattice/lattice_assert_canonical, lattice/lattice_bits, lattice/lattice_bits_static, lattice/lattice_digest, lattice/lattice_expand, mldsa/mldsa44_parse_sig, mldsa/mldsa_hint_unpack, mldsa/mldsa_rej_ntt_poly, mldsa/mldsa_sample_in_ball, mldsa/mldsa_use_hint, oraccle/oraccle_sample_ternary_vec, slip/slip_r1cs_arg_verify, typed/typed_bytes_lattice, typed/typed_lattice_digest_bits