Guide library PENGER Academy

Anatomy of a Wallet

A wallet manages keys and transaction data. The funds remain on the network. Follow a payment to see the difference.

What you’ll learnConnect derivation paths, watch-only data and spending conditions to a complete recovery plan.

Before you startKnow what a recovery phrase is; start with Seed Anatomy if that is new.

BIP32 Hierarchical Deterministic Derivation

BIP32 defines a tree structure for key derivation. Starting from a master key (derived from the BIP39 seed via HMAC-SHA512), child keys are generated at each level using the parent key and a 32-bit index.

Normal vs. Hardened Derivation

Each level in the tree can produce 231 normal child keys (indices 0 to 231-1) and 231 hardened child keys (indices 231 to 232-1, denoted with ').

  • Normal derivation — uses the parent public key + chain code. Allows deriving child public keys from an xpub without the private key.
  • Hardened derivation — uses the parent private key + chain code. Prevents child key compromise from propagating upward to the parent.
How one exposed child key can compromise its parent

Parent xpubcombined withNon-hardened child private keycan revealParent private key

A hardened derivation step blocks this particular relationship. It cannot protect keys already exposed on a compromised device.

The Derivation Function

BIP32 Child Key Derivation
// For hardened child (index >= 2^31): I = HMAC-SHA512(Key=parent_chain_code, Data=0x00 || parent_private_key || index) // For normal child (index < 2^31): I = HMAC-SHA512(Key=parent_chain_code, Data=parent_public_key || index) child_key = parse256(I_L) + parent_key (mod n) child_chain = I_R

ECDSA and Schnorr Signatures

Bitcoin historically uses the secp256k1 elliptic curve with ECDSA (Elliptic Curve Digital Signature Algorithm) for transaction signing. The Taproot upgrade (BIP340) introduced Schnorr signatures as an alternative.

ECDSA Signing Process

  1. Generate a per-message nonce k, for example with RFC 6979 deterministic generation
  2. Compute point R = k × G (elliptic curve point multiplication)
  3. Compute r = R.x mod n
  4. Compute s = k-1(hash + r × privateKey) mod n
  5. The signature is the pair (r, s)

The fundamental security primitive is the Elliptic Curve Discrete Logarithm Problem (ECDLP) — given P = k × G, computing k from P and G is computationally infeasible.

Schnorr Signatures (BIP340)

Schnorr signatures offer several advantages over ECDSA:

  • Linearity — signatures can be aggregated (key aggregation for multi-sig looks like a single signature on-chain)
  • Provable security — security reduction directly to the discrete logarithm problem
  • Smaller and faster — 64-byte signatures vs. variable-length DER-encoded ECDSA
  • Batch verification — multiple signatures can be verified faster than individually

A repeated ECDSA nonce can expose the signing key. Reusing it across different messages, or leaking enough information about it, can reveal the private key. Deterministic generation avoids dependence on fresh randomness for every signature; it does not remove fault or side-channel risks.

Extended Public Keys (xpub) and Watch-Only

An extended public key (xpub) encodes the public key together with its chain code, enabling the derivation of all normal child public keys without access to any private key. This enables powerful use cases:

  • Watch-only wallets — monitor balances and generate receiving addresses without spending capability
  • Payment servers — an e-commerce backend can generate a unique address for each customer using the xpub, while the private key stays offline on a hardware wallet
  • Auditing — share your xpub with an accountant for tax reporting without granting spending access
  • Multi-device setups — a phone watches balances while a hardware wallet handles signing

Serialization Prefixes

Extended keys are Base58Check-encoded with version bytes. The familiar ypub/zpub labels are SLIP-0132 wallet conventions that communicate an intended script family; they are not prefixes defined by BIP49 or BIP84 themselves. A plain xpub alone does not prove which address type a wallet should derive, so preserve the descriptor or derivation metadata with it.

Public Private Serialization convention Common interpretation
xpub xprv BIP32 version bytes Generic extended key; often treated as legacy by older software
ypub yprv SLIP-0132 Nested SegWit P2SH-P2WPKH
zpub zprv SLIP-0132 Native SegWit P2WPKH

Do not share your xpub publicly. It lets others derive the addresses in that account branch and track their transactions and balance, even though it cannot spend funds by itself. A watch-only key can therefore expose substantial financial history.

Two ways to lose privacy

A single receiving address exposes activity associated with that address. An account xpub lets its recipient derive many addresses in that branch. A watch-only copy therefore has a smaller spending risk, but can have a much larger privacy impact.

Source: BIP32 security and extended keys.

UTXO Model vs. Account Model

How a wallet tracks and spends funds depends on the underlying blockchain model. The two dominant models are fundamentally different in design:

UTXO Model (Bitcoin, Litecoin, Cardano)

In the Unspent Transaction Output (UTXO) model, there is no concept of a "balance." Instead, your wallet scans the blockchain for unspent outputs assigned to your addresses. To spend, you consume one or more UTXOs as inputs and create new outputs:

  • Each UTXO can only be spent once and in full
  • If the UTXO exceeds the payment amount, the wallet creates a change output back to itself
  • Transaction fees are implicit: fee = sum(inputs) - sum(outputs)

Account-Based Models (Ethereum, Solana, BNB Chain)

Account-based chains maintain state associated with accounts rather than consuming UTXOs. Ethereum and BNB Chain use a sequential transaction nonce for each externally owned account. Solana also uses accounts, but transaction freshness and replay protection normally rely on a recent blockhash (or a durable nonce account), not an Ethereum-style per-address transaction counter.

  • Simpler mental model — just "balance minus amount"
  • No change outputs needed
  • Replay protection is chain-specific: sequential account nonces on Ethereum-like chains; recent blockhashes or durable nonce accounts on Solana

The wallet’s work changes with the chain. Bitcoin requires input selection and change handling. Account-based chains require their own state, fee and replay-protection rules. Neither model makes every wallet implementation simple.

Address Types and Script Formats

Bitcoin supports multiple address types, each corresponding to a different script template that defines the spending conditions:

P2PKH (Pay-to-Public-Key-Hash)

The original Bitcoin address format. The locking script requires a signature and public key that hashes to the specified value. Addresses start with 1.

P2SH (Pay-to-Script-Hash)

Allows arbitrary spending conditions encoded in a script. The sender only needs the hash of the script — the full script is revealed at spending time. This enables multi-sig, time-locks, and other complex conditions. Addresses start with 3.

P2WPKH (Native SegWit)

Segregated Witness version 0. Moves signature data to a separate "witness" structure outside the base transaction, reducing the effective size and thus the fee. Addresses use Bech32 encoding and start with bc1q.

P2TR (Taproot)

The latest address type (SegWit v1), combining Schnorr signatures with MAST (Merkelized Abstract Syntax Trees). A P2TR output can be spent either via a key path (simple Schnorr signature) or a script path (reveals only the executed branch of a script tree). Addresses use Bech32m encoding and start with bc1p.

Check compatibility before comparing fees. The sender, signer and recovery software must support the address type. Fees also depend on transaction structure and fee rate, so no format is cheapest for every spend.

Recovery metadata is part of the design

Write down the network, script type, account path and watch-only source. Check that the coordinator and signer agree on receiving and change addresses before relying on the setup.

Questions that remain

Do I need a separate wallet for each cryptocurrency?

Not necessarily. HD wallets supporting BIP44 can derive keys for multiple coin types from a single seed phrase. Each cryptocurrency uses a different derivation path (e.g., m/44'/0' for Bitcoin, m/44'/60' for Ethereum). However, not all wallet software supports all coins — you may need different apps to access different chains, even if they all derive from the same seed.

What happens if my wallet software stops being maintained?

A compatible seed phrase is necessary, but it may not be sufficient by itself. Recovery can also require the exact BIP39 passphrase, derivation path, script or address type, account index and an adequate address-gap scan; multisig additionally needs its policy or descriptor. Record this metadata and test recovery with a small amount before depending on another wallet.

Is it safe to share my extended public key (xpub)?

Sharing your xpub allows the recipient to see all past and future addresses and balances for that account. While they cannot spend your funds, it is a significant privacy leak — they can track your entire financial activity for that account. Only share xpubs with trusted parties like your accountant, and consider using a dedicated account branch for shared access.

Can a wallet have multiple seed phrases?

Some wallet software allows managing multiple accounts, each derived from a different seed. However, each seed independently generates its own key tree. You must back up each seed separately. For most users, a single seed with multiple accounts (different derivation paths or passphrase-based hidden wallets) is more manageable than multiple seeds.

Why do I get a different address every time I receive crypto?

HD wallets automatically generate a new receiving address after each use to improve your privacy. If you reused one address, anyone who knows it could trace all your transactions. With fresh addresses, each payment is harder to link to your identity. All these addresses are still derived from your single seed phrase and will be recovered during wallet restoration.

[ CHECK YOURSELF ]

Test Your Knowledge

Take a quick quiz to check your understanding of this guide.

Take the Quiz

5 questions per level · ~2 min