def state
import bend-collections@1.0.0.0/spec/crypto/chacha.bend as Chachaimport Base
98# The initial state: constants, key (eight words), block counter, nonce
99# (three words). Missing key or nonce words read as 0 (the public API
100# rejects other lengths before this is reached).
101def state(+k: List<&2, U32>, counter: U32, +n: List<&2, U32>) -> List<&2, U32>:
102 List.append(&2, U32, constants(),
103 [get(k, 0n), get(k, 1n), get(k, 2n), get(k, 3n), get(k, 4n), get(k, 5n), get(k, 6n), get(k, 7n),
104 counter, get(n, 0n), get(n, 1n), get(n, 2n)])