Repository navigation
fix: left-pad odd-length raw hex in toPrefixedMessage - #5631
Merged
Merged
Conversation
|
@mortezashojaei 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: 264375b 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 |
mortezashojaei
force-pushed
the
fix/odd-length-raw-message-prefix
branch
from
November 21, 2026 18:09
974f4fa to
264375b
Compare
Merged
This was referenced Nov 22, 2026
fix: port recent viem fixes to
AbiParameters, Block, Bytes, Fee, Hex and PersonalMessage
wevm/ox#729
Merged
jxom
added a commit
to wevm/ox
that referenced
this pull request
Nov 28, 2026
…e`, `Hex` and `PersonalMessage` (#729) - Kept a leading U+FEFF when decoding UTF-8 strings (wevm/viem#5590). - Rejected a missing static head after a dynamic parameter in AbiParameters.decode (wevm/viem#5572). - Rejected odd-length hex in PersonalMessage.encode (wevm/viem#5631). - Added blockAccessListHash and slotNumber to Block (wevm/viem#5674). - Added baseFeePerBlobGas and blobGasUsedRatio to Fee.FeeHistory (wevm/viem#5635). Amp-Thread-ID: https://ampcode.com/threads/T-01a21f59-905f-745c-8634-6581aa9f965e Co-authored-by: Amp <[email protected]>
jxom
added a commit
to wevm/ox
that referenced
this pull request
Nov 28, 2026
…e`, `Hex` and `PersonalMessage` (#730) - Kept a leading U+FEFF when decoding UTF-8 strings (wevm/viem#5590). - Rejected a missing static head after a dynamic parameter in AbiParameters.decode (wevm/viem#5572). - Rejected odd-length hex in PersonalMessage.encode (wevm/viem#5631). - Added blockAccessListHash and slotNumber to Block (wevm/viem#5674). - Added baseFeePerBlobGas and blobGasUsedRatio to Fee.FeeHistory (wevm/viem#5635). Backport of #729. Amp-Thread-ID: https://ampcode.com/threads/T-01a21f59-905f-745c-8634-6581aa9f965e Co-authored-by: Amp <[email protected]>
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.
toPrefixedMessagenow left-pads an odd-length hexrawmessage to whole bytes before prefixing it, matchinghexToBytesand #5466. For example,{ raw: '0x123' }now hashes as the EIP-191 message of bytes0x0123.Problem
The raw hex was appended to the prefix unpadded. When
keccak256converted the odd-length result to bytes, it left-padded the whole string, which shifted every nibble of the prefix:So
signMessage({ message: { raw: '0x123' } })on a local account signed a hash that is not an EIP-191 message hash, andverifyMessageandrecoverMessageAddressdisagreed with other implementations for the same input. The ERC-7739hashMessageandsignMessagealso usetoPrefixedMessage.Change
toPrefixedMessage: left-pad odd-lengthrawhex strings (0x123→0x0123). Even-length strings,Uint8Array, and string messages are unchanged.toPrefixedMessagedefaultandhashMessageto hexcases gain an odd-lengthrawassertion. ThehashMessagesnapshot is the standard EIP-191 hash of0x0123(0x849ae777…5751).Validation
pnpm test --project core --run src/utils/signature/ src/accounts/: 191 passed.tscpasses on the touched modules.