|
| 1 | +# SLIP-0032 : Extended serialization format for BIP-32 wallets |
| 2 | + |
| 3 | +``` |
| 4 | +Number: SLIP-0032 |
| 5 | +Title: Extended serialization format for BIP-32 wallets |
| 6 | +Type: Standard |
| 7 | +Status: Draft |
| 8 | +Authors: Pavol Rusnak <[email protected]> |
| 9 | +Created: 2017-09-06 |
| 10 | +``` |
| 11 | + |
| 12 | +## Abstract |
| 13 | + |
| 14 | +BIP-0032 already defines a serialization format for hierarchical deterministic |
| 15 | +keys. In this document we present extended version of the serialization |
| 16 | +format, which aims to overcome some limitations of the original proposal. |
| 17 | + |
| 18 | +## Changes |
| 19 | + |
| 20 | +First modification is including full BIP-32 path of the exported node, so |
| 21 | +wallet can check whether the provided key was exported from expected part of |
| 22 | +the deterministic hierarchy. |
| 23 | + |
| 24 | +Second modification is removal of fingerprint field, which was barely used by |
| 25 | +wallets and introduces unnecessary extra computation steps during serialization |
| 26 | +of the key. Sometimes it is even not possible to compute the fingerprint at all |
| 27 | +(when the parent key is unknown). |
| 28 | + |
| 29 | +Third modification is the addition of "birthday" attribute, which describes the |
| 30 | +moment, when the deterministic hierarchy was generated. |
| 31 | + |
| 32 | +Last modification is the change from Base58 encoding to Bech32 encoding, which |
| 33 | +is more efficient in many areas. |
| 34 | + |
| 35 | +## Serialization format |
| 36 | + |
| 37 | +Extended public and private keys are serialized as follows: |
| 38 | + |
| 39 | +* 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 derived keys, ... |
| 40 | +* 4 * depth bytes: serialized BIP-32 path; each entry is encoded as 32-bit unsigned integer, most significant byte first |
| 41 | +* 4 bytes: wallet birthdate; number of seconds since 2009-01-09 00:00 UTC (equals to Unix epoch minus 1230768000); encoded as 32-bit unsigned integer, most significant byte first; use zero to not use birthdate |
| 42 | +* 32 bytes: the chain code |
| 43 | +* 33 bytes: the public key or private key data (ser<sub>P</sub>(K) for public keys, 0x00 || ser<sub>256</sub>(k) for private keys) |
| 44 | + |
| 45 | +This structure is encoded using Bech32 format described in BIP-0137. We will |
| 46 | +use 'xpub' human-readable part for extended public keys and 'xprv' for extended |
| 47 | +private keys. |
| 48 | + |
| 49 | +## References |
| 50 | + |
| 51 | +* [BIP-0032: Hierarchical Deterministic Wallets](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) |
| 52 | +* [BIP-0173: Base32 address format for native v0-16 witness outputs](https://github.com/bitcoin/bips/blob/master/bip-0137.mediawiki) |
0 commit comments