Class HierarchicalDeterministicKey


  • public class HierarchicalDeterministicKey
    extends java.lang.Object
    The procedure to implement BIP32 or SLIP 10 to generate deterministic keys hierarchically https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki https://github.com/satoshilabs/slips/blob/master/slip-0010.md
    Since:
    0.3.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] childKeyDerivation​(byte[] key, byte[] chainCode, byte[] init)
      CKD function in Bipt32 and Slip10
      static byte[] getFromSeed​(byte[] seed, byte[] init, int[] derivationPath)  
      static byte[] getMasterKeyFromSeed​(byte[] seed, byte[] key)
      Derives the masterkey given a seed byte array
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HierarchicalDeterministicKey

        public HierarchicalDeterministicKey()
    • Method Detail

      • getFromSeed

        public static byte[] getFromSeed​(byte[] seed,
                                         byte[] init,
                                         int[] derivationPath)
                                  throws java.io.IOException
        Parameters:
        seed - byte array containing the seed
        init - chaincode, that is the rightmost 32 bytes of the key
        derivationPath - path to follow when deriving the key
        Returns:
        derived key in byte array
        Throws:
        java.io.IOException - if an error occurs when processing the bytestream
      • getMasterKeyFromSeed

        public static byte[] getMasterKeyFromSeed​(byte[] seed,
                                                  byte[] key)
        Derives the masterkey given a seed byte array
        Parameters:
        seed - byte array containing the seed
        key - initial Hmac value
        Returns:
        master key as a byte array
      • childKeyDerivation

        public static byte[] childKeyDerivation​(byte[] key,
                                                byte[] chainCode,
                                                byte[] init)
                                         throws java.io.IOException
        CKD function in Bipt32 and Slip10
        Parameters:
        key - master key, that is the leftmost 32 bytes of the key
        chainCode - hierarchical chain code 'a/b/c' but in array format: { a, b, c}
        init - chaincode, that is the rightmost 32 bytes of the key
        Returns:
        master key as a byte array
        Throws:
        java.io.IOException - if an error occurs when processing the bytestream