diff options
author | Kevin Serrano <kevgagser@gmail.com> | 2016-11-19 01:23:20 +0800 |
---|---|---|
committer | Kevin Serrano <kevgagser@gmail.com> | 2016-11-19 01:23:20 +0800 |
commit | bef023fb4a699c16fe0fff30ce18840678ed7ad0 (patch) | |
tree | d11be9af938712aeb554f070822be01b2d7fbceb /app/scripts/lib/sig-util.js | |
parent | 37d836fa72c75945d436bd94feadb65aa95d7e5f (diff) | |
parent | 39e0a33bba2709971edec0304027f646cb2db3cc (diff) | |
download | tangerine-wallet-browser-bef023fb4a699c16fe0fff30ce18840678ed7ad0.tar tangerine-wallet-browser-bef023fb4a699c16fe0fff30ce18840678ed7ad0.tar.gz tangerine-wallet-browser-bef023fb4a699c16fe0fff30ce18840678ed7ad0.tar.bz2 tangerine-wallet-browser-bef023fb4a699c16fe0fff30ce18840678ed7ad0.tar.lz tangerine-wallet-browser-bef023fb4a699c16fe0fff30ce18840678ed7ad0.tar.xz tangerine-wallet-browser-bef023fb4a699c16fe0fff30ce18840678ed7ad0.tar.zst tangerine-wallet-browser-bef023fb4a699c16fe0fff30ce18840678ed7ad0.zip |
Resolve merge conflict.
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 +} |