Public and private keys explained.
A private key is a large random number that only you should know, and it signs your transactions. A public key is calculated from the private key and can be shared freely, so others can check your signatures and send you coins. The calculation only runs one way, so a public key never reveals the private key behind it.
เนื้อหานี้ยังมีเฉพาะภาษาอังกฤษ

Pick a secret number, say 11. Multiply eleven 3s together, divide the result by 17 and keep the remainder. You get 7, and you can tell the whole world that 7 is your number.
Could anyone work out your 11 from the 7? With numbers this small, yes, by trying every option, but with numbers 78 digits long, no computer that exists could. Every crypto wallet is built on that gap.
A key pair in plain terms
A private key is a large random number that only you know. A public key is a second number calculated from the private key. The two are made together as a key pair.
In Bitcoin and Ethereum, the private key is a 256-bit number chosen at random by your wallet. The public key comes from it through elliptic curve multiplication, on a curve both networks use called secp256k1.
You never need to do this maths yourself. What you need is the direction: private key to public key is quick, and public key back to private key is out of reach.
Worked example: why the maths only runs one way
The opening used tiny numbers for illustration. "mod 17" means divide by 17 and keep the remainder.
- Private key: 11.
- Work out 3 to the power of 11: 177,147.
- Divide by 17: 17 × 10,420 = 177,140, so the remainder is 7.
- Public key: 7.
Going backwards, there is no simple formula. You try 3 to the power of 1, then 2, then 3, and keep going until the remainder is 7. Here that takes 11 tries.
A real private key is picked from about 1.16 × 10⁷⁷ possible numbers. Suppose, for illustration, a machine could check 10²⁴ keys per second, a trillion trillion.
Trying them all would take about 3.7 × 10⁴⁵ years, far longer than the universe has existed.
Real elliptic curve maths differs in detail but follows the same pattern. Going forward takes a fraction of a second. Going back means searching, and the search is too big to finish.
What each key is for
| Private key | Public key | |
|---|---|---|
| Who knows it | Only you | Anyone |
| What it does | Signs transactions | Lets others check your signatures |
| If someone copies it | They can move your coins | They still cannot spend anything |
| Can it be rebuilt from the other? | No | Yes, from the private key |
When you spend coins, your wallet uses the private key to sign the transaction. Every node on the network then uses your public key to check that signature. The lesson on digital signatures walks through that check.
The same kind of pair can also be used for encryption, where the public key locks a message and the private key opens it. Bitcoin uses its key pairs for signing only, and its ledger stays public.
From private key to Bitcoin address
You rarely share a raw public key. For the most common address types, a Bitcoin wallet turns it into a shorter address:
- The private key produces the public key.
- The public key is hashed with SHA-256, then with RIPEMD-160, giving a 160-bit public key hash.
- That hash is encoded with a checksum, which helps wallets catch a mistyped address.
Each step in that chain runs one way. For basic address types, the full public key only appears on the blockchain when you spend from the address. How hashing works explains the hashing step.
Addresses come in a few formats. Older ones start with 1 or 3, and newer ones start with bc1q or, for Taproot, bc1p.
A Taproot address holds a form of the public key itself instead of its hash. Like every format, it reveals nothing about the private key.
Where your private keys live
Your coins never leave the blockchain, where they are recorded against addresses. A crypto wallet holds the keys that can spend them.
Most wallets never show you a private key. They create a seed phrase of 12 or 24 words and work out a whole family of private keys from it.
Back up the words and you have backed up every key the wallet will make, as the seed phrase lesson explains.
On an exchange, the exchange usually holds the keys for you, which the lesson on types of crypto wallets calls custodial.
A crypto CFD involves no keys at all, because you hold a price contract with a broker and never own the coin.
When a key is lost or stolen
There is no bank behind a private key. If you lose both the key and the seed phrase, the coins stay on the blockchain forever, and nobody can move them.
If someone copies your key, they can sign transactions exactly as you would. The network cannot tell the difference, and Bitcoin transactions cannot be reversed.
That is why no genuine support agent, exchange or wallet maker will ever ask for your private key or seed phrase. A request for either is a scam, one of the patterns in common crypto scams.
คำถามที่พบบ่อย
Can someone steal my crypto with my public key?
No. A public key or address only lets people send you coins and check your signatures. Spending needs the private key.
Is a wallet address the same as a public key?
Not exactly. A basic Bitcoin address is a hashed, shorter form of the public key with a checksum added, and it is just as safe to share.
How long is a private key?
In Bitcoin and Ethereum it is 256 bits, often written as 64 hexadecimal characters. Most people never see it, because wallets build their keys from a seed phrase.
Can two people end up with the same private key?
With a proper random number generator, the chance is so small it can be ignored. Keys made from weak randomness, or from a phrase a person made up, have been guessed and emptied in the past.
เรียนต่อ
บทที่ 3What is hashing?Hashing feeds data into a hash function, which returns a short code of fixed length called a hash. The same input always gives the same hash, a tiny change gives a completely different one, and there is no practical way to work back from the hash to the input. Bitcoin uses SHA-256 hashes to link blocks and name transactions.
บทที่ 3How does hashing work, and what is it used for?A hash function pads its input, cuts it into blocks of equal size and mixes each block into a running state over many rounds of bit operations. The final state is the hash. Crypto uses this to check files, store passwords, chain blocks together, summarise transactions in a Merkle root, build addresses and set the puzzle that miners solve.
บทที่ 3What is encryption?Encryption turns readable data into scrambled text using a key, and the right key turns it back. Symmetric encryption uses one shared key, while public key encryption uses a matched pair. Unlike hashing, encryption can be reversed. Bitcoin's ledger is not encrypted at all: encryption protects your connection to an exchange and the wallet files that hold your keys.
บทที่ 3How do digital signatures work?A digital signature is a number calculated from a message and a private key. Anyone with the matching public key can check it. If the check passes, the message came from whoever holds the private key and has not changed by a single bit. Bitcoin nodes run this check on every transaction before they accept it.
บทที่ 3How does a Bitcoin transaction work?A Bitcoin transaction spends earlier unspent outputs as its inputs, proves you may spend them with a signature, and creates new outputs: one for the person you pay and usually one returning change to you. Whatever the inputs hold beyond the outputs is the fee. Nodes check the transaction, and a miner adds it to a block.