diff --git a/src/validator/ECDSAValidator.sol b/src/validator/ECDSAValidator.sol index d4d9110c..1d465650 100644 --- a/src/validator/ECDSAValidator.sol +++ b/src/validator/ECDSAValidator.sol @@ -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; } } diff --git a/test/foundry/Kernel.test.sol b/test/foundry/Kernel.test.sol index 4ab6b887..4e66d03f 100644 --- a/test/foundry/Kernel.test.sol +++ b/test/foundry/Kernel.test.sol @@ -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 {