Accordingly to the BIP32/BIP44 specification recommendations I generating HD Wallet addresses using bitcoinj library (DeterministicKey instances) with the path like M/44'/60'/0'/0/0 using xpub key only (non-hardened keys can derive child public key without knowing private keys) to use them later for funds receiving operations only. But I was unable to get corresponding Ethereum address using web3j library, as I getting "Private key bytes not available" error (that is of course true).

My code sample for the address generation:

String xpub = "xpub6Df54KC7ti7yvkfDAwsL4QJ1a69GeMM1ChaNqSnGzbpFdxd4PCy1FzdPVftoBYFA4ogmvDUccUbEhGsozE1YkXtQ2YMxAXWKcM8cBxYD6cp";
DeterministicKey extKey = DeterministicKey.deserializeB58(xpub,mainnetParams);
DeterministicKey addrKey = HDKeyDerivation.deriveChildKey(extKey,0);
Credentials credentials = Credentials.create(addrKey.getPrivateKeyAsHex());

returned keys fully corresponds to the https://iancoleman.io/bip39/ results. The error raises on the addrKey.getPrivateKeyAsHex() call.

Also I tried another way:

System.out.println("address from pub=" + Keys.getAddress(addrKey.getPublicKeyAsHex()));

but in this case the result does not look correct accordingly to https://iancoleman.io/bip39/

Is it possible at all to generate Ethereum address without private key?

Any advice/explanation/link highly appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.