What is xpub, ypub and zpub?

April 9, 2024

In the Hierarchical Deterministic (HD) wallets, we use to talk about xpub (Master Extended Public Keys), ypub or zpub.

The mnemonic seed phrase generates a Master Extended Private Key and a Master Extended Public Key, which can be used to derivate new keys inside the wallet. From each Master Extended Private Key, you can obtain lots of Child Private Keys, which are linked to Child Public Keys and their addresses. So, you can have a single Master Extended Private Key and use it as the source of all the Child Private Keys and Child Public Keys in your wallet. Also, the matching Master Extended Public Key will generate the same Child Public Keys.

The Master Extended Public Key is useful for the creation of watch-only wallets because it allows access to the address of the wallets without needing access to the Private Key, consequently without access to sign transactions.

What are xpub, ypub and zpub?

They are the name of the Extended Public Keys on different wallets or scrips:

xpub

This is the name of the Extended Public Key. It is used on legacy wallets, with addresses starting with 1.

This is created on the bitcoin standard BIP32 and allows read-only access to a wallet. The xpub allows you to see all the transactions, addresses, and balances of a specific wallet, but it doesn’t allow you to spend the balance. To spend, you need a private key.

ypub

Is the same as xpub, but the y means the Extended Public Key belongs to a wallet with the bitcoin standard BIP49, which details an addressing scheme compatible with older versions than SegWit. A ypub key has an address of type P2SH-P2WPKH.

zpub

zpub es the same than ypub (the Extended Public Key belongs to a wallet with the bitcoin standard BIP49), but the addressing scheme is not backward compatible. It follows the address typeP2WPKH, so zpub is for wallets natively compatible with SegWit.

In this table you can see the relationship between private and public keys:

All the master public keys can be encoded as xpub.

The derivation schemes of ypub, zpub, etc are implementations created by Electrum y SatoshiLabs. These schemes have a specific encoding, described on SLIP 132 and SLIP 032

Privacy Considerations

With a public key is possible to access all the wallet addresses and the balance so is not recommended to share it. This is why it’s recommended to have your own Bitcoin node, so you avoid leaking that important information.

How to set up a Bitcoin Node with Umbrel on a Raspberry Pi 5

How to set up a Bitcoin Node with Umbrel on a Raspberry Pi 4

Credits

Estudio Bitcoin is a site in Spanish with lots of resources to learn about Bitcoin. All the different topics on the site, explain why they are important for Bitcoin, and let you deeply learn with a list of selected links.

¿Qué es la codificación de claves? xpub, ypub, zpub… — Estudio Bitcoin

Visit our Website

With so many hardware wallets on the market, it can be challenging to choose the right one for your needs. That’s where our Hardware Wallet Comparison TheBitcoinHole.com website comes in. You will find the most comprehensive and honest resource for comparing the features of the top hardware wallets.

Support Us

There are different ways to support our work:

  • With Bitcoin Lightning using Alby
  • With PayPal or a credit card using Ko-fi