Skip to content
STAGING — not production

Cryptography: Physics of Secrets

Why AES-256 is unbreakable by physics. The mechanics of RSA (Prime Factoring), ECC (Discrete Logs), and Hash Collisions.

Beginner 40 min read Expert Version →

🎯 What You'll Learn

  • Deconstruct RSA (The Factoring Problem)
  • Analyze ECC (The Discrete Log Problem)
  • Trace a Diffie-Hellman Key Exchange
  • Calculate the Thermodynamics of Brute Force
  • Audit a Hash for Pre-image Resistance

Introduction

Cryptography is not “Secret Writing”. It is Mathematical Warfare. It allows a lone individual to hide a secret that no government, army, or supercomputer can uncover.

It relies on Hard Problems: Math that is trivial to compute one way, but impossible to reverse without a “Trapdoor”. This lesson explores the Physics of the Impossible.


The Physics: Symmetric Encryption (AES-256)

AES is the standard for locking data. It Shuffles, Substitutes, and Mixes bytes in 14 “Rounds”.

The Physics of Brute Force: To crack AES-256, you must check up to 22562^{256} keys. The Landauer Limit states the minimum energy to flip 1 bit is kBTln2k_B T \ln 2 (~2.8×10212.8 \times 10^{-21} J at room temperature). Just counting to 22562^{256} — performing 22562^{256} bit operations at the thermodynamic minimum — requires roughly 105610^{56} joules. The Sun outputs 3.8×10263.8 \times 10^{26} watts. You would need to capture the Sun’s entire energy output for longer than the age of the universe. AES-256 is not just hard to crack. It is thermodynamically impossible to brute-force.


Deep Dive: Asymmetric Encryption (RSA vs ECC)

Symmetric keys are great, but how do I send you the key? Public Key Cryptography.

RSA (The Factoring Problem):

  • Easy: 13×17=22113 \times 17 = 221.
  • Hard: What are the factors of 239847129...?239847129...?
  • Key Size: Requires 3072 bits to be secure. Slow.

ECC (Elliptic Curve Cryptography):

  • Easy: P+P+P...=QP + P + P... = Q.
  • Hard: Given QQ, how many times did I add PP? (Discrete Log).
  • Key Size: Only 256 bits for same security. 1000x faster.
  • Physics: Used in Bitcoin, TLS 1.3, Signal.

Strategy: Diffie-Hellman (Paint Mixing)

How do two people agree on a secret color in public without revealing it?

  1. Public: Yellow Paint.
  2. Alice: Adds Secret Red. Sends Orange Mixture.
  3. Bob: Adds Secret Blue. Sends Green Mixture.
  4. Alice: Adds Secret Red to Bob’s Green -> BROWN.
  5. Bob: Adds Secret Blue to Alice’s Orange -> BROWN.

Result: Both have the same Shared Secret (Brown). An eavesdropper sees Orange and Green but cannot separate the colors to find the secret.


Code: ECDSA Signing

import ecdsa
import hashlib

# 1. Generate Key Pair (Curve secp256k1)
sk = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1)
vk = sk.verifying_key

# 2. Sign a Message
message = b"Attack at Dawn"
signature = sk.sign(message)

# 3. Verify the Signature
try:
    assert vk.verify(signature, message)
    print("Signature Valid!")
except ecdsa.BadSignatureError:
    print("WARNING: Forged Signature")

Practice Exercises

Exercise 1: Hash Collision (Beginner)

Task: Find two strings that produce the same MD5 hash. Result: Easy. You can do it in seconds on a laptop. MD5 is broken. Task: Do it for SHA-256. Result: Impossible.

Exercise 2: RSA Key Size (Intermediate)

Scenario: You use 1024-bit RSA. Risk: This can be factored by a Nation State. You must use 2048 or 3072.

Exercise 3: Quantum Threat (Advanced)

Scenario: Shor’s Algorithm runs on a Quantum Computer with 4000 Qubits. Result: It solves Factoring and Discrete Logs instantly. RSA and ECC are dead. AES-256 survives (only weakened to AES-128 via Grover’s Algo).


Knowledge Check

  1. Why is AES-256 considered thermodynamically secure?
  2. What is the Hard Problem behind RSA?
  3. Why do we prefer ECC over RSA today?
  4. What does Diffie-Hellman achieve?
  5. Are Hashes reversible?
Answers
  1. Energy limits. There isn’t enough energy in the solar system to check all keys.
  2. Integer Factoring. Finding prime factors of a huge number.
  3. Efficiency. Smaller keys, faster computation, same security.
  4. Key Exchange. Shared secret over an insecure channel.
  5. No. They are lossy compression (Pigeonhole Principle).

Summary

  • Symmetric: Fast, Unbreakable.
  • Asymmetric: Solves Key Exchange (Slow).
  • Hashing: Digital Fingerprint.

Want to go deeper?

Weekly infrastructure insights for engineers who build trading systems.

Free forever. Unsubscribe anytime.

You're in. Check your inbox.

Questions about this lesson? Working on related infrastructure?

Let's discuss