Skip to content

fix: accept EIP-155 v in recoverPublicKey - #5423

Closed
wavebyrd wants to merge 1 commit into
wevm:mainfrom
wavebyrd:fix/recover-eip155-v
Closed

wavebyrd wants to merge 1 commit into
wevm:mainfrom
wavebyrd:fix/recover-eip155-v

Conversation

@wavebyrd

@wavebyrd wavebyrd commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

recoverPublicKey (and so recoverAddress) only accepts a v of 0, 1, 27 or 28, so a signature object with an EIP-155 v throws Invalid yParityOrV value. serializeSignature and signatureToCompactSignature already accept v >= 35. This shows up with legacy transactions from getTransaction, since formatTransaction drops yParity for them:

const tx = await getTransaction(client, { hash }) // legacy, v: 38n, no yParity
await recoverAddress({ hash: signingHash, signature: tx })
// Error: Invalid yParityOrV value

This derives the parity from v >= 35 the same way serializeSignature and ox's Signature.vToYParity do. The new eip-155 v test fails without the change and the rest of recoverPublicKey.test.ts passes.

@vercel

vercel Bot commented Nov 5, 2026

Copy link
Copy Markdown

@wavebyrd is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 16e62e2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jxom jxom closed this Nov 6, 2026
jxom added a commit that referenced this pull request Nov 6, 2026
Derive the recovery bit from a signature object's EIP-155 `v`
(`chainId * 2 + 35 + yParity`) using bigint arithmetic, so parity stays
correct for chain IDs beyond `Number.MAX_SAFE_INTEGER`. Raw hex/bytes
signatures are unchanged and still only accept 0, 1, 27 or 28.

Supersedes #5423.



Claude-Session: https://claude.ai/code/session_01D3nmWhKptpqjwDfCp3LrqB

Co-authored-by: Claude <[email protected]>
Co-authored-by: wavebyrd <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants