The Math Behind Your Private Key
From group theory to elliptic curves: how public-key cryptography actually works Elliptic curves keep showing up in crypto. I'd been dodging them for years, but while digging into Ethereum's rollup architecture I finally decided to stop and actually learn what's going on. The surprise? It's all built on group theory—the same abstract algebra I learned in college and promptly forgot because it seemed so disconnected from anything real. Turns out I was wrong. By the end of this post, you'll understand the core math behind public and private keys: how they're constructed from elliptic curves, and why the construction is secure. We'll skip implementation details like hashing and signature protocols—this is about the foundation. In my post on Russell's Paradox, I covered what a set is. A field is a set $F$ equipped with two binary operations—addition and multiplication—satisfying nine axioms total: four for each operation, plus distributivity linking them. "Binary" means each operation takes two elements and returns one element from the same set: $$+: F \times F \to F$$ $$\cdot: F \times F \to F$$ Two axiom examples: As it turns out, fields are the minimal structure required to support linear algebra, calculus and other undergraduate math. The real numbers $\mathbb{R}$ form a field. So do the rationals $\mathbb{Q}$. But the integers $\mathbb{Z}$ do not: there's no integer $n$ such that $2 \cdot n = 1$. The multiplicative inverse of 2 would be $\frac{1}{2}$, which isn't in $\mathbb{Z}$. Cryptography often uses finite fields. Ethereum's BLS12-381 curve operates over $\mathbb{F}_p$: $$\mathbb{F}_p = \lbrace 0, 1, 2, \ldots, p-1 \rbrace$$ where $p$ is a large prime ($p \approx 2^{255}$). Arithmetic wraps modulo $p$. Using $p = 7$ as a small example: Why must $p$ be prime? With $p = 6$, we have $2 \cdot 3 \equiv 0$. If $2$ had an inverse $2^{-1}$, we could multiply both sides: $2^{-1} \cdot 2 \cdot 3 = 2^{-1} \cdot 0$, giving $3 = 0$, a contradiction. So $2$ has no multiplicative inverse, and the field axiom fails. Primes avoid this. A group is a simpler structure than a field: one binary operation instead of two, four axioms instead of nine. We write a group as $(G, \circ)$ where $G$ is a set and $\circ$ is the operation (could be addition, multiplication, composition, etc.). The four axioms: The axioms don't specify what $G$ contains or what $\circ$ does. Prove something about groups in general, and it applies to every group: integers, symmetries, points on a curve. Example: $(\mathbb{Z}, +)$, the integers under addition: An elliptic curve over a field $\mathbb{F}_p$ is the set of points $(x, y)$ satisfying: $$y^2 = x^3 + ax + b$$ plus a special point at infinity $\mathcal{O}$. The constants $a, b \in \mathbb{F}_p$ define the curve's shape. This set forms a group under point addition. The construction may seem arbitrary, but it's precisely what makes the group axioms hold. Here's how it works: Edge cases: Verifying the group axioms: So we have a group: points on an elliptic curve, an addition operation, four axioms satisfied. But groups are everywhere in mathematics. What makes this group useful for cryptography? The answer lies in an asymmetry: some operations on this group are easy to compute, others are practically impossible to reverse. To see this, we need one more concept. Scalar multiplication is repeated addition. Since we have a group operation, we can apply it repeatedly. $nP$ means adding $P$ to itself $n$ times: $$nP = \underbrace{P + P + \cdots + P}_{n \text{ times}}$$ Cryptographic security requires large numbers. Ethereum uses $n \approx 2^{256}$, a number with 78 digits. Naively computing $nP$ would require $n - 1$ additions, which is impossible. But any integer has a binary representation. Take $n = 13$: $$13 = 1101_2 = 8 + 4 + 1$$ So $13P = 8P + 4P + P$. The key insight: $8P = 2(4P) = 2(2(2P))$. We compute $2P$, $4P$, $8P$ by repeated doubling (3 operations), then add the relevant terms (2 more). Total: 5 operations instead of 12. This is double-and-add. For any $n$, it requires $O(\log n)$ operations, roughly the number of bits in $n$. Even for $n \approx 2^{256}$, that's only ~256 doublings and additions. Fast. The reverse direction is hard. Given $P$ and $Q = nP$, finding $n$ is the discrete logarithm problem (DLP). "Logarithm" by analogy to $b^n = x \Rightarrow n = \log_b(x)$. "Discrete" because we're in a finite group. No known algorithm beats brute force by much. With $n \approx 2^{256}$, that's infeasible. This asymmetry is exactly what public-key cryptography needs. Each curve specification includes a standard base point $P$ (also called the generator) that everyone uses. This is the core of elliptic curve cryptography. Real implementations add layers: Ethereum hashes your public key to derive your address, and signature schemes like ECDSA involve additional steps. But the security of all of it rests on the DLP being hard. We covered a lot of ground. Fields give us arithmetic in finite spaces. Groups are simpler structures—one operation, four axioms—that show up everywhere. Elliptic curves form a group under point addition, and the discrete logarithm problem on these curves is hard enough to secure your private keys. The construction is elegant: pick a secret number $n$, multiply a known point $P$ by it, publish the result $Q = nP$. Anyone can verify things with $Q$, but recovering $n$ is computationally out of reach. This post was written in collaboration with Claude (Opus 4.5).Fields: Numbers with Arithmetic
Groups: Simpler Than Fields
Elliptic Curves are Groups
Why Cryptographers Care
Takeaway