BIP32把每个密钥与256位链码配对,通过HMAC-SHA512和编号路径派生子密钥。xpub可派生普通公共后代,hardened分支需要私密材料;这既支持委托,也精确界定泄露后果。
Pieter Wuille编写BIP32,2012年2月11日分配。层级结构可委托账户或收款分支而不暴露其他分支。它不是共识规则,也不定义助记词、passphrase、script或地址发现;BIP39、路径和descriptor属于不同层。 [BIP 32 — Hierarchical deterministic wallets] [BIP 39 — Mnemonic code for deterministic keys] [Bitcoin Developer Guide — Wallets]
扩展私钥是secp256k1标量k加32字节链码c;公开形式以K=point(k)替代k。以‘Bitcoin seed’为key的HMAC-SHA512输出IL主私钥候选和IR链码。IL为0或不小于曲线阶n时seed无效。 [BIP 32 — Hierarchical deterministic wallets]
CKDpriv把parse256(IL)与父标量模n相加,IR作为子链码。普通输入是serP(Kpar)||ser32(i),hardened是0x00||ser256(kpar)||ser32(i),i≥2^31。CKDpub只能生成普通公共子密钥。 [BIP 32 — Hierarchical deterministic wallets]
xpub能生成所有普通公共后代。但父xpub加任一泄露的non-hardened子私钥即可恢复父私钥并危及同级分支。hardened阻止这一特定逆推,却不能抵御seed被盗、弱随机或用户误批恶意交易。 [BIP 32 — Hierarchical deterministic wallets]
Base58Check前序列化为78字节:version、depth、4字节父fingerprint、child number、chain code和33字节key data。mainnet xprv/xpub通常111字符。短fingerprint不是无碰撞认证;SLIP132的ypub/zpub兼容性不统一。 [BIP 32 — Hierarchical deterministic wallets] [SLIP 132 — Registered HD version bytes]
BIP43使用purpose'。BIP44路径为m/44'/coin_type'/account'/change/index,外部0、找零1、gap limit 20;BIP48用于multisig,BIP84用于SegWit,BIP86用于Taproot。这些是钱包约定,不在seed中,也非节点规则;'表示加2^31。 [BIP 43 — Purpose field for deterministic wallets] [BIP 44 — Multi-account hierarchy] [BIP 48 — Multi-script hierarchy for multisig wallets] [BIP 84 — Native SegWit derivation] [BIP 86 — Single-key Taproot derivation]
限定范围的xpub可只读监控和生成地址,却会暴露该子树过去未来地址、余额和时间关联。受控host仍可能替换地址;重要收款地址应在可信签名设备屏幕核对。 [BIP 32 — Hierarchical deterministic wallets] [Bitcoin Developer Guide — Wallets] [Trezor Learn — Hierarchical deterministic wallets]
xpub不描述script。descriptor加入origin [fingerprint/path]、wpkh()等wrapper、multisig门槛和cosigner、wildcard及checksum。一个multisig seed不能恢复其他xpub、顺序或门槛;需备份测试过的descriptor。 [BIP 380 — Output script descriptors] [BIP 389 — Multipath descriptor key expressions] [Bitcoin Core — Output descriptors] [Bitcoin Optech — Output script descriptors]
根seed可重建所有密钥,但恢复还需passphrase、格式、网络、purpose/script、coin type、account、receive/change、gap policy及multisig descriptor。余额为零常因搜索错树;应测试历史UTXO发现与签名。 [BIP 44 — Multi-account hierarchy] [BIP 380 — Output script descriptors] [Bitcoin Core — Output descriptors] [BIP 39 — Mnemonic code for deterministic keys]
极少见的IL≥n、零标量或无穷远点需跳到下一index。更常见的是丢失origin、不同account discovery、误读ypub/zpub、遗漏change、不支持Taproot或导入错误depth。xprv能花费,xpub泄露金融数据,descriptor记录策略。 [BIP 32 — Hierarchical deterministic wallets] [BIP 380 — Output script descriptors] [SLIP 132 — Registered HD version bytes] [Bitcoin Core — Output descriptors]
要获得更完整的理解,请将本词条与以下词条结合阅读: 钱包, Seed Phrase, Extended Public Key (xpub), Derivation Path, Gap Limit, Bitcoin. 反向关联还来自: 比特币地址, BIP 39, Cold Storage, Watch-only Wallet.