XChaCha20-Poly1305: ChaCha20-Poly1305 with a 192-bit nonce
(draft-irtf-cfrg-xchacha-03).
The first 16 bytes of the nonce and the key give a subkey through
HChaCha20; the last 8, after four zero bytes, are the nonce
ChaCha20-Poly1305 runs with under that subkey.
The point is the nonce’s length. A 96-bit nonce drawn at random collides
often enough that a long-lived key cannot use one; a 192-bit one does not,
so seal_with_random_nonce draws each
nonce and needs no counter kept anywhere. That is what to use. Passing a
nonce by hand through Aead is for a protocol that dictates one, and
carries the same rule as every AEAD: never twice under one key.
The specification is an Internet-Draft that expired in 2020 without
becoming an RFC. The construction is what libsodium, Go and Tink implement,
and it is checked here against the draft’s vectors and Project
Wycheproof’s.