-
Notifications
You must be signed in to change notification settings - Fork 498
/
BIP32.txt
40 lines (26 loc) · 2.14 KB
/
BIP32.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
BIP32 Wallets
-------------
The pycoin library implements a deterministic wallet that will securely generate Bitcoin addresses compliant with
[BIP0032].
This includes creating and parsing standard wallet keys.
The command-line utility "ku" exposes a lot of this API on the command-line.
Using this method, you can create a wallet that generates as many public keys as you need while keeping the private keys
offline. For example,
xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8
is the public wallet the corresponds to the the private wallet
xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi
First, you generate a Wallet object from either a master secret (so a pass phrase of some kind) or a wallet key, like one
of the above. Note: pass phrases must be absolutely unguessable. Because it's so difficult to come up with an unguessable
pass phrase, it's recommended you simply generate a random key as your basis ("ku create").
A Wallet object can generate a subkey using the "subkey" method, which is a child key that can be derived from the parent
easily if you know the value for i (which ranges from 0 to 2147483647).
A private Wallet object can yield a public Wallet object (which generates only the corresponding public keys), but not
the other way around.
A private Wallet object can generate a subkey whose addresses CANNOT be derived from the corresponding public Wallet
object (to generate change addresses, for example). Set ```is_hardened=True```.
WARNING: be extremely careful giving out public wallet keys. If someone has access to a private wallet key P, of course
they have access to all descendent wallet keys of P. But if they also have access to a public wallet key K where P is a
subkey of K, you can actually work your way up the tree to determine the private key that corresponds to the public
wallet key K (unless private derivation was used at some point between the two keys)! Be sure you understand this warning
before giving out public wallet keys!
[BIP0032]: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki