Created
January 8, 2018 09:35
-
-
Save raypulver/83a68c60a9e4f466d41edd48809e9c5c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function generateSignature(...signingData) { | |
const raw = web3Util.soliditySha3(...signingData); | |
const salted = ethUtil.hashPersonalMessage(ethUtil.toBuffer(raw)); | |
const { | |
v, | |
r, | |
s | |
} = lodash.mapValues(ethUtil.ecsign(salted, ethUtil.toBuffer('0x'+user.pk.trim())), (value, key) => key === 'v' ? value : ethUtil.bufferToHex(value)); | |
//console.log("Signature complete! ", v, r, s); | |
return {v: v, r: r, s: s}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment