Skip to content

Commit

Permalink
Add support for legacy flat signatures with recid instead of normaliz…
Browse files Browse the repository at this point in the history
…ed v.
  • Loading branch information
ricmoo committed Jan 11, 2020
1 parent 72b3bc9 commit 245cd0e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/bytes/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,15 @@ export function splitSignature(signature: SignatureLike): Signature {
// 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) {
result.v += 27;
} else {
logger.throwArgumentError("signature invalid v byte", "signature", signature);
}
}

// 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 245cd0e

Please sign in to comment.