Public and Private Keys, Explained
If you've ever heard someone say "not your keys, not your coins" and nodded along without really knowing what a "key" even is, THIS IS THE PERFECT POST FOR YOU. Public and private keys are the single idea that makes cryptocurrency work without a middleman, without passwords, and without anyone in charge. Once it clicks, a lot of the rest of blockchain suddenly makes sense too.
The problem we're actually solving
Imagine Alice wants to send Bob some money, with no bank standing between them. Immediately, a problem shows up: how does anyone prove a message is really from Alice, without her sharing some secret password that a middleman could verify?
There's no login screen here. No central server holding everyone's passwords. Just Alice, Bob, and a public network of strangers who all need to somehow agree: yes, this really came from Alice, and it hasn't been tampered with.
The answer is a pair of keys.
Two keys, one pair
- Private key — Your personal signing pen. A mathematically secret string, 256 bits long, that only you possess. Generating one takes about 2 milliseconds.
- Public key — Your home address. It's distributed freely, and anyone can use it to verify that a signature genuinely belongs to you.
Both keys are 256 bits, but in practice the public key ends up being a much longer string once encoded. More importantly: going from private key to public key is fast, BUT going backwards is, for all practical purposes, impossible. We'll come back to exactly how impossible in a moment, because the actual numbers are worth sitting with.
Where does the public key come from?
It's not made up, and it's not stored anywhere — it's mathematically derived from the private key using a one-way calculation. A simple way to picture this: imagine mixing blue and red paint into purple. If I hand you the purple can and tell you it's a mix of both, you can't work out the exact proportions I used just by looking at it. Combining is easy. Un-combining is, for all practical purposes, impossible.
That's the relationship between the two keys. Deriving a public key from a private one is trivial. Reversing it would take longer than the universe has existed — even with enormous computing power thrown at the problem. We'll get to the actual math on that.
A worked example: Alice sends Bob 1 BTC
Here's the process end to end:
- Bob shares his public address, derived from his public key, which is safe to hand out, like a bank account number.
- Alice writes the message: "Send 1 BTC from my address to Bob's address."
- That message gets run through a hash function, producing a fingerprint — a fixed-length summary of the exact transaction.
- Alice combines that fingerprint with her private key and a random number, and runs it through a signing formula.
- Out comes a signature — in practice, just two large numbers, labelled r and s.
- Alice broadcasts the signature, the transaction's fingerprint, and her public key to the network.
Nowhere in this process does Alice's private key ever get shared, transmitted, or exposed. It never leaves her hands.
Verification, not decryption
This is the part people usually get wrong in their head, so it's worth being precise. Verifying a signature is not decryption. Nobody unlocks or reads a hidden message.
Instead, there's a separate verification formula that takes the signature, the transaction's fingerprint, and Alice's public key, and simply checks whether the three are mathematically consistent. A useful mental model: it's like checking a finished Sudoku puzzle instead of solving it yourself. You don't need to know how someone solved it to instantly confirm whether it's correct. If the numbers line up, the signature is confirmed genuine — full stop.
There's a second check happening alongside this: does Alice actually have 1 BTC to send? This is where things get slightly unexpected — Bitcoin doesn't track account balances the way a bank does. There's no row anywhere saying "Alice: 2.5 BTC." Instead, it uses something called the UTXO model — Unspent Transaction Output.
Think of Alice's wallet as holding specific "bills": a UTXO worth 2 BTC, another worth 0.5 BTC — adding up to her balance. To spend, she references those specific existing UTXOs, and the network checks they genuinely belong to her and haven't already been spent.
Why bother with UTXOs at all?
Three good reasons:
- Prevents double-spending — every node can instantly check whether a specific UTXO has already been spent elsewhere. If so, the new transaction is rejected outright.
- Enables parallel verification — because each UTXO is independent, transactions spending different UTXOs can be checked at the same time, rather than needing to process one running balance sequentially.
- Better privacy — funds scattered across many separate UTXOs, rather than a single visible balance, make it harder to track someone's total holdings just by watching the ledger.
Once both checks pass, the transaction gets bundled into the next block on the chain, and Bob's wallet shows 1 BTC available — ready for him to spend later, using this exact same process with his own private key.
The transparency paradox
Here's something that catches people off guard: on a public blockchain, every wallet address and balance is 100% visible. Anyone in the world can audit the entire state of the ledger, at any moment, forever.
So why is any of this safe?
Picture a safe made entirely of glass. Viewing the gold inside is completely free — anyone can look, anytime. But opening the safe to actually spend what's inside strictly requires the private key. Total transparency and total security, at the same time. That's the trick.
Just how secure is a 256-bit key, really?
A private key is 256 bits long, giving 2²⁵⁶ possible combinations — roughly 1.16 × 10⁷⁷. To put that number in some kind of perspective:
- Estimated number of atoms on Earth: 1.3 × 10⁵⁰
- Estimated grains of sand on Earth: 7.5 × 10¹⁸
- Age of the universe, in years: 4.35 × 10¹⁷
- Land area of Australia, in cm²: 7.7 × 10¹⁶
- Area of a single $100 note, in cm²: 100
That $100 note is about 1.3 × 10⁻¹³% of Australia's entire land area — and even that vanishingly small ratio doesn't come close to capturing how large the keyspace actually is.
Now the real stress test: imagine giving every person on Earth (8 billion) 8 billion computers each, all running non-stop for a full year (roughly 3 × 10⁷ seconds). That gives you about 5 × 10²⁷ total guesses. Exhausting every possible private key at that rate would still take roughly 2 × 10⁵⁰ years — a number so far past the age of the universe that "impossible" barely covers it.
The Takeaway
Public and private keys solve a problem that used to require a trusted middleman: proving this really came from me, without ever revealing a secret to anyone. One key signs, the other verifies — and the math connecting them only runs safely in one direction. Everything else in blockchain — transactions, wallets, even the idea of "owning" cryptocurrency at all — is really just this one idea, applied over and over again.
