Compliant implementation of the BIP-32 specification for Hierarchical Deterministic Wallets.
Using maven:
mvn package
Importing a Base58Check serialized wallet:
String base58PrivateKey = "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi";
ExtendedKeyPair extendedPrivateKey = ExtendedKeyPair.parseBase58Check(base58PrivateKey);
Serializing an extended key:
String base58PrivateKey = "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi";
ExtendedKeyPair extendedPrivateKey = ExtendedKeyPair.parseBase58Check(base58PrivateKey);
String serializedPublicKey = extendedPrivateKey.serializePub();
String serializedPrivateKey = extendedPrivateKey.serializePriv();
Generating ancestors of an extended key:
ExtendedKeyPair masterKey = Bip32.generateMasterKey(new byte[]{0, 0, 0, 0});
ExtendedKeyPair childKey = masterKey.generate("m/0/2147483647H/1");
I have included Bitcoinj out of laziness. To avoid pulling in Bitcoinj, I would need to implement Base58 in this library.