Deep dive into the core ideas that power modern cryptography — from the number theory behind RSA and elliptic curves to symmetric ciphers, protocols, security definitions and cryptanalysis.
Each topic below comes with a clear explanation, a hands-on calculator, a short video to go deeper, and a quiz that gets trickier as you go. Take your time, experiment, and don’t worry about mistakes — that’s how you learn!
Crunch the numbers as you learn — supports sin, cos, tan, log, ln, √, powers, π, factorials, % and more. Tip: click the screen to use your keyboard too.
The foundation of modern cryptography
Modular arithmetic is like clock math. When the hour hand goes past 12, it wraps back to 1. In math terms, we're working with remainders after division. This simple concept is the foundation of nearly all modern encryption.
For example: 17 mod 5 = 2 (because 17 ÷ 5 = 3 remainder 2)
In Bitcoin, modular arithmetic is used in ECDSA (Elliptic Curve Digital Signature Algorithm) to create and verify digital signatures. Every transaction you make is secured by these calculations.
Tom Rocks Maths · How does Modular Arithmetic work?
The atoms of mathematics
A prime number is a natural number greater than 1 that can only be divided evenly by 1 and itself. These seemingly simple numbers are the building blocks of all integers and form the foundation of cryptographic security.
The beauty of primes: every integer greater than 1 can be uniquely expressed as a product of prime numbers (Fundamental Theorem of Arithmetic).
While Bitcoin uses elliptic curves (not RSA), prime numbers are still crucial. The secp256k1 curve used by Bitcoin is defined over a prime field with a 256-bit prime number.
TED-Ed · How Prime Numbers Keep the Internet Secure
The one-way function
A discrete logarithm is the inverse of modular exponentiation. If g^x mod p = h, then x is the discrete logarithm of h to the base g, modulo p. The magic: computing g^x mod p is easy, but finding x from the result is incredibly hard.
This asymmetry (easy one way, hard the other) is what makes public-key cryptography possible.
Even if an attacker sees all public communication, they cannot compute the shared secret without solving the discrete log problem.
The discrete log problem on elliptic curves (ECDLP) is what secures your Bitcoin wallet. Your private key is essentially a secret exponent, and your public key is the result of elliptic curve multiplication - easy to compute, impossible to reverse.
Khan Academy · The Discrete Logarithm Problem
The modern standard
An elliptic curve is a special type of curve defined by the equation y² = x³ + ax + b. When we combine this with modular arithmetic over a prime field, we get Elliptic Curve Cryptography (ECC) - the backbone of Bitcoin and Ethereum.
ECC provides the same security as RSA with much smaller key sizes: a 256-bit ECC key ≈ 3072-bit RSA key.
Bitcoin uses a specific elliptic curve called secp256k1, defined by:
Where p is a massive 256-bit prime. Your Bitcoin private key is a random 256-bit number k, and your public key is the point K = k × G, where G is the generator point.
Every Bitcoin address is derived from an elliptic curve public key. When you sign a transaction, you prove ownership of the private key without revealing it - this is the magic of ECDSA (Elliptic Curve Digital Signature Algorithm).
Computerphile · Elliptic Curves (Dr Mike Pound)
The math built to survive quantum computers
RSA and elliptic curves are safe today because reversing them (factoring huge numbers or solving discrete logs) would take normal computers billions of years. But a large quantum computer running Shor’s algorithm could do it in hours. That is the whole reason post-quantum cryptography exists.
Most post-quantum schemes are built on lattices — endless grids of points made by adding and subtracting a few vectors. The security comes from problems that are easy to state but brutally hard to solve, even for quantum computers.
In 2024, the US standards body NIST published the first official post-quantum algorithms. These are already rolling out in browsers and messaging apps right now.
Chalk Talk · Lattice-Based Cryptography: The Tricky Math of Dots
One shared key — the fast workhorse of encryption
In symmetric cryptography a single secret key is used to both lock (encrypt) and unlock (decrypt) a message. It is far faster than public-key math, so almost all real data — your Wi-Fi, disk encryption, and the actual content of an HTTPS page — is protected with it. Public-key crypto is mostly used just to agree on the symmetric key.
The same key k appears on both sides, so it must be shared secretly beforehand — the classic "key distribution" problem that Diffie–Hellman later solved.
XOR your message with a truly random key that is as long as the message and never reused, and the result is provably unbreakable — Shannon's "perfect secrecy." The catch is exactly that key: distributing one-time pads as long as all your data is why we use AES instead.
AES-NI instruction encrypts billions of bytes per second, which is why full-disk encryption barely slows your laptop.Computerphile · AES Explained (Advanced Encryption Standard)
How the pieces work together over an untrusted network
A single cipher only scrambles data. A protocol is the choreography that combines several tools — key exchange, authentication and encryption — into a conversation that is safe even when strangers are listening. Every HTTPS padlock is one protocol, TLS, running in the background.
A typical secure session does three things: agree on a shared key (key exchange), prove who you're talking to (authentication), then encrypt the data (symmetric crypto).
Advanced protocols do surprising things. A zero-knowledge proof convinces someone a statement is true while revealing nothing else — not even the secret behind it. A commitment scheme lets you lock in a value now and reveal it later without being able to change it (it is both binding and hiding), the digital version of a sealed envelope.
Computerphile · Transport Layer Security (TLS)
What it actually means for a cipher to be "secure"
Real cryptography never says "it looks random, so it's safe." Instead we define a precise attacker and a precise goal, then prove the attacker can't win. This is what separates modern cryptography from historical code-making.
A scheme is "broken" the moment an attacker does noticeably better than a coin flip — even slightly.
The strongest guarantee is a reduction: a proof that if someone could break the scheme, they could also solve a problem everyone believes is hard — like factoring huge numbers. So breaking the cipher is at least as hard as that famous open problem. Security stops being a hope and becomes a theorem.
1 / (any polynomial) as the key grows — so big keys make a winning attack astronomically unlikely.On semantic security & provable security
The art and science of breaking ciphers
Cryptanalysis is the attacking half of cryptology — and it is how we learn which ciphers to trust. A cipher earns confidence only by surviving decades of the world's best cryptanalysts trying to break it. The attacks below also define the "threat models" that security definitions promise to resist.
Because of the "birthday paradox," finding two inputs with the same hash takes roughly the square root of the naive effort. That is exactly why secure hashes need 256 bits: it drops the attacker's real work to a still-impossible 2128.
Computerphile · Cracking codes with frequency analysis