Skip to content

fix: accept an EIP-7702 authorization yParity above 1 in parseTransaction - #5367

Closed
erkancamli wants to merge 1 commit into
wevm:mainfrom
erkancamli:fix/parse-authorization-yparity
Closed

erkancamli wants to merge 1 commit into
wevm:mainfrom
erkancamli:fix/parse-authorization-yparity

Conversation

@erkancamli

Copy link
Copy Markdown
Contributor

Follow-up to #5304. That PR made serializeTransaction keep an EIP-7702 authorization yParity above 1, but parseTransaction still parses each authorization signature with parseEIP155Signature, which throws for anything other than 0 or 1:

if (yParity !== 0n && yParity !== 1n)
  throw new InvalidYParityError({ yParity })

So the mainnet transaction from #5297 (0xaec84209...cb09, authorization y_parity = 28) can be serialized but not parsed back:

const serialized = '0x04f8c90102843b9aca00...' // bytes from the #5304 test
parseTransaction(serialized)
// InvalidYParityError: Invalid `yParity` value "28". Expected 0 or 1.

recoverTransactionAddress({ serializedTransaction }) throws the same way, and so do the OP Stack and Celo parsers, which hand type 0x04 to the same function. As #5297 notes, EIP-7702 allows any y_parity below 2**8 in an authorization tuple, and a tuple that fails recovery is skipped without invalidating the transaction. ox's Authorization.fromTuple already accepts 0 to 255.

With this change, an authorization yParity from 2 to 255 is kept as is, with r and s padded to 32 bytes as before. 0 and 1 parse exactly as before, the outer transaction signature check is unchanged, and a value of 256 or more still throws InvalidYParityError.

Tests: in parseTransaction.test.ts, "behavior: authorization yParity above 1" parses the #5297 transaction and checks that it serializes back to the same bytes. It fails on main with the error above and passes with this change. The existing "invalid authorization list yParity" case now uses 256, since 2 is a valid value. The file passes 70/70. A changeset is included.

…saction`

`parseAuthorizationList` parsed each authorization signature with
`parseEIP155Signature`, which throws `InvalidYParityError` for any
`yParity` other than 0 or 1. EIP-7702 permits any `y_parity` below 2**8
in an authorization tuple, and wevm#5304 made `serializeTransaction` keep
such a value, so a transaction viem serializes, for example mainnet
0xaec84209...cb09 whose authorization has a `y_parity` of 28, could not
be parsed back, and `recoverTransactionAddress` threw on it.

An authorization `yParity` from 2 to 255 is now kept as is, with `r`
and `s` padded as before. 0 and 1 parse as before, and 256 or more
still throws.
@vercel

vercel Bot commented Nov 1, 2026

Copy link
Copy Markdown

@erkancamli 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 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5538146

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 commented Nov 1, 2026

Copy link
Copy Markdown
Member

Superseded by #5371, which includes this commit unchanged.

That PR also changes how recovery handles these values. Once a yParity of 27 or 28 parses, recoverPublicKey treats it as a legacy v, so the authorization recovers a signer. EIP-7702 skips such a tuple, so no delegation happens on chain, yet verifyAuthorization returned true for it. #5371 makes recoverAuthorizationAddress throw InvalidYParityError for a yParity other than 0 or 1, and verifyAuthorization return false.

Thanks for the fix!


Generated by Claude Code

@jxom jxom closed this Nov 1, 2026
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