Nonce
A nonce (number used once) is a value used only once in encryption; similar to an IV but emphasizing uniqueness over randomness, it is common in stream ciphers and AEAD.
Purpose
It ensures every encryption under the same key produces a different keystream, preventing two-time pad attacks.
Mechanism
A nonce must be unique (never repeated) within the key’s lifetime. It can be a counter (deterministic) or a random value. CTR/GCM/ChaCha20 use nonces to generate keystreams; the 96-bit nonce is the most common in GCM. Nonce reuse causes catastrophic security failure.
Use cases
- AES-GCM message encryption
- ChaCha20-Poly1305
- TLS record sequence numbers
- WireGuard nonce counters
Examples
- Input
nonce=0,1,2... (counter)Outputa unique nonce per messageDeterministic and unique
Common errors
- Nonce reuse replays the keystream and breaks authentication
- Use a monotonic counter or a long enough random nonce
Related terms
IV (Initialization Vector)
An initialization vector (IV) is an input that injects randomness into block-cipher modes so that the same plaintext produces different ciphertexts across encryptions. GLOSSARY
GCM (Galois/Counter Mode)
GCM is an AEAD mode that combines CTR encryption with GHASH authentication, providing confidentiality and integrity at once, and is the preferred mode of TLS 1.2/1.3. GLOSSARY
CTR (Counter Mode)
CTR mode turns a block cipher into a stream cipher: it encrypts an incrementing counter to generate a keystream that is XORed with the plaintext, supporting parallelism and random access, but provides no integrity. GLOSSARY
ChaCha20
ChaCha20 is a stream cipher designed by Daniel Bernstein, built on ARX (add-rotate-XOR) operations, and is commonly paired with Poly1305 as an AEAD — a high-performance alternative to AES-GCM. GLOSSARY