Skip to content

Commit

Permalink
added validator setup
Browse files Browse the repository at this point in the history
  • Loading branch information
leekt committed Feb 22, 2024
1 parent e7472a8 commit c6630f9
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 25 deletions.
7 changes: 5 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
url = https://github.com/leekt/I4337
[submodule "lib/FreshCryptoLib"]
path = lib/FreshCryptoLib
url = https://github.com/rdubois-crypto/FreshCryptoLib
url = https://github.com/rdubois-crypto/FreshCryptoLib
[submodule "lib/p256-verifier"]
path = lib/p256-verifier
url = https://github.com/daimo-eth/p256-verifier
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/vectorized/solady
url = https://github.com/vectorized/solady
3 changes: 2 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
solady/=lib/solady/src/
I4337/=lib/I4337/src/
FreshCryptoLib/=lib/FreshCryptoLib/solidity/src/
FreshCryptoLib/=lib/FreshCryptoLib/solidity/src/
p256-verifier/=lib/p256-verifier/src/
11 changes: 0 additions & 11 deletions script/DeployKernelInitial.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@ contract DeployKernelInitial is Script {
} else {
factory = KernelFactory(EXPECTED_KERNEL_FACTORY_ADDRESS);
}
//if(address(ECDSAVALIDATOR).code.length == 0) {
// console.log("ECDSAVALIDATOR NOT DEPLOYED");
//} else {
// KernelLiteECDSA kernellite;
// kernellite = new KernelLiteECDSA{salt:0}(IEntryPoint(ENTRYPOINT_0_6), IKernelValidator(ECDSAVALIDATOR));
// console.log("Kernel Lite address: %s", address(kernellite));
// if(factory.isAllowedImplementation(address(kernellite)) == false) {
// console.log("Registering kernellite implementation");
// factory.setImplementation(address(kernellite), true);
// }
//}
Kernel kernel;
kernel = new Kernel{salt: 0}(IEntryPoint(ENTRYPOINT_0_6));
console.log("Kernel address: %s", address(kernel));
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IKernelValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface IKernelValidator {

function validateSignature(bytes32 hash, bytes calldata signature) external view returns (ValidationData);

function validCaller(address caller, bytes calldata data) external payable returns (bool);
function validCaller(address caller, bytes calldata data) external view returns (bool);
}

// 3 modes
Expand Down
2 changes: 1 addition & 1 deletion src/mock/TestValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ contract TestValidator is IKernelValidator {
emit TestDisable(_data);
}

function validCaller(address _caller, bytes calldata) external payable override returns (bool) {
function validCaller(address _caller, bytes calldata) external view override returns (bool) {
return _caller == caller[msg.sender];
}
}
2 changes: 1 addition & 1 deletion src/validator/ECDSATypedValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ contract ECDSATypedValidator is IKernelValidator, EIP712 {
}

/// @dev Check if the caller is a valid signer for this kernel account
function validCaller(address _caller, bytes calldata) external payable override returns (bool) {
function validCaller(address _caller, bytes calldata) external view override returns (bool) {
return ecdsaValidatorStorage[msg.sender].owner == _caller;
}

Expand Down
2 changes: 1 addition & 1 deletion src/validator/ECDSAValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ contract ECDSAValidator is IKernelValidator {
return ValidationData.wrap(0);
}

function validCaller(address _caller, bytes calldata) external payable override returns (bool) {
function validCaller(address _caller, bytes calldata) external view override returns (bool) {
return ecdsaValidatorStorage[msg.sender].owner == _caller;
}
}
2 changes: 1 addition & 1 deletion src/validator/ERC165SessionKeyValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ contract ERC165SessionKeyValidator is IKernelValidator {
return packValidationData(sessionKey.validAfter, sessionKey.validUntil);
}

function validCaller(address, bytes calldata) external payable override returns (bool) {
function validCaller(address, bytes calldata) external view override returns (bool) {
revert NotImplemented();
}
}
2 changes: 1 addition & 1 deletion src/validator/KillSwitchValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ contract KillSwitchValidator is IKernelValidator {
}
}

function validCaller(address, bytes calldata) external payable override returns (bool) {
function validCaller(address, bytes calldata) external view override returns (bool) {
revert NotImplemented();
}
}
2 changes: 1 addition & 1 deletion src/validator/SessionKeyValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ contract SessionKeyValidator is IKernelValidator {
return true;
}

function validCaller(address, bytes calldata) external payable returns (bool) {
function validCaller(address, bytes calldata) external view returns (bool) {
revert NotImplemented();
}

Expand Down
2 changes: 1 addition & 1 deletion src/validator/WeightedECDSAValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ contract WeightedECDSAValidator is EIP712, IKernelValidator {
passed = approvals >= strg.threshold;
}

function validCaller(address, bytes calldata) external payable override returns (bool) {
function validCaller(address, bytes calldata) external view override returns (bool) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ contract ModularPermissionValidator is IKernelValidator {
validationData = _intersectValidationData(validationData, signatureValidation);
}

function validCaller(address caller, bytes calldata data) external payable override returns (bool) {
function validCaller(address caller, bytes calldata data) external view override returns (bool) {
revert("not implemented");
}

Expand Down
2 changes: 1 addition & 1 deletion src/validator/modularPermission/PolicyConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function toFlag(uint256 x) pure returns (bytes12) {
return bytes12(bytes32(x << 160));
}

function toPermissionFlag(uint256 x) pure returns(bytes12) {
function toPermissionFlag(uint256 x) pure returns (bytes12) {
bytes12 ret = bytes12(bytes32(x << 160));
assembly {
ret := not(ret)
Expand Down
2 changes: 1 addition & 1 deletion test/foundry/validator/WebAuthnFclValidator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ contract WebAuthnFclValidatorTest is KernelTestBase {
bytes memory sig = signHash(digest);

// Ensure it's reverting
vm.expectRevert(WebAuthnFclVerifier.InvalidWebAuthNData.selector);
vm.expectRevert("Kernel::_validateSignature: failed to validate signature");
kernel.isValidSignature(_wrongHash, sig);
}

Expand Down

0 comments on commit c6630f9

Please sign in to comment.