public Derive<ExtendedPrivateKey> derive() { return derive(CKD_FUNCTION); }
@Override public <Path> ExtendedPrivateKey derive(final Path derivationPath, final Derivation<Path> derivation) { return derive().derive(derivationPath, derivation); }
@Override public ExtendedPrivateKey derive(final CharSequence derivationPath) { return derive().derive(derivationPath); }
public Derive<ExtendedPrivateKey> deriveWithCache() { return derive(newCacheOf(CKD_FUNCTION)); }
private static List<String> generateKeyPairs(String mnemonic) throws InvalidKeySpecException, NoSuchAlgorithmException, CipherException { // 1. we just need eth wallet for now AddressIndex ethAddressIndex = BIP44.m().purpose44().coinType(60).account(0).external().address(0); AddressIndex btcAddressIndex = BIP44.m().purpose44().coinType(0).account(0).external().address(0); // 2. calculate seed from mnemonics , then get master/root key ; Note that the bip39 passphrase we set "" for common String seed; String salt = "mnemonic"; seed = getSeed(mnemonic, salt); System.out.println(seed); ExtendedPrivateKey rootKey = ExtendedPrivateKey.fromSeed(hexStringToByteArray(seed), Bitcoin.MAIN_NET); // 3. get child private key deriving from master/root key ExtendedPrivateKey childPrivateKey = rootKey.derive(ethAddressIndex, AddressIndex.DERIVATION); // 4. get key pair byte[] privateKeyBytes = childPrivateKey.getKey(); //child private key ECKeyPair keyPair = ECKeyPair.create(privateKeyBytes); walletFile = Wallet.createLight(password, keyPair); List<String> returnList = EthAddress(childPrivateKey, keyPair); childPrivateKey = rootKey.derive(btcAddressIndex, AddressIndex.DERIVATION); bitcoinAddress(childPrivateKey); return returnList; }