Repository navigation
fix(signatureToCompactSignature): pad s and derive yParity from legacy v - #5235
Closed
pucedoteth wants to merge 1 commit into
Closed
pucedoteth wants to merge 1 commit into
pucedoteth wants to merge 1 commit into
Conversation
…acy `v` Set the yParity bit on `s` padded to 32 bytes, so an `s` with a leading zero byte keeps its value, and derive yParity from an EIP-155 `v` the same way `serializeSignature` does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@pucedoteth is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 2ade2ef The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
signatureToCompactSignaturereturns a wrong EIP-2098 signature in two cases. Both come up with transactions read over RPC.sshorter than 32 bytes. The yParity bit was set onhexToBytes(s)[0], which is only the top byte whensis exactly 32 bytes. Nodes returnr/sas quantities with leading zeros stripped, so about 1 in 256 signatures has a shorters, and the bit lands inside the value. In the new test,s = 0xc3d1…(31 bytes) already has its top bit set, so the output is unchanged and the parity is lost.compactSignatureToSignaturethen reads the result as a differents, andrecoverAddressreturns the wrong address.sis now left-padded to 32 bytes first. Thesizeoption ofhexToBytespads on the right, so this usespad.Legacy
vwith a chain id. yParity was computed asv - 27n, sov = 38n(chain 1, recovery 1) became11and the bit was never set.formatTransactiondropsyParityfor legacy transactions, sovis all a caller has there. The yParity logic now matchesserializeSignature:27/28/>= 35by parity, otherwise the sameInvalid \v` or `yParity` valueerror. Before, an unsupportedv` silently produced no bit.The two new tests fail without the change. The short-
stest uses a real signature fromaccounts[0]and checks thatrecoverAddressreturns that account after a round trip through the compact form. Allsrc/utils/signaturetests pass (50), and biome andtscare clean.Written with AI assistance (Claude Code).
🤖 Generated with Claude Code