Skip to content

Commit

Permalink
Fixed splitSignature when recoveryParam is encoded directly (#893, #933
Browse files Browse the repository at this point in the history
…).
  • Loading branch information
ricmoo committed Jul 8, 2020
1 parent 7e56f3d commit bf65ddb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/bytes/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,6 @@ export function splitSignature(signature: SignatureLike): Signature {
result.s = hexlify(bytes.slice(32, 64));
result.v = bytes[64];

// Compute recoveryParam from v
result.recoveryParam = 1 - (result.v % 2);

// Allow a recid to be used as the v
if (result.v < 27) {
if (result.v === 0 || result.v === 1) {
Expand All @@ -352,6 +349,9 @@ export function splitSignature(signature: SignatureLike): Signature {
}
}

// Compute recoveryParam from v
result.recoveryParam = 1 - (result.v % 2);

// Compute _vs from recoveryParam and s
if (result.recoveryParam) { bytes[32] |= 0x80; }
result._vs = hexlify(bytes.slice(32, 64))
Expand Down

0 comments on commit bf65ddb

Please sign in to comment.