Crypto Foundations & Threat Models

  • Goals: confidentiality, integrity, authenticity
  • Threat models define the attacker before the defense
  • Security levels and work factors
  • Randomness, entropy, and bias
  • Why key/nonce reuse breaks everything
1 / 11

Security goals

  • Confidentiality: hide content
  • Integrity: detect modification
  • Authenticity: bind data to identity
  • Availability: stay usable under attack

Encryption alone != integrity

2 / 11

Threat models

  • Passive vs active attacker
  • CPA vs CCA vs KPA
  • Online vs offline
  • Attack surface: oracles, errors, side channels

No threat model -> no real security claim

3 / 11

Computational security

  • Breaks are possible in theory, infeasible in practice
  • Work factor measured in operations
  • Compare to realistic budgets
4 / 11

Security levels

  • Preimage on b-bit hash ~ 2^b
  • Collision on b-bit hash ~ 2^(b/2)
  • Symmetric key k-bit -> 2^k work

Birthday bound dominates collisions

5 / 11

Randomness and entropy

  • Uniformity is not enough
  • Unpredictability is required
  • Min-entropy measures worst-case guessability
6 / 11

Modulo bias

  • x % n is biased unless 2^64 % n == 0
  • Fix with rejection sampling
  • Bias can be attacker-visible
7 / 11

One-time pad

  • Perfect secrecy requires:
    • truly random key
    • key length == message length
    • key used once

Reuse collapses to XOR of plaintexts

8 / 11

Determinism leaks

  • Deterministic encryption leaks equality
  • Nonce or randomness makes encryption probabilistic
  • Reuse of nonces reintroduces determinism
9 / 11

Implementation pitfalls

  • Timing leaks
  • Error oracles
  • Parsing and padding bugs
  • State reuse

Security is end-to-end

10 / 11

What you will build

  • XorShift64* toy PRNG
  • Unbiased modulo reduction
  • Birthday collision threshold
  • Two-time pad recovery
11 / 11
Use arrow keys or click edges to navigate. Press H to toggle help, F for fullscreen.