Index Mathematics Conjectures nbv lettuce Widgets

lattice_permutation

stdlib/dilithium/lattice/lattice_permutation.nbv only in the dilithium field

lattice_permutation(state)

The squeeze of the lattice sponge in the Dilithium field, BLAKE3 in place of a Poseidon permutation (dags LatticeBlake3): state is laid out as lattice_squeeze builds it, the output lanes, then the lattice state and the absorbed length. Those kappa + 1 elements are hashed as their little-endian bytes (FieldScalar::as_le_bytes, 3 per element) and the output lanes are filled with field_bit_width! - 1 bits each of the BLAKE3 output, least significant bit first. Returns lattice_t() elements, the rest zero.

Calls
fields/assert_dilithium, blake3/blake3, calloc, bits/from_bits, lattice/lattice_bits, dilithium/lattice/lattice_kappa, dilithium/lattice/lattice_output_len, dilithium/lattice/lattice_t, slice
Precompiles
assert_eq!, clone!, concat!, div_ceil!, field_bit_width!, len!, loop_flat_map!, wtns!
Used by
lattice/lattice_squeeze, typed/typed_bytes_lattice

Source

# The squeeze of the lattice sponge in the Dilithium field, BLAKE3 in place of a Poseidon
# permutation (dags LatticeBlake3): `state` is laid out as lattice_squeeze builds it, the
# output lanes, then the lattice state and the absorbed length. Those kappa + 1 elements are
# hashed as their little-endian bytes (`FieldScalar::as_le_bytes`, 3 per element) and the
# output lanes are filled with `field_bit_width! - 1` bits each of the BLAKE3 output, least
# significant bit first. Returns lattice_t() elements, the rest zero.
(state)

static _ = assert_dilithium()

static out_len = lattice_output_len()
static kappa = lattice_kappa()
static t = lattice_t()
static e = field_bit_width!
assert_eq! t, len! state
static pad = 8 * (div_ceil! e, 8) - e

let inputs = wtns! slice((clone! state), out_len, kappa + 1)
let bits = loop_flat_map! kappa + 1, i {
  concat! lattice_bits(inputs[i]), calloc(pad)
}
let hash = blake3(bits, out_len * (e - 1))
let out = loop_flat_map! out_len, i {
  from_bits(slice((clone! hash), (e - 1) * i, e - 1))
}
concat! out, calloc(t - out_len)