Every cryptocurrency wallet is composed of a public address and a private key. These keys are just a string of random numbers. The public address can be shared with other people and they can use it to send funds to it. The private key should never be shared, as the owner of the private key has access to the funds and can send them to other wallets.
Originally, blockchain generated a new private key and public key every time funds were to be sent to a Bitcoin wallet. This made it increasingly difficult to back up the wallet information, as users had to back up their Bitcoin wallets every time they received funds in them. Over time there were many attempts to improve this system, but the real breakthrough came with BIP32 (Bitcoin Improvement Proposal), which marked the creation of the Hierarchical Deterministic Wallets.
An HD Wallet automatically generates a structure of child private and public keys. This structure is hierarchical, as the name suggests since these keys are obtained from a single master – parent- seed (see image below). This solved the issue of users having to keep generating their own wallets. It also makes it easy to back up and restore backups, with the use of this single seed.
Every child key pair can define an xPub (Extended Public Key). As the name suggests, an Xpub doesn’t contain information about private keys, but only public ones. This means that an xPub will not give you access to the funds in a wallet, but the user can also view the child wallet’s addresses, transactions, and balances. You can think of it as a read-only view of a wallet. Although the Xpub doesn’t give you spending abilities, only to view wallet’s information, it’s highly risky to share the key with anyone.
What are Ypub and Zpub?
After the adoption of SegWit, theBIP49 standard gave origin to the yPub. A yPub key is the same as an xPub key. However, it follows the new standard and has an address type P2SH-P2WPKH. yPub is for backward-compatible SegWit Wallets.
After the xPub and yPub, the newest Public Extended Key is zPub. Just as its predecessor the zPub follows the BIP49 standard, but the address type is P2WPKH. zPub is for native compatible SegWit wallets.
An easy way to differentiate between xPubs, yPubs and zPubs is that xPubs addresses always start with “1”, the yPub addresses always start with “3”, whilst zPub addresses always start with “bc1”.
Create and view an xPub, yPub and zPub key with Crypto APIs