com.google.bitcoin.crypto
Class HDKeyDerivation
java.lang.Object
com.google.bitcoin.crypto.HDKeyDerivation
public final class HDKeyDerivation
- extends Object
Implementation of the (public derivation version) deterministic wallet child key generation algorithm.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
createMasterPrivateKey
public static DeterministicKey createMasterPrivateKey(byte[] seed)
throws HDDerivationException
- Generates a new deterministic key from the given seed, which can be any arbitrary byte array. However resist
the temptation to use a string as the seed - any key derived from a password is likely to be weak and easily
broken by attackers (this is not theoretical, people have had money stolen that way). This method checks
that the given seed is at least 64 bits long.
- Throws:
HDDerivationException - if generated master key is invalid (private key 0 or >= n).
IllegalArgumentException - if the seed is less than 8 bytes and could be brute forced.
createMasterPrivKeyFromBytes
public static DeterministicKey createMasterPrivKeyFromBytes(byte[] privKeyBytes,
byte[] chainCode)
throws HDDerivationException
- Throws:
HDDerivationException - if privKeyBytes is invalid (0 or >= n).
createMasterPubKeyFromBytes
public static DeterministicKey createMasterPubKeyFromBytes(byte[] pubKeyBytes,
byte[] chainCode)
deriveChildKey
public static DeterministicKey deriveChildKey(DeterministicKey parent,
int childNumber)
- Parameters:
childNumber - the "extended" child number, ie. with the 0x80000000 bit specifying private/public derivation.
deriveChildKey
public static DeterministicKey deriveChildKey(DeterministicKey parent,
ChildNumber childNumber)
throws HDDerivationException
- Throws:
HDDerivationException - if private derivation is attempted for a public-only parent key, or
if the resulting derived key is invalid (eg. private key == 0).
Copyright © 2014. All rights reserved.