@Test public void testBip32Key() throws NoSuchAlgorithmException, SignatureException, InvalidKeyException { String rootKey = "38d2c44314c401b3ea7c23c54e12c36a527aee46a7f26b82443a46bf40583e439dea25de09b0018b35a741d8cd9f6ec06bc11db49762617485f5309ab72a12d4"; byte[] derivePrivateKey = DerivePrivateKey.bip32derivePrvKey(rootKey, 2, (byte) 0); System.out.println(Hex.toHexString(derivePrivateKey)); }
public static byte[] bip32derivePrvKey(String rootPrivateKey, int accountIndex, byte keySpace, long ...programIndex) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException { byte[] res = Hex.decode(rootPrivateKey); byte[][] paths = PathUtil.getBip32Path(keySpace, accountIndex, programIndex); for (int i = 0; i < paths.length; i++) { byte[] xpub = DeriveXpub.deriveXpub(res); res = NonHardenedChild.nhChild(paths[i], res, xpub); } return res; }
DerivePrivateKey { public static byte[] bip32derivePrvKey(String rootPrivateKey, int accountIndex, byte keySpace, long ...programIndex) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException { byte[] res = Hex.decode(rootPrivateKey); byte[][] paths = PathUtil.getBip32Path(keySpace, accountIndex, programIndex); for (int i = 0; i < paths.length; i++) { byte[] xpub = DeriveXpub.deriveXpub(res); res = NonHardenedChild.nhChild(paths[i], res, xpub); } return res; } }
DerivePrivateKey { public static byte[] bip32derivePrvKey(String rootPrivateKey, int accountIndex, byte keySpace, long ...programIndex) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException { byte[] res = Hex.decode(rootPrivateKey); byte[][] paths = PathUtil.getBip32Path(keySpace, accountIndex, programIndex); for (int i = 0; i < paths.length; i++) { byte[] xpub = DeriveXpub.deriveXpub(res); res = NonHardenedChild.nhChild(paths[i], res, xpub); } return res; }  }
DerivePrivateKey { public static byte[] bip32derivePrvKey(String rootPrivateKey, int accountIndex, byte keySpace, long ...programIndex) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException { byte[] res = Hex.decode(rootPrivateKey); byte[][] paths = PathUtil.getBip32Path(keySpace, accountIndex, programIndex); for (int i = 0; i < paths.length; i++) { byte[] xpub = DeriveXpub.deriveXpub(res); res = NonHardenedChild.nhChild(paths[i], res, xpub); } return res; }  static byte[] bip44derivePrvKey(String rootPriv, int accountIndex, boolean change, int programIndex); static byte[] bip32derivePrvKey(String rootPrivateKey, int accountIndex, byte keySpace, long ...programIndex); }
DerivePrivateKey { public static byte[] bip32derivePrvKey(String rootPrivateKey, int accountIndex, byte keySpace, long ...programIndex) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException { byte[] res = Hex.decode(rootPrivateKey); byte[][] paths = PathUtil.getBip32Path(keySpace, accountIndex, programIndex); for (int i = 0; i < paths.length; i++) { byte[] xpub = DeriveXpub.deriveXpub(res); res = NonHardenedChild.nhChild(paths[i], res, xpub); } return res; }  static byte[] bip44derivePrvKey(String rootPriv, int accountIndex, boolean change, int programIndex); static byte[] bip32derivePrvKey(String rootPrivateKey, int accountIndex, byte keySpace, long ...programIndex);  }