Skip to content
uencoder

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)
    Output
    a unique nonce per message

    Deterministic and unique

Common errors

Nonce reuse replays the keystream and breaks authentication
Use a monotonic counter or a long enough random nonce

Related terms

Related tools

References