diff --git a/index.js b/index.js index c98d54f3..daacf14b 100644 --- a/index.js +++ b/index.js @@ -416,11 +416,10 @@ exports.toRpcSig = function (v, r, s) { } // geth (and the RPC eth_sign method) uses the 65 byte format used by Bitcoin - // FIXME: this might change in the future - https://github.com/ethereum/go-ethereum/issues/2053 return exports.bufferToHex(Buffer.concat([ exports.setLengthLeft(r, 32), exports.setLengthLeft(s, 32), - exports.toBuffer(v - 27) + exports.toBuffer(v) ])) } diff --git a/test/index.js b/test/index.js index e24048eb..e0866dbc 100644 --- a/test/index.js +++ b/test/index.js @@ -604,7 +604,12 @@ describe('message sig', function () { const s = Buffer.from('129ff05af364204442bdb53ab6f18a99ab48acc9326fa689f228040429e3ca66', 'hex') it('should return hex strings that the RPC can use', function () { - assert.equal(ethUtils.toRpcSig(27, r, s), '0x99e71a99cb2270b8cac5254f9e99b6210c6c10224a1579cf389ef88b20a1abe9129ff05af364204442bdb53ab6f18a99ab48acc9326fa689f228040429e3ca6600') + assert.equal(ethUtils.toRpcSig(27, r, s), '0x99e71a99cb2270b8cac5254f9e99b6210c6c10224a1579cf389ef88b20a1abe9129ff05af364204442bdb53ab6f18a99ab48acc9326fa689f228040429e3ca661b') + assert.deepEqual(ethUtils.fromRpcSig('0x99e71a99cb2270b8cac5254f9e99b6210c6c10224a1579cf389ef88b20a1abe9129ff05af364204442bdb53ab6f18a99ab48acc9326fa689f228040429e3ca661b'), { + v: 27, + r: r, + s: s + }) assert.deepEqual(ethUtils.fromRpcSig('0x99e71a99cb2270b8cac5254f9e99b6210c6c10224a1579cf389ef88b20a1abe9129ff05af364204442bdb53ab6f18a99ab48acc9326fa689f228040429e3ca6600'), { v: 27, r: r, @@ -622,7 +627,7 @@ describe('message sig', function () { }) it('pad short r and s values', function () { - assert.equal(ethUtils.toRpcSig(27, r.slice(20), s.slice(20)), '0x00000000000000000000000000000000000000004a1579cf389ef88b20a1abe90000000000000000000000000000000000000000326fa689f228040429e3ca6600') + assert.equal(ethUtils.toRpcSig(27, r.slice(20), s.slice(20)), '0x00000000000000000000000000000000000000004a1579cf389ef88b20a1abe90000000000000000000000000000000000000000326fa689f228040429e3ca661b') }) it('should throw on invalid v value', function () {