18

Both Bitcoin and Ethereum private keys are usually a 256-bit number, isn't it possible to use the same private key for both Bitcoin wallets and Ethereum accounts?

For instance, the Bitcoin wiki states:

In Bitcoin, a private key is usually a 256-bit number (some newer wallets may use between 128 and 512 bits), which can be represented one of several ways. Here is a private key in hexadecimal - 256 bits in hexadecimal is 32 bytes, or 64 characters in the range 0-9 or A-F.

E9 87 3D 79 C6 D8 7D C0 FB 6A 57 78 63 33 89 F4 45 32 13 30 3D A6 1F 20 BD 67 FC 23 3A A3 32 62

Which is (removed the whitespaces):

e9873d79c6d87dc0fb6a5778633389f4453213303da61f20bd67fc233aa33262

With MyEtherWallet I generated the corresponding public key for Ethereum:

0x60751Ab56d58781069b1C73064aD580dAde1F469

Now I see not every 256-bit number is a valid ECDSA private key for bitcoin. Can I use the same private key for Ethereum and Bitcoin? Is there a convenient way to generate both the ETH and BTC public key from any 256-bit random number?

This would be a cool way to store Ether and Bitcoin on the same account. Is it possible?

18

Yes, both cryptocoins use the same elliptic curve SECP256K1.

Perhaps a better alternative is to use a BIP32 wallet. You have a master key that is not directly used for transactions, but it is used to derive child keys than can be used.

You can derive separate keys for bitcoin and ethereum. You will always be able to use the master key to sign transactions for both keys.

  • @5chdn check out BIP 44 for a wallet scheme that enables using multiple cryptocurrencies with the same HD private key – Loourr Oct 7 '17 at 21:42
  • "Yes, you can"...but how does one do so? If I already have an appropriately backed up appropriately secured cold bitcoin wallet, how can I just reuse it for ethereum? – JamesTheAwesomeDude Dec 11 '17 at 21:08
  • @JamesTheAwesomeDude If you have a BIP44 compatible wallet, you can generate keys using a path. For ethereum the more common path is m/44'/60'/0'/0, but there's no standarized path ethereum.stackexchange.com/questions/19055/… and github.com/ethereum/EIPs/issues/84. – Ismael Dec 11 '17 at 22:10
0

maybe my 2 tools help in creating keys and testing keys.

i made 2 tools:

https://free-online-app.com/bitcoin-2-ethereum-address-converter/

it looks up a bitcoin address on the blockchain. if the address did at least one send, it has its public key retrievable. from the (sometimes compressed) public key it calculates the long pubkey (X and Y) and from these two it can generate a valid ethereum address which can be used with the same private key as the bitcoin address.

also i made this tool:

https://free-online-app.com/bitcoin-ethereum-private-key-converter/

this takes an ETH or BTC private key and generates both an ETH and a BTC address & keys from it. so if you generate a eth-address with the first tool, you can take the second tool to convert your privkey to use in an eth wallet

New contributor
brocard is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Welcome to the Ethereum Stack Exchange! Do you have the code to the tools as open source? Some flags have been raised about this answer. If the code is open source, linking to the code (and the code can mention your website) will probably reduce concerns about this answer advertising a website, especially one that is handling private keys. (Your essentially duplicate answers to similar questions will also be deleted for now.) – eth 2 days ago
  • the code is the html/js app in the link. it can be copied from the url and used offline. – brocard yesterday
0

Self-answering my own question 4 years later: Yes!

I wrote an Secp256k1 implementation in Crystal: github.com/q9f/secp256k1.cr

In that process, I implemented both key management for Bitcoin and Ethereum. The same keypair can be used to retrieve Bitcoin and Ethereum formatted addresses:

generate a compressed bitcoin mainnet address:

key = Secp256k1::Keypair.new

btc = Secp256k1::Bitcoin::Account.new key
btc.address
# => "1Q1zbmPZtS2chwxpviqz6qHgoM8UUuviGN"

eth = Secp256k1::Ethereum::Account.new key
eth.address
# => "0x224008a0F3d3cB989c807F568c7f99Bf451328A6"

The Github repository contains more examples. Interesting benefit: This way you could use the Bitcoin wallet-import format (WIF) for Ethereum accounts or even mini private keys.

Your Answer

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

Not the answer you're looking for?Browse other questions tagged or ask your own question.