com.google.bitcoin.crypto
Class DeterministicKey

java.lang.Object
  extended by com.google.bitcoin.crypto.DeterministicKey
All Implemented Interfaces:
Serializable

public class DeterministicKey
extends Object
implements Serializable

A deterministic key is a node in a DeterministicHierarchy. As per the BIP 32 specification it is a pair (key, chaincode). If you know its path in the tree you can derive more keys from this.

See Also:
Serialized Form

Method Summary
 byte[] getChainCode()
          Returns the chain code associated with this key.
 ChildNumber getChildNumber()
          Returns the last element of the path returned by getChildNumberPath()
 com.google.common.collect.ImmutableList<ChildNumber> getChildNumberPath()
          Returns the path through some DeterministicHierarchy which reaches this keys position in the tree.
 byte[] getFingerprint()
          Returns the first 32 bits of the result of getIdentifier().
 byte[] getIdentifier()
          Returns RIPE-MD160(SHA256(pub key bytes)).
 DeterministicKey getParent()
           
 String getPath()
          Returns the path of this key as a human readable string starting with M to indicate the master key.
 BigInteger getPrivAsFieldElement()
           
 byte[] getPrivKeyBytes()
          Returns the private key bytes, if they were provided during construction.
 byte[] getPrivKeyBytes33()
           
 byte[] getPubKeyBytes()
           
 DeterministicKey getPubOnly()
          Returns the same key with the private part removed.
 boolean hasPrivate()
           
 byte[] serializePrivate()
           
 String serializePrivB58()
           
 String serializePubB58()
           
 byte[] serializePublic()
           
 ECKey toECKey()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getChildNumberPath

public com.google.common.collect.ImmutableList<ChildNumber> getChildNumberPath()
Returns the path through some DeterministicHierarchy which reaches this keys position in the tree. A path can be written as 1/2/1 which means the first child of the root, the second child of that node, then the first child of that node.


getChildNumber

public ChildNumber getChildNumber()
Returns the last element of the path returned by getChildNumberPath()


getChainCode

public byte[] getChainCode()
Returns the chain code associated with this key. See the specification to learn more about chain codes.


getPath

public String getPath()
Returns the path of this key as a human readable string starting with M to indicate the master key.


getIdentifier

public byte[] getIdentifier()
Returns RIPE-MD160(SHA256(pub key bytes)).


getPubKeyBytes

public byte[] getPubKeyBytes()

getFingerprint

public byte[] getFingerprint()
Returns the first 32 bits of the result of getIdentifier().


getPrivAsFieldElement

@Nullable
public BigInteger getPrivAsFieldElement()

getParent

@Nullable
public DeterministicKey getParent()

getPrivKeyBytes

@Nullable
public byte[] getPrivKeyBytes()
Returns the private key bytes, if they were provided during construction.


getPrivKeyBytes33

public byte[] getPrivKeyBytes33()
Returns:
private key bytes, padded with zeros to 33 bytes.

getPubOnly

public DeterministicKey getPubOnly()
Returns the same key with the private part removed. May return the same instance.


hasPrivate

public boolean hasPrivate()

toECKey

public ECKey toECKey()

serializePubB58

public String serializePubB58()

serializePrivB58

public String serializePrivB58()

serializePublic

public byte[] serializePublic()

serializePrivate

public byte[] serializePrivate()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014. All rights reserved.