def xchacha20
import bend-collections-laws-crypto@1.0.0.0/src/crypto/chacha/chacha20.bend as Chacha20import Base
159# XChaCha20 with a 24-byte nonce.
160def xchacha20(+key_bytes: List<&2, U32>, counter: U32, +nonce_bytes: List<&2, U32>, +plaintext: List<&2, U32>) -> Maybe<&2, List<&2, U32>>:
161 when(valid(key_bytes, nonce_bytes, 24n), xencrypt_unchecked(key_bytes, counter, nonce_bytes, plaintext))