def hstate
import bend-collections@1.0.0.0/spec/crypto/chacha.bend as Chachaimport Base
175# HChaCha20 (draft-irtf-cfrg-xchacha-03 section 2.2): the state is set up as
176# for ChaCha20 with the 16-byte nonce in words 12..15; after twenty rounds
177# (no feed-forward) words 0..3 and 12..15 are the 32-byte subkey.
178def hstate(+k: List<&2, U32>, +n: List<&2, U32>) -> List<&2, U32>:
179 List.append(&2, U32, constants(),
180 [get(k, 0n), get(k, 1n), get(k, 2n), get(k, 3n), get(k, 4n), get(k, 5n), get(k, 6n), get(k, 7n),
181 get(n, 0n), get(n, 1n), get(n, 2n), get(n, 3n)])