Fixed splitSignature when recoveryParam is encoded directly (#893, #933).

This commit is contained in:
Richard Moore 2020-07-07 22:54:35 -04:00
parent 7e56f3d392
commit bf65ddbff0
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
1 changed files with 3 additions and 3 deletions

View File

@ -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) {
@ -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))