Last active
July 6, 2018 19:29
-
-
Save maxidev/b74ce427bdae6c501b39d279d843c547 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ethUtil = require('ethereumjs-util'); | |
var ethTx = require('ethereumjs-tx'); | |
var privkey = ""; | |
var privBuff = new Buffer(privkey, "hex"); | |
var msg = ethUtil.sha3("The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"); | |
var sign = ethUtil.ecsign(msg, privBuff); | |
console.log(sign); | |
var signedHash = ethUtil.toRpcSig(sign.v, sign.r, sign.s); | |
var sigDecoded = ethUtil.fromRpcSig(signedHash); | |
console.log("SigDecoded", sigDecoded); | |
var recoveredPub = ethUtil.ecrecover(ethUtil.sha3("The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"), sigDecoded.v, sigDecoded.r, sigDecoded.s); | |
var recoveredAddress = ethUtil.addHexPrefix(ethUtil.pubToAddress(recoveredPub).toString("hex")); | |
console.log("Recoverered Addr", recoveredAddress); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment