Skip to content
This repository was archived by the owner on Jun 17, 2021. It is now read-only.

Commit 19d2b1f

Browse files
authored
Merge pull request #139 from Neurone/master
Fixed signature to comply to Geth and Parity (see #131)
2 parents 76c0809 + 64b662e commit 19d2b1f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,10 @@ exports.toRpcSig = function (v, r, s) {
416416
}
417417

418418
// geth (and the RPC eth_sign method) uses the 65 byte format used by Bitcoin
419-
// FIXME: this might change in the future - https://github.com/ethereum/go-ethereum/issues/2053
420419
return exports.bufferToHex(Buffer.concat([
421420
exports.setLengthLeft(r, 32),
422421
exports.setLengthLeft(s, 32),
423-
exports.toBuffer(v - 27)
422+
exports.toBuffer(v)
424423
]))
425424
}
426425

test/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,12 @@ describe('message sig', function () {
604604
const s = Buffer.from('129ff05af364204442bdb53ab6f18a99ab48acc9326fa689f228040429e3ca66', 'hex')
605605

606606
it('should return hex strings that the RPC can use', function () {
607-
assert.equal(ethUtils.toRpcSig(27, r, s), '0x99e71a99cb2270b8cac5254f9e99b6210c6c10224a1579cf389ef88b20a1abe9129ff05af364204442bdb53ab6f18a99ab48acc9326fa689f228040429e3ca6600')
607+
assert.equal(ethUtils.toRpcSig(27, r, s), '0x99e71a99cb2270b8cac5254f9e99b6210c6c10224a1579cf389ef88b20a1abe9129ff05af364204442bdb53ab6f18a99ab48acc9326fa689f228040429e3ca661b')
608+
assert.deepEqual(ethUtils.fromRpcSig('0x99e71a99cb2270b8cac5254f9e99b6210c6c10224a1579cf389ef88b20a1abe9129ff05af364204442bdb53ab6f18a99ab48acc9326fa689f228040429e3ca661b'), {
609+
v: 27,
610+
r: r,
611+
s: s
612+
})
608613
assert.deepEqual(ethUtils.fromRpcSig('0x99e71a99cb2270b8cac5254f9e99b6210c6c10224a1579cf389ef88b20a1abe9129ff05af364204442bdb53ab6f18a99ab48acc9326fa689f228040429e3ca6600'), {
609614
v: 27,
610615
r: r,
@@ -622,7 +627,7 @@ describe('message sig', function () {
622627
})
623628

624629
it('pad short r and s values', function () {
625-
assert.equal(ethUtils.toRpcSig(27, r.slice(20), s.slice(20)), '0x00000000000000000000000000000000000000004a1579cf389ef88b20a1abe90000000000000000000000000000000000000000326fa689f228040429e3ca6600')
630+
assert.equal(ethUtils.toRpcSig(27, r.slice(20), s.slice(20)), '0x00000000000000000000000000000000000000004a1579cf389ef88b20a1abe90000000000000000000000000000000000000000326fa689f228040429e3ca661b')
626631
})
627632

628633
it('should throw on invalid v value', function () {

0 commit comments

Comments
 (0)