Fixed splitSignature logic for verifying EIP-2930 and EIP-1559 v (#2084).

This commit is contained in:
Richard Moore 2021-10-17 22:56:57 -04:00
parent ab319f2f4c
commit 3de1b81501
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651

@ -406,10 +406,13 @@ export function splitSignature(signature: SignatureLike): Signature {
} else {
if (result.v == null) {
result.v = 27 + result.recoveryParam;
} else if (result.recoveryParam !== (1 - (result.v % 2))) {
} else {
const recId = (result.v === 0 || result.v === 1) ? result.v :(1 - (result.v % 2));
if (result.recoveryParam !== recId) {
logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature);
}
}
}
if (result.r == null || !isHexString(result.r)) {
logger.throwArgumentError("signature missing or invalid r", "signature", signature);