diff options
author | kumavis <kumavis@users.noreply.github.com> | 2017-01-17 07:02:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-17 07:02:24 +0800 |
commit | ee62a6a3913967a6840d28ca812b94bbfa7a5779 (patch) | |
tree | cac32de6cc520917db9621ce93f7f4ad9abd787e /app/scripts/lib/sig-util.js | |
parent | e8e06542e47b41668f196b6db54290490003845b (diff) | |
parent | 88fabdd2de78d0dd4be86b02c94a64d9748667fa (diff) | |
download | tangerine-wallet-browser-ee62a6a3913967a6840d28ca812b94bbfa7a5779.tar tangerine-wallet-browser-ee62a6a3913967a6840d28ca812b94bbfa7a5779.tar.gz tangerine-wallet-browser-ee62a6a3913967a6840d28ca812b94bbfa7a5779.tar.bz2 tangerine-wallet-browser-ee62a6a3913967a6840d28ca812b94bbfa7a5779.tar.lz tangerine-wallet-browser-ee62a6a3913967a6840d28ca812b94bbfa7a5779.tar.xz tangerine-wallet-browser-ee62a6a3913967a6840d28ca812b94bbfa7a5779.tar.zst tangerine-wallet-browser-ee62a6a3913967a6840d28ca812b94bbfa7a5779.zip |
Merge pull request #1005 from MetaMask/dev
Merge dev into master!
Diffstat (limited to 'app/scripts/lib/sig-util.js')
-rw-r--r-- | app/scripts/lib/sig-util.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/scripts/lib/sig-util.js b/app/scripts/lib/sig-util.js new file mode 100644 index 000000000..193dda381 --- /dev/null +++ b/app/scripts/lib/sig-util.js @@ -0,0 +1,28 @@ +const ethUtil = require('ethereumjs-util') + +module.exports = { + + concatSig: function (v, r, s) { + const rSig = ethUtil.fromSigned(r) + const sSig = ethUtil.fromSigned(s) + const vSig = ethUtil.bufferToInt(v) + const rStr = padWithZeroes(ethUtil.toUnsigned(rSig).toString('hex'), 64) + const sStr = padWithZeroes(ethUtil.toUnsigned(sSig).toString('hex'), 64) + const vStr = ethUtil.stripHexPrefix(ethUtil.intToHex(vSig)) + return ethUtil.addHexPrefix(rStr.concat(sStr, vStr)).toString('hex') + }, + + normalize: function (address) { + if (!address) return + return ethUtil.addHexPrefix(address.toLowerCase()) + }, + +} + +function padWithZeroes (number, length) { + var myString = '' + number + while (myString.length < length) { + myString = '0' + myString + } + return myString +} |