2

I am trying to create a meteor dapp that can sign a piece of data and then recover the address it was signed with. When I run the dapp I get this error in the console:

Secp256k1 bindings are not compiled. Pure JS implementation will be used

I believe this is causing issues with web3.eth.sign as I cannot recover the address I signed with using ecrecover in either a contract or from ethereumjs-util.

From this answer https://ethereum.stackexchange.com/a/12684 it appears node version 5 or greater is required however meteor only supports node 4.

Is this error a problem or should I ignore it?

2
  • This is an innocent error that has no pronounced effect on web3, I have had the same for more than a year in Meteor and it has never hampered development.
    – Joël
    Mar 6, 2017 at 13:42
  • @Joël do you have any idea why I cant get the correct address from ecrecover then? ethereum.stackexchange.com/questions/12621/…
    – Joe
    Mar 6, 2017 at 14:05

1 Answer 1

2

If you use web3 to sign a message and then try to verify that message in a contract, you need to prepend the following string to the message before running ecrecover in a contract: \x19Ethereum Signed Message:\n<length of message>

There are the two places where I found this.

https://github.com/ethereum/go-ethereum/issues/3731

https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign

The Ethereum wiki page has a link after the Example in the eth_sign documentation, that links to an example of using solidity ecrecover to verify signature calculated with web3.eth.sign. Pasting it here for completeness.

https://gist.github.com/bas-vk/d46d83da2b2b4721efb0907aecdb7ebd

2
  • I have been using ecrecover from ethereumjs utils not from a contract. Do I still need to prepend the string?
    – Joe
    May 9, 2017 at 8:41
  • AFAIK, you should not need to prepend the string when using ecrecover from ethereumjs utils. You might want to confirm this by looking at the ethereumjs utils source code. I mentioned the above because you also mentioned using ecrecover in a contract when you wrote " ... cannot recover the address I signed with using ecrecover in either a contract or from ethereumjs-util." May 23, 2017 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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