Secp256k1 – Fixing Compilation Issues with Pure JS Implementation

meteorsecp256k1signature

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?

Best Answer

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

Related Topic