TECHNICAL_DOC // KEYS / ADDRESS
ADDRESS
A Bitcoin address is a human-readable encoding of a scriptPubKey locking condition.
It is derived from a public key or script-hash/">script hash and encodes the output type, network, and
an error-detection checksum. Sending to an address instructs the wallet to construct the
appropriate scriptPubKey. There are four address formats in active use:
P2PKH, P2SH, P2WPKH, and P2TR.
ADDRESS_FORMATS
ALL FOUR ADDRESS TYPES AT A GLANCE
Format Prefix Encoding Payload Introduced
P2PKH 1... Base58Check HASH160(pubkey) Bitcoin 2009
P2SH 3... Base58Check HASH160(script) BIP 16 (2012)
P2WPKH bc1q... Bech32 HASH160(pubkey) BIP 141 (2017)
P2TR bc1p... Bech32m x-only pubkey BIP 341 (2021)
Lengths:
P2PKH: 26–34 chars (typically 34)
P2SH: 34 chars
P2WPKH: 42 chars (bc1q + 39 chars)
P2TR: 62 chars (bc1p + 59 chars)
P2PKH — Pay to Public Key Hash
LEGACY
The original address format. Encodes HASH160(compressed_pubkey) with a 0x00 version-byte-base58check/">version byte via Base58Check. Starts with "1".
Derivation:
pubkey_hash = RIPEMD160(SHA256(compressed_pubkey))
payload = 0x00 || pubkey_hash (21 bytes)
checksum = SHA256(SHA256(payload))[0:4]
address = Base58Encode(payload || checksum)
scriptPubKey:
OP_DUP OP_HASH160 <20-byte-hash> OP_EQUALVERIFY OP_CHECKSIG
Example:
1A1zP1eP5QGefi2DMPTfTL5SLmv7Divf Na (genesis coinbase)
P2SH — Pay to Script Hash
LEGACY
Encodes the hash of an arbitrary redeem script. Unlocking requires providing the original script plus data satisfying it. Version byte 0x05 produces "3" prefix.
Derivation:
script_hash = RIPEMD160(SHA256(redeem_script))
payload = 0x05 || script_hash (21 bytes)
checksum = SHA256(SHA256(payload))[0:4]
address = Base58Encode(payload || checksum)
scriptPubKey:
OP_HASH160 <20-byte-hash> OP_EQUAL
Common use: P2SH-wrapped P2WPKH (bc1q inside 3... address)
redeem_script = OP_0 <20-byte-hash160>
P2WPKH — Native SegWit v0
SEGWIT
Native SegWit address for single-key outputs. Uses Bech32 encoding with HRP "bc" and witness-version-0-1/">witness version 0. Signature moves to the witness field.
Derivation:
witness_program = RIPEMD160(SHA256(compressed_pubkey))
(20 bytes)
address = Bech32Encode("bc", 0, witness_program)
scriptPubKey:
OP_0 <20-byte-witness-program> (22 bytes)
Benefits:
Lower fees (witness data discounted 75%)
No scriptSig (malleability fix)
Error-detecting Bech32 checksum
Example: bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4
P2TR — Pay to Taproot (SegWit v1)
TAPROOT
Taproot address encodes a 32-byte x-only tweaked public key as witness version 1. Uses Bech32m encoding. Enables key-path and script-path spends.
Derivation:
output_key = internal_key + H_taptweak(key||merkle_root)×G
witness_program = output_key.x (32 bytes, x-only)
address = Bech32mEncode("bc", 1, witness_program)
scriptPubKey:
OP_1 <32-byte-witness-program> (34 bytes)
Key-path spend: single Schnorr signature in witness
Script-path spend: reveal script + control block
Example: bc1p5d7rjq7g6rdk2yhzks9smlaqtedr4dekq08ge8ztwac72sfr9rusxg3297
TERMINOLOGY_INDEX
scriptPubKey
The locking script stored in a UTXO. An address is a human-readable encoding of this script.
Version Byte
0x00 → P2PKH (starts "1"), 0x05 → P2SH (starts "3"). Encoded into Base58Check prefix.
Witness Version
HRP
Human Readable Part. "bc" for mainnet, "tb" for testnet. Precedes the separator "1" in Bech32.
Output Key
The Taproot tweaked public key committed to in P2TR. May commit to a Merkle tree of scripts.
INTERACTIVE — TRY IT YOURSELF
KEYS / ADDRESSES
Bitcoin Addresses
A Bitcoin address is a one-way derivative of a public key. You cannot reverse an address back to its public key — that's the security guarantee. But the derivation path differs for each address type: P2PKH encodes the key hash with Base58Check, P2SH hashes a redeem script, P2WPKH uses native SegWit Bech32, and P2TR (Taproot) tweaks the key directly into Bech32m.
LIVE DERIVATION — ONE PUBKEY → FOUR ADDRESS TYPES
Paste a compressed public key (33 bytes, hex) and instantly derive all four standard address formats simultaneously. The derivation chain is shown step-by-step for each type.
PUBKEY → ALL ADDRESS FORMATS33 or 65 byte compressed/uncompressed
DERIVATION PIPELINE — STEP BY STEP
Every address type starts from the same HASH160 operation:
RIPEMD-160(SHA-256(pubkey)). The 20-byte result is then wrapped differently depending on the spending conditions required.
HASH160 → ADDRESS PIPELINE
ADDRESS FORMAT COMPARISON
FORMAT OVERVIEW TABLE
| TYPE | SCRIPT | ENCODING | WITNESS | SEGWIT DISCOUNT | TAPROOT PRIVACY |
|---|---|---|---|---|---|
| P2PKH | OP_DUP OP_HASH160 <hash> OP_EQUALVERIFY OP_CHECKSIG | Base58Check | ✗ | ✗ | ✗ |
| P2SH | OP_HASH160 <script_hash> OP_EQUAL | Base58Check | ✗ | ✗ | ✗ |
| P2WPKH | OP_0 <20-byte hash> | Bech32 (v0) | ✓ | ✓ | ✗ |
| P2TR | OP_1 <32-byte tweaked key> | Bech32m (v1) | ✓ | ✓ | ✓ |
P2TR (Taproot) note: P2TR addresses encode the x-coordinate of the tweaked public key — not just the raw key. The tweak commits to a script tree, so a key-path spend looks indistinguishable from a script-path spend on-chain. The
HASH_TapTweak step shown above uses SHA256-tagged hashing (BIP 340).