TeachMeBitcoin

Serialization and Prefixes (ypub, zpub)

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

Serialization and Prefixes (ypub, zpub)

While the original BIP32 standard only defined xpub and xprv, the evolution of Bitcoin (SegWit) required new ways to tell wallets which type of address to generate from an extended key. This led to the creation of the SLIP-132 standard.

1. The Standard Prefix: xpub

An xpub (Mainnet) always starts with the characters xpub.

2. The SegWit Prefixes

To help wallets know they should generate SegWit addresses, different version bytes were introduced:

ypub (Nested SegWit)

zpub (Native SegWit)

3. Why the prefixes matter?

The internal math of the key is exactly the same whether it starts with x, y, or z. The only difference is the Version Byte at the beginning.

4. The Table of SLIP-132

Prefix Script Type Address Format
xpub P2PKH 1... (Legacy)
ypub P2SH-P2WPKH 3... (Nested SegWit)
zpub P2WPKH bc1q... (Native SegWit)
Ypub P2WSH Multisig Nested SegWit
Zpub P2WSH Multisig Native SegWit

In the final section, we will build a Python Extended Key Auditor.

☕ Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!