Crypto · How blockchains work
Public and private keys: how crypto ownership works
How a private key becomes a public key and an address, what a digital signature proves, and why guessing a key is hopeless, shown with a real demonstration key.
On this page
Owning cryptocurrency means knowing a secret number. There is no account in your name and no registry of holders. A blockchain records that certain coins can be spent by whoever proves knowledge of a particular private key, and it accepts that proof from anyone, without asking who they are.
The proof works through public-key cryptography, a method invented in the 1970s that also protects every secure website. Each private key has a matching public key that can be shared freely. The private key produces signatures; the public key lets anyone check them. Getting from the private key to the public key is easy, and going back is, for practical purposes, impossible.
This lesson follows one real key through each step, from secret number to address to signature, and then puts numbers on how hard a key is to guess. It is the idea underneath every wallet, every exchange withdrawal and every theft.
Three things that are easy to mix up
| Item | What it is | Share it? | If lost |
|---|---|---|---|
| Private key | A secret 256-bit number | Never | The coins can never be moved again |
| Public key | A point on a curve, derived from the key | Yes; revealed on spending | Recomputed from the private key |
| Address | A short, checksummed form of the public key | Yes; it is how you get paid | Recomputed from the public key |
A wallet is software or a device that stores private keys and signs with them. It does not "contain" coins. The coins are entries on the blockchain; the wallet holds what is needed to move them. Crypto wallets and custody: keys, seed phrases, hot and cold storage covers the kinds of wallet and what each protects against.
From private key to address
To make the steps concrete we built a key pair that anyone can reproduce. The private key
is the SHA-256 hash of the sentence Finabase Learn demonstration key. Never send funds to it. Because the sentence is published here, the key is public, and anything sent to
its address could be taken by any reader. It exists only to show the arithmetic.
Step 1: the private key. A number between 1 and just under 2^256, normally produced by a random number generator. Ours, in hexadecimal:
80a97dc983831246601d6fbd6cd1820cd35eba03de773d3d2238b5a089f989c2
Step 2: the public key. Bitcoin and Ethereum both use an elliptic curve called secp256k1. The public key is a point on that curve, found by "multiplying" a fixed starting point by the private key. The operation is quick to compute forward. Reversing it, finding the multiplier given the result, is the problem that would take longer than the life of the universe with any known method on today's computers. Ours, in the compressed 33-byte form:
03f9aeb82a6a695d45efd516ebb29de8e72a9006c9b69b976e3416a5cc717713e5
Step 3: the address. For a classic bitcoin address, the public key is hashed with SHA-256, then with RIPEMD-160, which shortens it to 160 bits. A version byte is added in front and a four-byte checksum behind, and the result is written in Base58, an alphabet that leaves out look-alike characters such as 0 and O. Ours:
1E5CpgepKFCF8HnxFzLae2jZEJnS8v92vM
The checksum is why a mistyped address is almost always rejected by a wallet before anything is sent: changing a character breaks the check. It does not protect against pasting a different, valid address, which is what address-swapping malware does.
Address formats you will meet
Bitcoin has added address types over the years. All are valid today, and the first characters tell them apart.
| Starts with | Type | Introduced by | Notes |
|---|---|---|---|
1 |
Pay to public key hash | Original | The format derived above |
3 |
Pay to script hash | BIP 13 / 16 | Used for multi-signature and wrapped formats |
bc1q |
Native SegWit (bech32) | BIP 173 | Lower fees; lowercase only |
bc1p |
Taproot (bech32m) | BIP 350 | Active since November 2021; Schnorr signatures |
Ethereum works differently. An address is the last 20 bytes of the Keccak-256 hash of the
public key, written as 0x followed by 40 hexadecimal characters. One Ethereum address
holds ether and every token on that chain, and the same address format is used by many
other networks. That convenience is also a hazard: an address that looks identical exists
on several chains, and coins sent on a network the recipient's wallet or exchange does not
support may be unrecoverable.
One backup, many keys
Modern wallets do not make you back up each key. They generate a single master secret and derive an endless sequence of key pairs from it by a standard method (BIP 32), which is why a wallet can show a new address for every payment and still be restored from one backup. That master secret is what a seed phrase encodes. See Seed phrase.
What a signature proves
When you send coins, your wallet builds a transaction ("pay this address this amount from these coins") and uses the private key to compute a digital signature over it. The transaction, the signature and the public key are broadcast. Every node then runs a check that needs only those three things.
A valid signature establishes two facts:
- Authorization. It was produced by someone who knows the private key matching that public key.
- Integrity. It was produced for exactly this transaction. Any change to the recipient, the amount or anything else makes the signature invalid.
It never reveals the private key. Signing thousands of transactions leaks nothing usable about the key, provided the wallet software is sound.
We ran both cases with the demonstration key. It signed the message Pay Ben 0.01 BTC.
The signature verified against the public key. The same signature checked against
Pay Ben 0.10 BTC failed.
This is what lets a network of strangers process payments. Nobody has to trust the sender's identity or the computers that relayed the message. The mathematics either checks out or it does not.
A signature is also unconditional. The network cannot tell a payment you intended from one you were tricked into signing, or one signed by a thief who copied your key. If the signature is valid, the transaction is valid, and once confirmed it is final (see How a blockchain reaches agreement: consensus explained).
Why nobody guesses a private key
The number of possible private keys is about 2^256:
115,792,089,237,316,195,423,570,985,008,687,907,853,269,984,665,640,564,039,457,584,007,913,129,639,936
That is roughly 1.16 × 10^77. Classic addresses are shorter, 160 bits, so the practical target is the 2^160 possible addresses, about 1.46 × 10^48.
A worked example. Suppose an attacker can test a trillion keys every second, far beyond any real hardware, and that a billion different addresses hold coins.
- Chance that one random key matches any funded address: 10^9 ÷ 1.46 × 10^48 = about 6.8 × 10^−40.
- Guesses in 13.8 billion years, the age of the universe: 10^12 a second × 4.35 × 10^17 seconds = 4.35 × 10^29.
- Expected number of hits: 4.35 × 10^29 × 6.8 × 10^−40 = about 3 × 10^−10.
After the entire age of the universe the attacker would have about a one in three billion chance of having found a single funded address. This is why the system can let anyone generate keys offline without checking for duplicates: two honest users will not collide.
The assumption carrying all of this is that the key was chosen randomly. Keys made from a memorable phrase, a birthday or a weak random number generator are found quickly, because attackers try those first. Our demonstration key is an example: it is the hash of an English sentence, the kind of input an attacker's program would try early.
How keys are actually lost
Since guessing is hopeless, losses come from the handling of keys.
- Theft by malware or phishing. A fake wallet app, a fake support agent or a malicious browser extension gets the user to type or reveal the key or the seed phrase.
- Signing something harmful. On chains with smart contracts, a user can be led to sign a transaction or a permission that hands a contract the right to move their tokens.
- Loss. A discarded hard drive, a forgotten password on an encrypted file, a single paper backup destroyed. There is no recovery process, because nobody else has the key.
- Custodian failure. Coins held on an exchange are controlled by the exchange's keys. The user has a claim on a company, not a key.
- Weak generation. Keys derived from guessable inputs or from faulty software.
Every one of these is about secrecy or backup, never about the cryptography being broken. The two requirements pull in opposite directions: more copies protect against loss and increase the chance one is found. Balancing them is most of what wallet design is about.
Privacy: what an address reveals
An address carries no name, but it is not anonymous. Every payment to and from it is public and permanent. If an address is ever linked to a person, through an exchange that verified their identity, a purchase delivered to their home or a published donation address, the link extends to its whole history and often to other addresses that transacted with it. Wallets reduce this by using a fresh address for each payment, which is good practice and costs nothing.
How Finabase does it
Finabase does not create, store or use private keys, and it has no wallet. It shows prices and market data, such as the BTC.X quote page and the crypto list. You cannot receive or send coins through it, and it will never ask for a private key or a seed phrase. Anyone asking for those on Finabase's behalf is attempting fraud.
The demonstration key was derived by the script that draws this page's figures, using Node.js's standard cryptography library. To reproduce it, hash the sentence above with SHA-256 to get the private key, derive the compressed secp256k1 public key, and apply SHA-256, RIPEMD-160 and Base58Check with version byte 0. Do not send funds to the resulting address.
Frequently asked questions
What is the difference between a public key and a private key?
The private key is a secret number that authorizes spending. The public key is derived from it and lets anyone verify a signature without learning the secret. You share the public key or the address made from it, and never the private key.
Can someone steal my crypto with just my address?
No. An address only lets people send you coins and see its history. Spending requires a signature from the private key. Be wary of what follows a request for your address, though: scams often start there and move on to asking for a key or a signature.
Can a private key be recovered if it is lost?
No. There is no issuer, no reset and no customer service for a key. The only recovery is a backup you made yourself, such as a seed phrase. Coins whose keys are lost stay on the ledger forever, unspendable.
Is a seed phrase the same as a private key?
Not exactly. A seed phrase encodes a master secret from which a wallet derives all of its private keys. Anyone holding the phrase can regenerate every key, so it must be guarded as closely as the keys themselves.
Can two people end up with the same private key?
In principle yes, in practice no, if both keys are generated randomly. With about 10^77 possibilities the chance is far too small to matter. The realistic danger is a key that came from a weak source of randomness.
Summary
A private key is a random 256-bit number, the public key is computed from it on an elliptic curve, and the address is a hashed, checksummed form of the public key. Each step is easy forward and infeasible backward. Spending means signing a transaction with the private key; any node can verify the signature with the public key, and it is valid only for that exact transaction. The space of keys is so large that guessing fails even on cosmic timescales, so coins are lost through stolen, exposed or missing keys, and the network treats any valid signature as final, whoever made it.
Check your understanding
5 questions on this lesson. Each answer comes with the reason, and nothing is scored.
Which of these can safely be given to someone who wants to pay you?
- Your private key
- Your address
- Your seed phrase
Show the answer
B. Your address An address only allows others to send coins and view its history. The private key and the seed phrase both give the power to spend.
A transaction is signed, then a relay changes the amount before passing it on. What do nodes do?
- Accept it, since the signature is from the right key
- Reject it, because the signature no longer matches the transaction
- Ask the sender to confirm
Show the answer
B. Reject it, because the signature no longer matches the transaction A signature covers the exact contents of the transaction. Any change makes verification fail.
Why is it practical to derive a public key from a private key but not the reverse?
- The reverse calculation is illegal
- Public keys are stored encrypted on the blockchain
- The forward step is a fast calculation, while no known method reverses it in any feasible time
Show the answer
C. The forward step is a fast calculation, while no known method reverses it in any feasible time Elliptic-curve multiplication is easy to compute and its inverse is a problem with no efficient known solution on today’s computers.
A user creates a private key by hashing the phrase “my dog rex 2019”. What is the main weakness?
- The key is too short
- The key is not random, so attackers who try common phrases can find it
- Hashes cannot be used as keys
Show the answer
B. The key is not random, so attackers who try common phrases can find it The key has the right length but comes from a guessable input. The security of a key rests on it being chosen at random from the whole space.
A thief copies your private key and signs a transfer of your coins. How does the network treat the transaction?
- As valid, because the signature is valid
- As invalid, because you did not intend it
- As pending until you approve it
Show the answer
A. As valid, because the signature is valid The network checks signatures, not intentions or identities. A valid signature from the right key is all it requires.
Sources and further reading
- Bitcoin developer guide — Transactions (secp256k1 private keys are 256 bits; ECDSA signatures)
- Bitcoin developer guide — Wallets (private key formats, public keys, hierarchical deterministic wallets)
- Bitcoin developer reference — Transactions (address version bytes; P2PKH)
- BIP 13 — Address format for pay-to-script-hash (addresses beginning with 3)
- BIP 173 — Base32 address format for native v0-16 witness outputs (bech32, the bc1 prefix)
- BIP 350 — Bech32m format for v1+ witness addresses (Taproot)
- BIP 340 — Schnorr signatures for secp256k1
- BIP 32 — Hierarchical deterministic wallets
- Ethereum.org — Accounts (private keys, public keys, addresses from the Keccak-256 hash)
- Demonstration key on this page — derived and tested by Finabase with Node.js (secp256k1, SHA-256, RIPEMD-160, Base58Check); inputs printed in the text
