I am trying to sign a message using the following code:ethJsUtil.ecsign(ethJsUtil.sha256(msg),new Buffer('0x...'))

Where 0x... is my private key taken from MyEtherWallet. It gives the error in the title both with and without the 0x at the beginning

2 Answers 2


ethJsUtil.ecsign(ethJsUtil.sha256(msg),ethJsUtil.toBuffer('0x...')) works. new Buffer was returning an empty buffer


Basically you pasted:

node ./keygen.js 0xdd0c9ec256a7e76a6693a0d2dea01a6de6b7dfeaf3afcaef7b95647758c79c1a  

Instead of:

node ./keygen.js dd0c9ec256a7e76a6693a0d2dea01a6de6b7dfeaf3afcaef7b95647758c79c1a  
  • Please explain the relevance of this answer. It's been flagged by two different users and I reluctantly will clean this up if it gets another flag.
    – eth
    Commented Jul 14, 2017 at 19:50

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.