Skip to content

Instantly share code, notes, and snippets.

@raypulver
Created January 8, 2018 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raypulver/83a68c60a9e4f466d41edd48809e9c5c to your computer and use it in GitHub Desktop.
Save raypulver/83a68c60a9e4f466d41edd48809e9c5c to your computer and use it in GitHub Desktop.
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