wtns!
Materialize each element of an expression as its own witness entry. Constraints and witnesses
wtns! expr
Witness values are linear combinations of witness entries. Additions and multiplications by statics only grow these combinations, which is free until a combination is used in a constraint row, where every term costs. wtns! gives every element that is not already a single witness entry a fresh entry, constrained equal to the combination, so later rows refer to one entry instead of the whole combination. It also turns static and constant values into real witness entries.
Arguments
expr- Any expression, static or witness, of any length.
Returns
A witness vector of the same length whose elements are all single witness entries. wtns! is an expression. In the static VM (static_eval!) the input is returned unchanged.
Constraints
One row (combination * 1 = entry) and one witness entry per element that is not already a single entry. Elements that are already single entries are passed through for free.
Example
(let x) # x[0] + x[1] is a linear combination of two entries, # wtns! makes it a single entry let s = wtns! x[0] + x[1] s
Notes
Materialize at coarse boundaries, e.g. once per hash permutation (keccak_f1600 does this for its output state), to keep combinations from growing without paying a row for every intermediate value. The outputs of the entrypoint are materialized the same way automatically. See constraints.
Used in the standard library
blake3/blake3_core, dilithium/lattice/lattice_permutation, dilithium/mldsa/mldsa44_w_approx, dilithium/mldsa/mldsa44_w_approx_static, dilithium/mldsa/mldsa_ntt_native, keccak/keccak_f1600, lattice/lattice_digest, mersenne61/mldsa/mldsa44_w_approx, mersenne61/mldsa/mldsa_intt, mersenne61/poseidon/poseidon_mersenne61, mersenne61/poseidon/poseidon_mersenne61_state, milli/mldsa/mldsa44_w_approx, milli/poseidon/poseidon_milli, milli/poseidon/poseidon_milli_state, mldsa/mldsa44_parse, mldsa/mldsa_sample_in_ball, typed/typed_bytes_lattice, typed/typed_lattice_digest_bits, typed/typed_lex_chacha