Skip to content

Conversation

@Zer0dot
Copy link
Contributor

@Zer0dot Zer0dot commented Aug 22, 2024

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 the SemiModularAccount, 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.

@Zer0dot Zer0dot changed the title Zer0dot/sma replay safe hash feat: Add SMA Replay-Safe Hash Aug 22, 2024
@Zer0dot Zer0dot force-pushed the zer0dot/sma-replay-safe-hash branch from 3400f3d to bccc3b2 Compare August 22, 2024 20:33
@Zer0dot Zer0dot force-pushed the zer0dot/sma-replay-safe-hash branch from bccc3b2 to 6faa4b6 Compare August 22, 2024 20:55
Copy link
Contributor

@adamegyed adamegyed left a 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.

Comment on lines 409 to 413
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);
Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in df43ba7!

@Zer0dot
Copy link
Contributor Author

Zer0dot commented Aug 22, 2024

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.

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.

@Zer0dot Zer0dot merged commit a1510cd into develop Aug 22, 2024
@jaypaik jaypaik deleted the zer0dot/sma-replay-safe-hash branch October 9, 2024 00:03
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.

3 participants