HDPrivateKey class
Provides support for Extended Private keys (Hierarchical Deterministic keys) as described in the BIP32 spec.
This is essentially a method of having a master private key, and then using what is generally referred to as a derivation path to generate a tree of keypairs which can all be deterministically derived from the original master private key.
This method of key generation is useful for enhancing one's privacy by avoiding key re-use.
Extended Private Key Serialization Format
=============================================
depth[1] chaincode[32]
\/ \/
|_________|_|________|________________________|________________________|
|^ |^ |^
|^version[4] |^fingerprint[4] |^key[33] <---> privkey(ser256(k))
4 bytes: version bytes (
mainnet:
public: 0x0488B21E ,
private: 0x0488ADE4 ;
testnet:
public: 0x043587CF ,
private: 0x04358394 )
1 byte:
depth: 0x00 for master nodes,
0x01 for level-1 derived keys, ....
4 bytes: the fingerprint of the parent key (0x00000000 if master key)
4 bytes: child number. This is ser32(i) for i in xi = xpar/i, with xi the key being serialized. (0x00000000 if master key)
32 bytes: the chain code
33 bytes: 0x00 || ser256(k) for private keys
Constructors
- HDPrivateKey.fromSeed(String seed, NetworkType networkType)
- Generate a private key from a seed, as described in BIP32
- HDPrivateKey.fromXpriv(String vector)
-
Reconstruct a private key from a standard
xpriv
string.
Properties
-
chainCode
↔ List<
int> -
getter/setter pairinherited
-
childNumber
↔ List<
int> -
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hdPublicKey → HDPublicKey
-
Returns the public key associated with this private key
no setter
-
keyBuffer
↔ List<
int> -
Retrieves the key as a byte buffer
getter/setter pairinherited
- keyType ↔ KeyType?
-
getter/setter pairinherited
- networkType ↔ NetworkType?
-
getter/setter pairinherited
- nodeDepth ↔ int?
-
getter/setter pairinherited
-
parentFingerprint
↔ List<
int> -
getter/setter pairinherited
- privateKey → SVPrivateKey
-
Converts the HDPrivateKey instance to a SVPrivateKey.
The generic APIs require SVPrivateKeys, with HDPrivateKey
only being used as a means to expose BIP32 wallet functionality
no setter
- publicKey → SVPublicKey
-
Returns the public key associated with this private key as a SVPublicKey
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
versionBytes
↔ List<
int> -
getter/setter pairinherited
- xprivkey → String
-
Returns the serialized representation of the extended private key.
no setter
- xpubkey → String
-
Returns the serialized
xpub
-encoded public key associated with this private key as a stringno setter
Methods
-
deriveChildKey(
String path) → HDPrivateKey - Derives a child private key along the specified path
-
deriveChildNumber(
int index) → HDPrivateKey - Derives a child private key specified by the index
-
deserialize(
String vector) → void -
inherited
-
getVersionBytes(
) → List< int> -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
serialize(
) → String -
inherited
-
toString(
) → String -
Returns the serialized
xpriv
-encoded private key as a string.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited