I create a transaction with signTransaction and I have an output like this:

"signedTx": {
    "messageHash": "0x..",
    "v": "0x..",
    "r": "0x..",
    "s": "0x..",
    "rawTransaction": "0x....."

Now I want to retrieve public key using v r and s And verify the signature


you can use ecRecover function in web3@1.0.0

web3.eth.personal.ecRecover(dataThatWasSigned, signature [, callback])


web3.eth.personal.ecRecover("Hello world", "0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400").then(console.log);


Or you can use ethereumjs-utils library function ecrecover

Edit You can use this to recover public address

const publicKey = util.ecrecover(util.sha3('test'), sig.v, sig.r, sig.s);
const address = util.pubToAddress(publicKey).toString('hex');

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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