hash160 → P2PKH / P2SH / P2WPKH addresses
A hash160 is the 20-byte fingerprint RIPEMD160(SHA256(pubkey)). On its own it produces no address; wrapped with a version byte and a checksum it becomes a 1… or 3… address, and wrapped in bech32 it becomes bc1q…. This page shows every one of those wrappings side by side — and why a Taproot address can never come out of one.
Enter a value above and press Convert. Not sure what to type? Press “Use example” to load the sample from the placeholder.
What this page computes
You give it one value — a 20-byte hash160 — and it shows you every address that can be built from it, plus the raw bytes each address commits to. The hash itself is one line of arithmetic:
This page starts at the third box: the hashing is already done, and everything below is pure
wrapping. That is the useful part to understand, because the same 20 bytes become a
1…, a 3…, a bc1q… or a tb1q… address depending only on
which bytes are glued in front of them.
1. What a cryptographic hash function is
A hash function takes an input of any length and returns a fixed-length fingerprint. Cryptographers require three separate properties from it, and each one is doing different work inside a Bitcoin address.
| Property | Meaning | Cost for a 160-bit output | What it protects here |
|---|---|---|---|
| Preimage resistance | Given a digest h, find any input x with H(x) = h | ≈ 2160 = 1 461 501 637 330 902 918 203 684 832 716 283 019 655 932 542 976 attempts | Stops anyone minting a brand-new public key that hashes to your address and spending your coins with that key's own private key |
| Second-preimage resistance | Given one specific input x, find a different x′ with H(x′) = H(x) | ≈ 2160 | Matters once your public key is public: nobody can substitute another key for the exact one you already spent from |
| Collision resistance | Find any two inputs x ≠ x′ with the same digest | ≈ 280 = 1 208 925 819 614 629 174 706 176 (birthday bound) | Stops a counterparty building two keys with one address, showing you the harmless one and spending with the other |
The first property is the one people misread. The address is the hash, so there is nothing to "derive the address from" — see section 4. What preimage resistance really buys you is that the set of public keys mapping to a given address is effectively unreachable: to spend a P2PKH output you must reveal a public key with that exact hash160 and sign with its private key, and the attacker may choose both. If a preimage were findable in 240 steps instead of 2160, an attacker would simply generate a fresh keypair whose public key hashes to your address and empty it. Preimage resistance is the property that makes a published address safe to leave unspent forever.
2. Why RIPEMD160(SHA256(x)) and not a single hash
Both halves are deliberate, and they are answering two different questions.
| Construction | Output | Collision resistance | Preimage resistance | Trade-off |
|---|---|---|---|---|
SHA256(x) | 32 bytes | 2128 | 2256 | Strongest collision bound, but every output in a script and in the UTXO set would be 12 bytes bigger |
RIPEMD160(x) | 20 bytes | 280 | 2160 | Compact, but only one hash function stands between the attacker and you |
SHA256(x) truncated to 20 B | 20 bytes | 280 | 2160 | No second function; also reuses the same internal state and padding rules |
RIPEMD160(SHA256(x)) | 20 bytes | 280 | 2160 | Two independent designs in series — what Bitcoin uses |
Read it as an assembly line. SHA-256 is a modern, well-studied 256-bit function; running it first makes the value that enters the second stage a uniformly random 32-byte string, so RIPEMD-160 never sees structured input from an attacker. RIPEMD-160 then shrinks the commitment to 20 bytes, and that saving is real money:
| Item | With a 20-byte commitment | With a 32-byte commitment | Saved per output |
|---|---|---|---|
P2PKH scriptPubKey | 25 bytes (76a914 ‖ 20 B ‖ 88ac) | 37 bytes | 12 bytes |
| Base58Check address | 34 characters (25 bytes encoded) | ≈ 50 characters | 16 characters |
| Witness v0 program | 20 bytes (P2WPKH) | 32 bytes (P2WSH-sized) | 12 bytes |
Twelve bytes multiplied by every unspent output in the chain, forever, is a strong argument. The second
argument is defence in depth: a break of one function does not immediately break the construction. To
forge a collision in RIPEMD160(SHA256(x)) an attacker must produce two inputs whose
SHA-256 digests collide, that is to say they must break SHA-256 as well, or attack RIPEMD-160
through an interface where they control only 32-byte inputs.
Chaining hashes does not multiply security. The collision resistance of
RIPEMD160(SHA256(x)) is still bounded by the weakest link in that attack path —
RIPEMD-160's 280 birthday bound — because a collision in the final output is enough.
The composition buys resistance to cryptanalytic breaks and a fixed 32-byte input length for the
inner stage, not a bigger number.
3. The birthday bound, and why 160 bits is enough
Preimage attacks need work proportional to the output space, 2160. Collisions are cheaper because of the birthday paradox: in a room of 23 people two share a birthday, and for hashes the expected search is about
| Digest size | Preimage work | Collision work | Used by |
|---|---|---|---|
| 128 bits | 2128 | 264 | MD5-class designs — long broken in practice |
| 160 bits | 2160 | 280 | hash160: RIPEMD-160 inside Bitcoin addresses |
| 256 bits | 2256 | 2128 | SHA-256, used for the outer stage and for Taproot's tagged hashes |
280 is the honest weak point of hash160, and it is considered acceptable for three reasons: a collision only pays off if the attacker can then persuade someone to use one of the two colliding keys; the attacker must also match SHA-256, because the second stage takes only 32-byte inputs; and RIPEMD-160's 160-bit width was a standardised, internationally vetted choice (it was selected by the EU's RIPE project) rather than a first attempt. If you are generating addresses for somebody else and they never verify that you do not know the key, collision resistance is the property that is supposed to protect them — and it is the one with the smallest margin.
4. The address is not a secret — what actually protects your coins
Look at a real address's insides: 146ZNjH7…2UqT is nothing but
Base58Check(0x00 ‖ hash160). The hash is in the address, published on every invoice,
in every QR code, on every block explorer. Nobody is trying to hide it, and "you cannot reverse the hash to
find my address" is not a security argument — the address was given away on purpose.
What protects the coins is a combination of three things:
- The private key. Spending requires a valid ECDSA signature over the transaction. Nothing in the address lets you produce one.
- Preimage resistance of hash160. An alternative public key that hashes to your address must be infeasible to find (≈ 2160), because such a key could be spent with a signature the attacker makes themselves.
- The public key is not on-chain until you spend. In P2PKH the chain stores only the
20-byte hash while the output is unspent. The full point appears in the
scriptSigof the transaction that spends it.
| Address type | What the chain stores while unspent | What the spend reveals | Quantum exposure |
|---|---|---|---|
P2PKH (1…) | hash160 of the key | The 33- or 65-byte public key | Low until spent: only a 160-bit preimage is exposed |
P2SH-P2WPKH (3…) | hash160(0x0014 ‖ hash160) | The 22-byte redeemScript and the public key | Low until spent |
P2WPKH (bc1q…) | The 20-byte witness program | The compressed public key | Low until spent |
P2TR (bc1p…) | The 32-byte x-only output key — a curve point | A signature (key path) | High from the moment it is funded |
That last row is why hashing still matters in a post-quantum discussion. Shor's algorithm solves the elliptic-curve discrete logarithm, so it can recover a private key from a public key that is visible on-chain. For an unspent P2PKH output there is no point visible — only a hash — so a quantum attacker must attack the hash instead, where Grover's algorithm gives only a quadratic speed-up (2160 → roughly 280 quantum steps). Taproot chose the opposite trade-off: its output key is a curve point sitting on-chain, which is what makes it cheap to verify and private to cooperate on, and also what makes it the first thing a quantum adversary could take.
5. Byte-level layout of everything this page prints
| Address | Bytes fed to the address encoder | Length | First characters |
|---|---|---|---|
| P2PKH mainnet | 0x00 ‖ hash160 | 21 B + 4 B checksum | 1…, always 34 characters |
| P2PKH testnet | 0x6F ‖ hash160 | 21 B + 4 B | m… or n… |
| P2SH-P2WPKH mainnet | 0x05 ‖ hash160(0x0014 ‖ hash160) | 21 B + 4 B | 3… |
| P2SH-P2WPKH testnet | 0xC4 ‖ hash160(0x0014 ‖ hash160) | 21 B + 4 B | 2… |
| P2WPKH mainnet | "bc" + separator + witness v0 + 32 five-bit words | 42 characters | bc1q… |
| P2WPKH testnet | "tb" + separator + witness v0 + same words | 42 characters | tb1q… |
Note the double hashing in the P2SH-P2WPKH row. A nested SegWit address does not commit to your
public-key hash directly; it commits to hash160 of the 22-byte redeemScript
0x0014 ‖ hash160, which is why its payload is a different 20 bytes from every other row.
6. Worked example with the sample hash160
These are the values this page actually prints for 21f57b6d…89012, computed here and not
copied from anywhere:
| Step | Value |
|---|---|
| SHA-256 of the public key | 067eb00a0b9864633b020eef374476142daba913c5481ad6a4741cc8ab702617 |
| RIPEMD-160 of that digest = hash160 | 21f57b6debcfc5b67182dfb4af1641f0a8189012 |
P2PKH payload 00 ‖ hash160 | 0021f57b6debcfc5b67182dfb4af1641f0a8189012 |
| Its double-SHA256 checksum (first 4 bytes) | cbd7667e |
| P2PKH mainnet address | 146ZNjH7XTXnMd1ofe3z7CL2i8WM7N2UqT |
P2PKH testnet payload 6F ‖ hash160 | 6f21f57b6debcfc5b67182dfb4af1641f0a8189012 (checksum 8c66f080) |
| P2PKH testnet address | micWfnN6LUy38jVRPD2Mw7YMa873zjixGw |
RedeemScript 0014 ‖ hash160 | 001421f57b6debcfc5b67182dfb4af1641f0a8189012 |
| Its hash160 = script hash | 823333d5fd23a83661e8e47629552c4a5bfc8b6e |
P2SH payload 05 ‖ script hash | 05823333d5fd23a83661e8e47629552c4a5bfc8b6e (checksum acbfef44) |
| P2SH-P2WPKH mainnet address | 3DZT76KyKyc5zkzvLugP8umgt4RPY4XPQw |
| P2SH-P2WPKH testnet address | 2N57fAqFzwS7SCYdU23JFkrkx6QdZKurmpU |
| P2WPKH mainnet address | bc1qy86hkm0telzmvuvzm76279jp7z5p3yqjnaerk6 |
| P2WPKH testnet address | tb1qy86hkm0telzmvuvzm76279jp7z5p3yqjemzsdf |
| Witness program words (after version 0) | y86hkm0telzmvuvzm76279jp7z5p3yqj + checksum naerk6 |
P2PKH scriptPubKey | 76a91421f57b6debcfc5b67182dfb4af1641f0a818901288ac |
P2WPKH scriptPubKey | 001421f57b6debcfc5b67182dfb4af1641f0a8189012 |
Six different addresses, one hash, zero cryptography beyond the two hash calls that produced it. If you change a single input byte anywhere upstream, every row in that table changes.
7. A Taproot address cannot be built from a hash160
This is the one thing on the page that is not possible, and the reason is structural, not a limitation of this tool. A P2TR output commits to a 32-byte x-only output key, computed as
Producing that requires the full curve point: the tweak is taggedHash("TapTweak", x(P)), the
addition needs a real point with a known y, and the result must be a point whose private key the owner can
actually use. A hash160 is 20 bytes of digest; it is not a point, it has no y, and — crucially — nobody
knows the discrete log of the point you would get by treating it as an x coordinate, even though the curve
equation may well have a solution for it.
| What P2TR needs | What a hash160 provides |
|---|---|
| A 32-byte x coordinate of a real key | 20 bytes; 12 bytes shorter than a valid field element |
| A point whose private key the owner holds | A digest — no corresponding known scalar |
| A TapTweak derived from the internal key | Nothing to tweak; the tweak cannot be computed |
| bech32m, witness version 1, 32-byte program | Only bech32 v0 (20 bytes) or Base58Check payloads |
For the sample value, left-padding the 20 bytes to 32 and treating them as an x coordinate happens to
land on a valid curve point, producing bc1pkc3xmm086pdgtvrkcg33cn90lhv9aq6f3ueuu9gvwdeeqrzmr5qsejuhs7.
Nobody holds the private key for it. Sending bitcoin there is indistinguishable from sending it to a
burn address. The genuine Taproot address for the same key is
bc1pmsrhxnvmj8tjxxu9wj69ntvwvhvr28qufyc26tshz3rjj777tx3sh54u63, and it can only be derived
from the full public key 02ff812e…ee80, never from its hash.
8. Where this value comes from and what comes next
- Upstream: compressed public key → hash160 → addresses shows the hashing step itself, and private key HEX → all formats starts from the very beginning.
- Downstream, Base58Check: Base58Check encoder / decoder takes the payloads printed above and shows the version byte, checksum and internal structure.
- Downstream, bech32: Bech32 / Bech32m decoder does the same
for the
bc1q…form, including the witness program and checksum. - Addresses from the same key: P2PKH, P2SH-P2WPKH, P2WPKH.
9. Security notes and common mistakes
- An address is not a secret. A hash160 is public by construction; treat every published address as known to everybody forever.
- Hashing the wrong serialization. The compressed key (
02…/03…) and the uncompressed key (04…) hash to different values, so one private key owns two P2PKH addresses. The demonstration values are21f57b6d…9012(compressed →146ZNjH7…) and3f0e966d…23f9(uncompressed →16kR3eis…). - Assuming the checksum validates meaning. A Base58Check checksum proves the string was not mistyped; it says nothing about whether the version byte matches the network you are on.
- Believing 20 bytes is "weak". 160 bits of preimage resistance is beyond any classical attack; the weakest link is the 80-bit collision bound, and exploiting it requires more than brute force.
- Sending to the wrong address type. The four Base58/bech32 forms above are four
different
scriptPubKeys. Funds sent to one cannot be spent by a wallet that only knows another.
Every value on this page is computed by the PHP process serving it. Nothing is sent anywhere, and the hash160 you paste is not logged.
10. Quick reference
| Item | Value |
|---|---|
| Formula | RIPEMD160(SHA256(pubkey)) |
| Output size | 20 bytes / 40 hex characters / 160 bits |
| Addresses derivable from it | P2PKH (mainnet + testnet), P2SH-P2WPKH (mainnet + testnet), P2WPKH (mainnet + testnet) |
| Addresses not derivable | P2TR / Taproot — needs the full curve point |
| Base58Check payload length | 21 bytes (1 version byte + 20 body bytes), plus a 4-byte checksum |
| P2PKH address length | 34 characters on both networks |
| P2WPKH address length | 42 characters (bc1q… or tb1q…) |
| P2SH-P2WPKH payload | hash160(0x0014 ‖ hash160), not hash160 itself |
| Preimage resistance | 2160 |
| Collision resistance | 280 (birthday bound) |