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
4 changes: 3 additions & 1 deletion src/account/KeystoreAccountFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {IKeystore} from "../interface/IKeystore.sol";
import {KeystoreAccount} from "./KeystoreAccount.sol";

contract KeystoreAccountFactory {
error NotFromSenderCreator();

KeystoreAccount public immutable accountImplementation;
IEntryPoint public immutable entryPoint;
ISenderCreator public immutable senderCreator;
Expand All @@ -21,7 +23,7 @@ contract KeystoreAccountFactory {
}

function createAccount(bytes32 refHash, uint256 salt) public returns (KeystoreAccount ret) {
require(msg.sender == address(senderCreator), "only callable from SenderCreator");
require(msg.sender == address(senderCreator), NotFromSenderCreator());
address addr = getAddress(refHash, salt);
uint256 codeSize = addr.code.length;
if (codeSize > 0) {
Expand Down
17 changes: 17 additions & 0 deletions src/lib/OnlyKeystore.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

abstract contract OnlyKeystore {
error NotFromKeystore();

address public immutable keystore;

constructor(address aKeystore) {
keystore = aKeystore;
}

modifier onlyKeystore() {
require(msg.sender == keystore, NotFromKeystore());
_;
}
}
14 changes: 3 additions & 11 deletions src/verifier/UserOpECDSAVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@ import {PackedUserOperation} from "account-abstraction/interfaces/PackedUserOper
import {ECDSA} from "solady/utils/ECDSA.sol";

import {IVerifier} from "../interface/IVerifier.sol";
import {OnlyKeystore} from "../lib/OnlyKeystore.sol";

contract UserOpECDSAVerifier is IVerifier {
address public immutable keystore;

modifier onlyKeystore() {
require(msg.sender == keystore, "verifier: not from Keystore");
_;
}

constructor(address aKeystore) {
keystore = aKeystore;
}
contract UserOpECDSAVerifier is IVerifier, OnlyKeystore {
constructor(address aKeystore) OnlyKeystore(aKeystore) {}

function validateData(bytes32 message, bytes calldata data, bytes calldata config)
external
Expand Down
13 changes: 3 additions & 10 deletions src/verifier/UserOpMultiSigVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,17 @@ import {PackedUserOperation} from "account-abstraction/interfaces/PackedUserOper
import {ECDSA} from "solady/utils/ECDSA.sol";

import {IVerifier} from "../interface/IVerifier.sol";
import {OnlyKeystore} from "../lib/OnlyKeystore.sol";

contract UserOpMultiSigVerifier is IVerifier {
contract UserOpMultiSigVerifier is IVerifier, OnlyKeystore {
bytes1 public constant SIGNATURES_ONLY_TAG = 0xff;
address public immutable keystore;

struct SignerData {
uint8 index;
bytes signature;
}

modifier onlyKeystore() {
require(msg.sender == keystore, "verifier: not from Keystore");
_;
}

constructor(address aKeystore) {
keystore = aKeystore;
}
constructor(address aKeystore) OnlyKeystore(aKeystore) {}

function validateData(bytes32 message, bytes calldata data, bytes calldata config)
external
Expand Down
13 changes: 3 additions & 10 deletions src/verifier/UserOpWebAuthnCosignVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@ import {LibBytes} from "solady/utils/LibBytes.sol";
import {WebAuthn} from "solady/utils/WebAuthn.sol";

import {IVerifier} from "../interface/IVerifier.sol";
import {OnlyKeystore} from "../lib/OnlyKeystore.sol";

contract UserOpWebAuthnCosignVerifier is IVerifier {
contract UserOpWebAuthnCosignVerifier is IVerifier, OnlyKeystore {
bytes1 public constant SIGNATURES_ONLY_TAG = 0xff;
address public immutable keystore;

modifier onlyKeystore() {
require(msg.sender == keystore, "verifier: not from Keystore");
_;
}

constructor(address aKeystore) {
keystore = aKeystore;
}
constructor(address aKeystore) OnlyKeystore(aKeystore) {}

function validateData(bytes32 message, bytes calldata data, bytes calldata config)
external
Expand Down
14 changes: 3 additions & 11 deletions src/verifier/UserOpWebAuthnVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@ import {PackedUserOperation} from "account-abstraction/interfaces/PackedUserOper
import {WebAuthn} from "solady/utils/WebAuthn.sol";

import {IVerifier} from "../interface/IVerifier.sol";
import {OnlyKeystore} from "../lib/OnlyKeystore.sol";

contract UserOpWebAuthnVerifier is IVerifier {
address public immutable keystore;

modifier onlyKeystore() {
require(msg.sender == keystore, "verifier: not from Keystore");
_;
}

constructor(address aKeystore) {
keystore = aKeystore;
}
contract UserOpWebAuthnVerifier is IVerifier, OnlyKeystore {
constructor(address aKeystore) OnlyKeystore(aKeystore) {}

function validateData(bytes32 message, bytes calldata data, bytes calldata config)
external
Expand Down
2 changes: 1 addition & 1 deletion test/account/KeystoreAccountFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ contract KeystoreAccountFactoryTest is Test {
vm.assume(caller != address(entryPoint.senderCreator()));

vm.prank(caller);
vm.expectRevert("only callable from SenderCreator");
vm.expectRevert(KeystoreAccountFactory.NotFromSenderCreator.selector);
factory.createAccount(refHash, salt);
}
}
3 changes: 2 additions & 1 deletion test/verifier/UserOpECDSAVerifier.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {PackedUserOperation} from "account-abstraction/interfaces/PackedUserOper
import {Test} from "forge-std/Test.sol";
import {ECDSA} from "solady/utils/ECDSA.sol";

import {OnlyKeystore} from "../../src/lib/OnlyKeystore.sol";
import {UserOpECDSAVerifier} from "../../src/verifier/UserOpECDSAVerifier.sol";

contract UserOpECDSAVerifierTest is Test {
Expand Down Expand Up @@ -50,7 +51,7 @@ contract UserOpECDSAVerifierTest is Test {
function testFuzz_validateDataInvalidCaller(address keystore) public {
vm.assume(keystore != address(this));
vm.prank(keystore);
vm.expectRevert("verifier: not from Keystore");
vm.expectRevert(OnlyKeystore.NotFromKeystore.selector);
verifier.validateData(0, "", "");
}

Expand Down
3 changes: 2 additions & 1 deletion test/verifier/UserOpMultiSigVerifier.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {Test} from "forge-std/Test.sol";
import {ECDSA} from "solady/utils/ECDSA.sol";
import {LibString} from "solady/utils/LibString.sol";

import {OnlyKeystore} from "../../src/lib/OnlyKeystore.sol";
import {UserOpMultiSigVerifier} from "../../src/verifier/UserOpMultiSigVerifier.sol";

contract UserOpMultiSigVerifierTest is Test {
Expand Down Expand Up @@ -64,7 +65,7 @@ contract UserOpMultiSigVerifierTest is Test {
function testFuzz_validateDataInvalidCaller(address keystore) public {
vm.assume(keystore != address(this));
vm.prank(keystore);
vm.expectRevert("verifier: not from Keystore");
vm.expectRevert(OnlyKeystore.NotFromKeystore.selector);
verifier.validateData(0, "", "");
}

Expand Down
3 changes: 2 additions & 1 deletion test/verifier/UserOpWebAuthnCosignVerifier.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {LibString} from "solady/utils/LibString.sol";
import {P256} from "solady/utils/P256.sol";
import {WebAuthn} from "solady/utils/WebAuthn.sol";

import {OnlyKeystore} from "../../src/lib/OnlyKeystore.sol";
import {UserOpWebAuthnCosignVerifier} from "../../src/verifier/UserOpWebAuthnCosignVerifier.sol";

contract UserOpWebAuthnCosignVerifierTest is Test {
Expand Down Expand Up @@ -97,7 +98,7 @@ contract UserOpWebAuthnCosignVerifierTest is Test {
function testFuzz_validateDataInvalidCaller(address keystore) public {
vm.assume(keystore != address(this));
vm.prank(keystore);
vm.expectRevert("verifier: not from Keystore");
vm.expectRevert(OnlyKeystore.NotFromKeystore.selector);
verifier.validateData(0, "", "");
}

Expand Down
3 changes: 2 additions & 1 deletion test/verifier/UserOpWebAuthnVerifier.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {LibString} from "solady/utils/LibString.sol";
import {P256} from "solady/utils/P256.sol";
import {WebAuthn} from "solady/utils/WebAuthn.sol";

import {OnlyKeystore} from "../../src/lib/OnlyKeystore.sol";
import {UserOpWebAuthnVerifier} from "../../src/verifier/UserOpWebAuthnVerifier.sol";

contract UserOpWebAuthnVerifierTest is Test {
Expand Down Expand Up @@ -70,7 +71,7 @@ contract UserOpWebAuthnVerifierTest is Test {
function testFuzz_validateDataInvalidCaller(address keystore) public {
vm.assume(keystore != address(this));
vm.prank(keystore);
vm.expectRevert("verifier: not from Keystore");
vm.expectRevert(OnlyKeystore.NotFromKeystore.selector);
verifier.validateData(0, "", "");
}

Expand Down