-
Notifications
You must be signed in to change notification settings - Fork 10
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
Remediations re 7739 update #216
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
using ModeLib for ExecutionMode; | ||
using ExecLib for bytes; | ||
using NonceLib for uint256; | ||
using SentinelListLib for SentinelListLib.SentinelList; | ||
|
||
/// @dev The timelock period for emergency hook uninstallation. | ||
uint256 internal constant _EMERGENCY_TIMELOCK = 1 days; | ||
|
@@ -226,7 +227,9 @@ | |
/// @dev Delegates the validation to a validator module specified within the signature data. | ||
function isValidSignature(bytes32 hash, bytes calldata signature) external view virtual override returns (bytes4) { | ||
// Handle potential ERC7739 support detection request | ||
if (checkERC7739Support(hash, signature)) return SUPPORTS_ERC7739; | ||
if (signature.length == 0) { | ||
if (checkERC7739Support(hash, signature)) return SUPPORTS_ERC7739; | ||
} | ||
// else proceed with normal signature verification | ||
|
||
// First 20 bytes of data will be validator address and rest of the bytes is complete signature. | ||
|
@@ -335,14 +338,13 @@ | |
/// and return 0xffffffff as a result. | ||
function checkERC7739Support(bytes32 hash, bytes calldata signature) public view virtual returns (bool) { | ||
unchecked { | ||
if (signature.length == uint256(0)) { | ||
// Forces the compiler to optimize for smaller bytecode size. | ||
if (uint256(hash) == (~signature.length / 0xffff) * 0x7739) { | ||
SentinelListLib.SentinelList storage validators = _getAccountStorage().validators; | ||
address next = validators.entries[SENTINEL]; | ||
while (next != ZERO_ADDRESS && next != SENTINEL) { | ||
if (IValidator(next).isValidSignatureWithSender(msg.sender, hash, signature) == SUPPORTS_ERC7739) return true; | ||
} | ||
// Forces the compiler to optimize for smaller bytecode size. | ||
if (uint256(hash) == (~signature.length / 0xffff) * 0x7739) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curious what does ~ do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is bitwise negation. so it makes 0xfff..fff out of 0. |
||
SentinelListLib.SentinelList storage validators = _getAccountStorage().validators; | ||
address next = validators.entries[SENTINEL]; | ||
while (next != ZERO_ADDRESS && next != SENTINEL) { | ||
if (IValidator(next).isValidSignatureWithSender(msg.sender, hash, signature) == SUPPORTS_ERC7739) return true; | ||
next = validators.getNext(next); | ||
} | ||
} | ||
} | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
if signature length is 0 then check? is this correct?
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.
yes, it's in 7739 spec