2

Are web3.personal.sign and web3.eth.sign difference in value of generate signature ? Or both of them generate an equal output ?

I could test web3.eth.sign using testRPC, however web3.personal.sign with testRPC gives error and I could not compare the output of both method with the same input.

  • 1
    In general, even signing the same message twice with the same ECDSA function will give different results, since the k value is chosen randomly each time – Tjaden Hess Jul 20 '18 at 12:49
  • @Tjaden Hess Thank you, My main purpose is to run successfully JavaScript code presented here: link when i run it using node i receive some errors. Do you know what is the best way of running this JS code ? Do i need to create an html file and run it with browser ? or it's better to create a JS file and run it using node filename.js ? I describe the main question here: link Thanks – Questioner Jul 22 '18 at 13:01
2

I think I had similar problem. I couldn't get correct address from ecrecover after message was signed with personal.sign, but it works fine after it was sign with eth.sign. Then I found this on web3 docs: https://web3js.readthedocs.io/en/1.0/web3-eth-personal.html#sign

"Signs data using a specific account. This data is before UTF-8 HEX decoded and enveloped as follows: "\x19Ethereum Signed Message:\n" + message.length + message."

After I added "\x19Ethereum Signed Message:\n" and message length to signed message, from which I want to recover address, it finally return correct address.

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.