Skip to content

fix(EIP-1271) - change function parameter type and selector#29

Merged
oleg-ssvlabs merged 4 commits into
mainfrom
fix/eip1271-signature
Apr 9, 2026
Merged

fix(EIP-1271) - change function parameter type and selector#29
oleg-ssvlabs merged 4 commits into
mainfrom
fix/eip1271-signature

Conversation

@oleg-ssvlabs
Copy link
Copy Markdown
Contributor

@oleg-ssvlabs oleg-ssvlabs commented Mar 19, 2026

Summary

  • Fixed EIP-1271 ABI to use standard isValidSignature(bytes32,bytes) interface instead of legacy isValidSignature(bytes,bytes)
  • Regenerated contract bindings (selector changed from 0x20c13b0b to 0x1626ba7e)
  • Updated signature verification to pass [32]byte directly and check only the standard magic value
  • Added selector assertion in test stubs to catch ABI regressions locally

Context

Smart contract wallets (Gnosis Safe, etc.) implementing standard EIP-1271 did not match the legacy selector, causing reshare and resign operations with multisig owners to fail.

Why there were two magic values

In EIP-1271, when a contract's isValidSignature confirms a valid signature, it returns its own 4-byte function selector as the success indicator. Since a Solidity function selector is keccak256("functionName(argTypes)")[:4], two different interface versions produce two different magic values:

  • keccak256("isValidSignature(bytes32,bytes)")[:4] = 0x1626ba7e (finalized EIP-1271)
  • keccak256("isValidSignature(bytes,bytes)")[:4] = 0x20c13b0b (legacy draft)

The old code stored both selectors as magic values (mislabeled — the finalized 0x1626ba7e was called MAGIC_VALUE_ETH_SIGN and the legacy draft 0x20c13b0b was called MAGIC_VALUE_PERSONAL_SIGN) to handle contracts implementing either version. But since the ABI was actually using the legacy (bytes,bytes) interface, only 0x20c13b0b could ever be returned — making the other magic value dead code. Now that the ABI is fixed to the standard (bytes32,bytes), only 0x1626ba7e can be returned, so we only need one.

Closes #25
Closes #26

…y (bytes,bytes)

The ABI
  defined isValidSignature(bytes,bytes) with selector 0x20c13b0b instead of
  the standard isValidSignature(bytes32,bytes) with selector 0x1626ba7e. This meant
  smart contract wallets implementing standard EIP-1271 could not authorize reshare
  or resign operations.
iurii-ssv
iurii-ssv previously approved these changes Mar 20, 2026
Copy link
Copy Markdown

@iurii-ssv iurii-ssv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable, but we need a review from repo maintainer(s) to merge

Comment thread eip1271/common.go
@GalRogozinski
Copy link
Copy Markdown

is it related to #26 @oleg-ssvlabs?

@oleg-ssvlabs
Copy link
Copy Markdown
Contributor Author

is it related to #26 @oleg-ssvlabs?

seems to be related. I did not see that PR.
Looking into it, I did not update the encoder. Updated here - 2a177ae

iurii-ssv
iurii-ssv previously approved these changes Mar 23, 2026
Comment thread crypto/signature_test.go
@momosh-ssv momosh-ssv self-requested a review March 27, 2026 15:41
Copy link
Copy Markdown

@momosh-ssv momosh-ssv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing: the Alchemy API key in crypto/signature_test.go:18 is hardcoded. The multisig tests make live Sepolia calls and will fail if the key is rotated or rate-limited. Might be worth moving to an env var.

Comment thread eip1271/common.go
Comment thread types_encoding.go Outdated
nkryuchkov
nkryuchkov previously approved these changes Apr 1, 2026
Copy link
Copy Markdown
Contributor

@nkryuchkov nkryuchkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code LGTM, but I don't have domain knowledge on removing MAGIC_VALUE_ETH_SIGN. Can we add to the PR description why we are removing it?

@momosh-ssv
Copy link
Copy Markdown

...I don't have domain knowledge on removing MAGIC_VALUE_ETH_SIGN. Can we add to the PR description why we are removing it?

I can relate to this, and totally agree here...

iurii-ssv
iurii-ssv previously approved these changes Apr 1, 2026
ljuba-ssv
ljuba-ssv previously approved these changes Apr 2, 2026
Comment thread types_encoding.go
This reverts commit 2a177ae.
Copy link
Copy Markdown
Contributor

@nkryuchkov nkryuchkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please write a few words in the PR description about why we used to check for MAGIC_VALUE_PERSONAL_SIGN or MAGIC_VALUE_ETH_SIGN, but now it's only MAGIC_VALUE?

@oleg-ssvlabs
Copy link
Copy Markdown
Contributor Author

Can you please write a few words in the PR description about why we used to check for MAGIC_VALUE_PERSONAL_SIGN or MAGIC_VALUE_ETH_SIGN, but now it's only MAGIC_VALUE?

good point. Updated PR description

@oleg-ssvlabs oleg-ssvlabs requested a review from nkryuchkov April 8, 2026 07:05
Copy link
Copy Markdown
Contributor

@nkryuchkov nkryuchkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great explanation, thanks

Copy link
Copy Markdown

@MatheusFranco99 MatheusFranco99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@oleg-ssvlabs oleg-ssvlabs merged commit e8a9972 into main Apr 9, 2026
2 checks passed
@oleg-ssvlabs oleg-ssvlabs deleted the fix/eip1271-signature branch April 9, 2026 07:15
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.

Wrong eip-1271 Abi type caused failed resign or reshare

8 participants