lattice_expand
stdlib/lattice/lattice_expand.nbv
lattice_expand(seed, static len, static a_exp)
A challenge vector of len elements from one squeeze output seed (dags LatticeSponge::sample_vector): up to lattice_output_len elements are the seed itself, longer vectors are the counter mode expansion a_exp (bits(seed) || bits(i)), lattice_kappa elements per block i.
- Calls
lattice/lattice_bits_static,lattice/lattice_bits_vec,dilithium/lattice/lattice_kappa,dilithium/lattice/lattice_output_len,mat_vec_mul,slice_from_start- Precompiles
assert_eq!,clone!,concat!,div_ceil!,field_bit_width!,if_lt!,if_lte!,len!,loop_flat_map!- Used by
lattice/lattice_oraccle_sample_vec
Source
# A challenge vector of `len` elements from one squeeze output `seed` (dags
# LatticeSponge::sample_vector): up to `lattice_output_len` elements are the seed itself,
# longer vectors are the counter mode expansion `a_exp (bits(seed) || bits(i))`, `lattice_kappa`
# elements per block i.
(seed, static len, static a_exp)
static kappa = lattice_kappa()
static out_len = lattice_output_len()
static e = field_bit_width!
assert_eq! out_len, len! seed
assert_eq! kappa * e * (out_len + 1), len! a_exp
let mut out[len]
if_lte! len, out_len {
out = slice_from_start((clone! seed), len)
}
if_lt! out_len, len {
let seed_bits = lattice_bits_vec(clone! seed)
static blocks = div_ceil! len, kappa
let full = loop_flat_map! blocks, i {
mat_vec_mul((clone! a_exp), concat! (clone! seed_bits), lattice_bits_static(i))
}
out = slice_from_start(full, len)
}
out