Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/validator/ECDSAValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ contract ECDSAValidator is IKernelValidator {

function validateSignature(bytes32 hash, bytes calldata signature) public view override returns (uint256) {
address owner = ecdsaValidatorStorage[msg.sender].owner;
return owner == ECDSA.recover(hash, signature) ? 0 : 1;
if( owner == ECDSA.recover(hash, signature) ) {
return 0;
}
bytes32 ethHash = ECDSA.toEthSignedMessageHash(hash);
address recovered = ECDSA.recover(ethHash, signature);
if (owner != recovered) {
return SIG_VALIDATION_FAILED;
}
return 0;
}
}
3 changes: 2 additions & 1 deletion test/foundry/Kernel.test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ contract KernelTest is Test {
}

function test_validate_signature() external {
Kernel kernel2 = Kernel(payable(address(ecdsaFactory.createAccount(owner, 1))));
bytes32 hash = keccak256(abi.encodePacked("hello world"));
(uint8 v, bytes32 r, bytes32 s) = vm.sign(ownerKey, hash);
assertEq(kernel.isValidSignature(hash, abi.encodePacked(r, s, v)), Kernel.isValidSignature.selector);
assertEq(kernel2.isValidSignature(hash, abi.encodePacked(r, s, v)), Kernel.isValidSignature.selector);
}

function test_set_default_validator() external {
Expand Down