---
title: "Extended Key (xprv/xpub) — definition | Nuri Glossary"
description: "A key bundled with a chain code so it can derive children, either extended private or extended public."
lang: "en"
type: "glossary-term"
canonical: "https://nuri.com/glossary/extended-key"
---

# Extended Key (xprv/xpub)

A key bundled with a chain code so it can derive children, either extended private or extended public.

## Basically

An extended key lets your wallet create new Bitcoin keys and addresses from one starting point. An xprv is private, while an xpub is public.

## Key Takeaways

- An extended key pairs a cryptographic key with a 32-byte chain code. Together, they allow deterministic child key derivation as defined in BIP-32.
- Extended private keys (xprv) can derive child private and public keys. Extended public keys (xpub) can only derive child public keys, which enables watch-only wallets and secure key management.
- Exposing an xprv compromises all funds in its subtree. An xpub leak also harms privacy and can lead to full key compromise if combined with any non-hardened child private key.

## What Is an Extended Key?

An extended key is the basic building block of hierarchical deterministic (HD) wallets. It combines a standard private or public cryptographic key with a 32-byte chain code, which adds entropy for deriving child keys. A key alone cannot produce deterministic descendants without the chain code, so the chain code makes the derivation tree possible.
Extended keys were introduced in BIP-32, proposed by Pieter Wuille in 2012. Before HD wallets, every new address required an independent key backup. With extended keys, one seed phrase can generate an entire tree of keys and addresses, all recoverable from that seed.
Extended keys come in two types. An extended private key (xprv) contains a private key plus chain code and can derive the full range of child keys. An extended public key (xpub) contains a compressed public key plus chain code and can only derive child public keys, allowing a merchant to generate fresh receiving addresses on a server without exposing private keys.

## Master Key Generation

The master extended key is the root of the entire HD wallet tree. It is derived from a seed, typically produced from a BIP-39 mnemonic phrase, using HMAC-SHA512.
The master private key and master chain code together form the master extended private key. The master extended public key is derived by computing the corresponding secp256k1 public key and pairing it with the same chain code.

## Child Key Derivation

BIP-32 defines two derivation modes. Each mode has distinct security properties.
Normal, or non-hardened, derivation uses indexes 0 through 2³¹ − 1. The HMAC input includes the parent public key, so both extended private and extended public keys can derive child public keys. This enables xpub-based watch-only wallets.
Hardened derivation uses indexes 2³¹ through 2³² − 1, written with a prime symbol, such as 0'. The HMAC input uses the parent private key instead of the public key, so only the extended private key can perform hardened derivation. An xpub cannot derive hardened children.
Standard derivation paths like BIP-44's m/44'/0'/0'/0/0 use hardened derivation for the purpose, coin type, and account levels. They then switch to non-hardened derivation for the change and address index levels. This creates security firewalls between accounts while still allowing xpub-based address generation within each account.

## Serialization Format

Extended keys are serialised into a 78-byte structure. Base58Check encoding follows this step.
The 78-byte payload is double-SHA-256 hashed to produce a 4-byte checksum, which is appended before Base58 encoding. The result is a 111-character string. The version bytes make the Base58 output start with a recognisable prefix: "xpub" or "xprv" for mainnet, and "tpub" or "tprv" for testnet.

## Version Byte Variants

Different Bitcoin address types use different version bytes in the serialisation. These produce distinct prefixes that tell wallet software which script type to use when generating addresses, and they are registered in SLIP-0132.
These prefixes do not represent different keys, but different serialisation formats of the same underlying extended key. The prefix tells wallet software which Bitcoin address type to generate when deriving addresses from the key. For Taproot (P2TR) addresses defined in BIP-86, no widely adopted version prefix has been standardised yet.

## Watch-Only Wallets

Extended public keys are most commonly used to create watch-only wallets. A merchant or accounting system imports an xpub and generates fresh receiving addresses for every transaction without handling private keys. The private keys stay on a signing device or in cold storage, completely air-gapped from the internet-connected server.

## Multi-Account Wallet Architecture

HD wallets use extended keys to organise funds into isolated accounts. Under BIP-44, each account gets its own hardened extended key at depth 3, m/44'/0'/account'. Compromising one account's keys cannot affect other accounts because hardened derivation prevents upward key recovery.

## Multisignature Coordination

Multisig wallet cosigners share their account-level xpubs to enable collaborative address generation. The wallet software combines these xpubs to produce multisig addresses without any cosigner revealing a private key. All cosigners can independently verify and generate the same set of addresses, as explained in the multisig wallets deep dive.

## Payment Platforms and Wallet SDKs

Payment processors and wallet SDKs rely on extended keys to generate unique addresses per customer or invoice. Platforms like Spark use hierarchical key structures for self-custodial wallets, where you control the root key while the application derives payment addresses on the fly.

## xprv Exposure: Total Fund Loss

Leaking an extended private key is catastrophic because an attacker with an xprv can derive every child private key in the entire subtree and drain all funds at every derived address. This is equivalent to losing the seed phrase for that branch of the wallet tree. Never store extended private keys on internet-connected devices; use air-gapped signing or a hardware signing device instead.

## xpub + Child Private Key Vulnerability

BIP-32 explicitly warns that knowledge of a parent extended public key plus any non-hardened child private key is equivalent to knowing the parent extended private key. The maths for non-hardened derivation is straightforward.
Standard derivation paths therefore use hardened derivation at account boundaries. Hardened derivation uses the parent private key as the HMAC input, so an attacker cannot compute the intermediate value without already having the private key.

## Privacy Implications of xpub Sharing

Sharing an xpub reveals your complete financial history for that branch of the wallet, even without exposing a private key. Anyone with the xpub can generate all past and future addresses, revealing total holdings, transaction history, business relationships, and payment patterns. Share the narrowest-scope xpub possible, preferring an account-level xpub over a master xpub when a service only needs to track one account; the Bitcoin privacy analysis covers wider privacy techniques.

## Address Gap Limits

Wallet software scans forward through the derivation tree looking for used addresses when recovering a wallet from a seed. It stops after finding a configurable number of consecutive unused addresses, known as the address gap limit and typically set to 20. Generating addresses far ahead of the gap limit can make funds appear missing during recovery.

## Why It Matters

Extended keys make modern Bitcoin wallets practical. Before BIP-32, wallets generated random independent keys that required frequent backups, and one missed backup could mean permanent fund loss. Extended keys replaced that fragile model with a deterministic tree: back up once, recover everything.
Extended keys also separate key generation from key signing, forming the foundation of secure key management. A hot wallet can generate addresses using an xpub while the corresponding xprv stays offline in cold storage. This pattern scales from individual users to exchanges handling billions in assets, making the extended key hierarchy central to security and usability for self-custodial platforms building on Bitcoin.
This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.
Part of the [Nuri glossary](https://nuri.com/glossary), which defines 1876 Bitcoin, Lightning, wallet, stablecoin and payment terms.
