Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signer/core: fix incorrect EIP-712 recursive encoding of nested bytes arrays #30987

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

crStiv
Copy link

@crStiv crStiv commented Jan 5, 2025

This PR fixes issue #30979 where nested bytes arrays (bytes[]) were incorrectly encoded recursively. The fix adds special handling for bytes arrays in the encodeArrayValue function to treat them as primitive types rather than nested arrays.

Changes:

  • Added special case for bytes arrays in encodeArrayValue
  • Added test case to verify the fix
  • Updated documentation

The issue was causing encoding errors when dealing with nested bytes arrays, as each byte in the array was being treated as a separate array element rather than as part of a single bytes value.

closes #30979

@crStiv crStiv requested a review from holiman as a code owner January 5, 2025 00:49
@holiman holiman changed the title fix: fix incorrect recursive encoding of nested bytes arrays signer/core: fix incorrect EIP-712 recursive encoding of nested bytes arrays Jan 7, 2025
@holiman
Copy link
Contributor

holiman commented Jan 7, 2025

Thanks for looking into this. Howevder, the test you added fails,

=== RUN   TestEncodeNestedBytesArray
    types_test.go:258: Failed to hash struct with nested bytes array: domain is undefined

Also, a lot of other tests fail (https://ci.appveyor.com/project/ethereum/go-ethereum/builds/51265439/job/01cck5hat24897m0#L1126) , and the imports need to be sorted (https://ci.appveyor.com/project/ethereum/go-ethereum/builds/51265439/job/cxswaevl9mqlc8v7#L56)

@fjl fjl assigned jwasinger and unassigned jwasinger Jan 7, 2025
@crStiv
Copy link
Author

crStiv commented Jan 7, 2025

@holiman made a change, did I understand correctly what you wanted to be changed?

@holiman
Copy link
Contributor

holiman commented Jan 7, 2025

did I understand correctly what you wanted to be changed?

I am not sure. I really just (so far) commented on failing tests. We never ever check in a failing test

@holiman
Copy link
Contributor

holiman commented Jan 8, 2025

The test that you added, and several others, are still failing: https://ci.appveyor.com/project/ethereum/go-ethereum/builds/51280768/job/sa6l473v1d5lp1vl#L1125 .

I don't understand. Do you run the test locally? Because I don't see how it could possibly succeed?

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.

Incorrect recursive encoding of nested bytes arrays (bytes[]) in apitypes
3 participants