BitcoinMachine
TECHNICAL_DOC // KEYS / HASH160
HASH160
(KEY HASH)
HASH160 is the two-step hash operation RIPEMD160(SHA256(data)) that converts a public key or script/">redeem script into a compact 20-byte fingerprint. It is the foundation of P2PKH and P2SH addresses — the 20-byte output is what gets encoded into a Bitcoin address and committed to in the scriptPubKey. Hiding the full public key until spend time provides an additional layer of security.
HASH160 — TWO-STEP PROCESS
HASH160(data) = RIPEMD160(SHA256(data)) Step 1: SHA256 pubkey (33 bytes compressed) → sha256_hash = SHA256(pubkey) (32 bytes) Step 2: RIPEMD160 → hash160 = RIPEMD160(sha256_hash) (20 bytes) Example: pubkey: 0279BE667EF9DCBBAC55A06295CE870B07029... SHA256: 0B7A33F6B22F93C8F89D3C... (32 bytes) HASH160: 89ABCDEFABBAABBAABBA... (20 bytes) In Bitcoin Script: OP_HASH160 computes this operation in one opcode Result stored in scriptPubKey or verified against it
Usage in Address Types
APPLICATIONS
HASH160 is used in two classic address types — P2PKH (pay to public key hash) and P2SH (pay to script hash).
P2PKH (Pay to Public Key Hash): hash160_input: compressed public key (33 bytes) hash160_output: 20-byte pubkey hash scriptPubKey: OP_DUP OP_HASH160 <hash160> OP_EQUALVERIFY OP_CHECKSIG address format: Base58Check with version 0x00 example: 1A1zP1eP5QGefi2DMPTfTL5SLmv7Divf... (26-34 chars) P2SH (Pay to Script Hash): hash160_input: redeem script (arbitrary bytes) hash160_output: 20-byte script hash scriptPubKey: OP_HASH160 <hash160> OP_EQUAL address format: Base58Check with version 0x05 example: 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNL... (34 chars) P2WPKH (Native SegWit): Uses HASH160 of pubkey as witness program (20 bytes) scriptPubKey: OP_0 <20-byte hash160>
TERMINOLOGY_INDEX
HASH160
RIPEMD160(SHA256(data)). Produces 20 bytes. Used in P2PKH and P2SH address derivation.
Pubkey Hash
HASH160(compressed_pubkey). The 20-byte value committed to in a P2PKH scriptPubKey.
Script Hash
HASH160(redeem_script). The 20-byte value committed to in a P2SH scriptPubKey.
OP_HASH160
Bitcoin Script opcode that computes RIPEMD160(SHA256(stack_top)) in a single operation.