[Ethereum] Convert a Bitcoin private key into an Ethereum address

addressesbitcoinprivate-key

I'm currently using the lightwallet.js for ethereum and it seems to only accept a mnemonic seed to generate an ethereum address. I want to be able to use my Bitcoin private key to generate an ethereum address. I'm able to generate a bitcoin private key using bitcoinjs library, but I can't seem to figure out how I can do this with ethereum using a bitcoin private key. Is there a specific library I need to use?

Best Answer

A private key in both bitcoin and ethereum is simply a random 256 bit number (actually a number between 0 and the order of the secp256k1 curve, but that's not really important).

If you can get your raw bitcoin public key, i.e.something like a random hex string of length 64, then it can be used directly as a raw ETH private key in any library or client.

For example, to import it into geth just use

geth account import <(my_privkey)

for parity see How to import a plain private key into Parity?

To simply derive an address from the key in JS, you can use the keythereum library or ethereumjs-util

You can even use openssl, see https://kobl.one/blog/create-full-ethereum-keypair-and-address/

Related Topic