-
Notifications
You must be signed in to change notification settings - Fork 25
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
feat: Add SMA Replay-Safe Hash #155
Conversation
3400f3d
to
bccc3b2
Compare
bccc3b2
to
6faa4b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 1 small style nit.
Side note: it would be possible to implement EIP-5267 for SMA, because we do know all of the fields in the EIP712Domain
struct. However, I don't think we need to, because there's already account impl-specific behavior we will need to do for signing, and it will increase codesize.
uint8 v; | ||
bytes32 r; | ||
bytes32 s; | ||
|
||
if (vm.envOr("SMA_TEST", false)) { | ||
// todo: implement replay-safe hashing for SMA | ||
(v, r, s) = vm.sign(owner1Key, message); | ||
} else { | ||
bytes32 replaySafeHash = singleSignerValidationModule.replaySafeHash(address(account1), message); | ||
(v, r, s) = vm.sign(owner1Key, replaySafeHash); | ||
} | ||
(v, r, s) = vm.sign(owner1Key, replaySafeHash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit: can inline declare vars now as:
(uint8 v, bytes32 r, bytes32 s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in df43ba7!
Interesting point, hadn't thought of it. I agree we're better off as it is for now, it's probably not beneficial to expose this on SMA when it can't be done on a standard MA. |
Motivation
Currently, two SMAs with the same fallback signer could be used to verify messages. This is problematic as signatures must be unique on a per-account basis.
This has been addressed for modules already, and this PR addresses this for SMAs.
Solution
Add a
replaySafeHash()
function and related EIP712 functionality to theSemiModularAccount
, which is computed upon ERC1271 signature validation. This means the fallback signer must sign the replay-safe hash, but the inner hash must be submitted in the transaction.