6

I'd like to explore the option to verify the messages that have been signed in Bitcoin wallets in Ethereum smart contracts.

  • Ethereum smart contract is given a list of Bitcoin addresses

  • Ethereum smart contract can verify if the incoming function call msg, v, r, s matches any of previously given Bitcoin addresses

Now, the question is that the built-in ecrecover() only gives a resulting Ethereum address and I do not know how could I proceed from here.

  • Can built-in ecrecover() deal with Bitcoin addresses

  • Does there exist a way to mapBitcoin address to Ethereum address 1:1

  • Can built-in ecrecover() give full public key output?

  • If built-in ecrecover() does not work, can I write my own recover that outputs a Bitcoin address and spends reasonable gas?

  • Can I somehow preprocess Bitcoin addresses (or public keys) to Ethereum ecrecover() compatible format?

... which all kind of are related to one question

  • Do I need full Bitcoin public key as a starting point or is Bitcoin address enough?

1 Answer 1

4

Both Ethereum and Bitcoin uses the same elliptic curve for private keys secp256k1. The difference is Ethereum formats addresses as hexadecimal and bitcoin as base58.

It can be made such that ecrecover to work for both, it returns the raw 20 bytes without address formatting.

One possible issue is that Ethereum uses keccak256 for signing, and bitcoin libraries normally use sha256, so you have to use ethereum libraries for signing.

3
  • Thank you Ismael. This is exactly some pointers I needed. The problem here is that I worked from the assumption I could use the existing Bitcoin wallet signing UI for the message and then recover it on the Ethereum side. Commented Dec 8, 2017 at 9:34
  • 1
    Ismael, I have a picky request. You wrote "uses the same type of elliptic curve" but wouldn't "uses the same exact elliptic curve" be more accurate? Commented Feb 8, 2018 at 21:49
  • @DaveScotese Thanks, you are correct, both use the same elliptic curve, it should be fixed now.
    – Ismael
    Commented Feb 9, 2018 at 0:53

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.