mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 15:50:28 +01:00
24 lines
678 B
JavaScript
24 lines
678 B
JavaScript
|
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')
|
||
|
},
|
||
|
|
||
|
}
|
||
|
|
||
|
function padWithZeroes (number, length) {
|
||
|
var myString = '' + number
|
||
|
while (myString.length < length) {
|
||
|
myString = '0' + myString
|
||
|
}
|
||
|
return myString
|
||
|
}
|