28

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?

2 Answers 2

27

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.

3
  • @5chdn check out BIP 44 for a wallet scheme that enables using multiple cryptocurrencies with the same HD private key
    – Loourr
    Commented Oct 7, 2017 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? Commented Dec 11, 2017 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
    Commented Dec 11, 2017 at 22:10
6

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 and acknowledge you have read our privacy policy.

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