Course contentsShow
← Security
Lesson 131 of 3,0523. Symmetric Cryptography Deep DiveFree lesson

Nonces vs IVs: Definitions and Differences

Understand the distinction between nonces (number used once) and initialization vectors, their purposes, and when each is used.

Nonces vs IVs: Definitions and Differences

What you'll learn: You'll understand what nonces and initialization vectors are, how they differ, and when cryptography uses each one.


What is a Nonce?

A nonce (number used once) is a value that must be unique for each encryption operation with the same key. Think of it like a unique ticket number—it just needs to be different every time, but it doesn't have to be unpredictable. A simple counter (1, 2, 3...) works perfectly as a nonce.

Key property: Uniqueness matters, randomness doesn't necessarily matter.

Where you've seen it: CTR mode and ChaCha20 both require nonces. In AES-GCM, that value you must never reuse? That's a nonce.


What is an Initialization Vector (IV)?

An initialization vector (IV) is also a unique starting value, but with an important twist: it typically needs to be unpredictable. Think of it like shuffling a deck of cards before dealing—the order needs to be random, not just different.

Key property: Both uniqueness AND unpredictability often matter.

Where you've seen it: CBC mode uses an IV. If an attacker can predict your next IV, they can potentially learn information about your plaintext before you even encrypt it.


The Practical Difference

  • Nonce: Can be a counter. Just don't repeat it. (Example: ChaCha20, CTR, GCM)
  • IV: Usually must be random. Predictability can break security. (Example: CBC mode)

Some cryptographers use these terms interchangeably, but the distinction helps you understand requirements: if your mode says "nonce," a counter is fine. If it says "IV" and you're using CBC, generate it randomly.


Key Takeaway: Nonces must be unique; IVs typically must be both unique and unpredictable. The terminology hints at the security requirements of your cipher mode.