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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ struct ECDSAValidatorStorage {
address owner;
}

contract MultiSignatureECDSASigner is SignerBase {
bytes constant DUMMY_ECDSA_SIG =
hex"fffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";

contract MultiChainSigner is SignerBase {
mapping(address => uint256) public usedIds;
mapping(bytes32 id => mapping(address wallet => address)) public signer;

Expand Down Expand Up @@ -70,8 +73,15 @@ contract MultiSignatureECDSASigner is SignerBase {
}
bytes memory ecdsaSig = sig[0:65];
bytes32 merkleRoot = bytes32(sig[65:97]);
bytes32[] memory proof = abi.decode(sig[97:], (bytes32[]));
require(MerkleProofLib.verify(proof, merkleRoot, userOpHash), "hash is not in proof");
// if the signature is a dummy signature, then use dummyUserOpHash instead of real userOpHash
if (keccak256(ecdsaSig) == keccak256(DUMMY_ECDSA_SIG)) {
(bytes32 dummyUserOpHash, bytes32[] memory proof) = abi.decode(sig[97:], (bytes32, bytes32[]));
require(MerkleProofLib.verify(proof, merkleRoot, dummyUserOpHash), "hash is not in proof");
// otherwise, use real userOpHash
} else {
bytes32[] memory proof = abi.decode(sig[97:], (bytes32[]));
require(MerkleProofLib.verify(proof, merkleRoot, userOpHash), "hash is not in proof");
}
// simple ecdsa verification
if (owner == ECDSA.recover(merkleRoot, ecdsaSig)) {
return SIG_VALIDATION_SUCCESS_UINT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ struct ECDSAValidatorStorage {
address owner;
}

contract MultiSignatureECDSAValidator is IValidator, IHook {
bytes constant DUMMY_ECDSA_SIG =
hex"fffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";

contract MultiChainValidator is IValidator, IHook {
event OwnerRegistered(address indexed kernel, address indexed owner);

mapping(address => ECDSAValidatorStorage) public ecdsaValidatorStorage;
Expand Down Expand Up @@ -69,8 +72,15 @@ contract MultiSignatureECDSAValidator is IValidator, IHook {
}
bytes memory ecdsaSig = sig[0:65];
bytes32 merkleRoot = bytes32(sig[65:97]);
bytes32[] memory proof = abi.decode(sig[97:], (bytes32[]));
require(MerkleProofLib.verify(proof, merkleRoot, userOpHash), "hash is not in proof");
// if the signature is a dummy signature, then use dummyUserOpHash instead of real userOpHash
if (keccak256(ecdsaSig) == keccak256(DUMMY_ECDSA_SIG)) {
(bytes32 dummyUserOpHash, bytes32[] memory proof) = abi.decode(sig[97:], (bytes32, bytes32[]));
require(MerkleProofLib.verify(proof, merkleRoot, dummyUserOpHash), "hash is not in proof");
// otherwise, use real userOpHash
} else {
bytes32[] memory proof = abi.decode(sig[97:], (bytes32[]));
require(MerkleProofLib.verify(proof, merkleRoot, userOpHash), "hash is not in proof");
}
// simple ecdsa verification
if (owner == ECDSA.recover(merkleRoot, ecdsaSig)) {
return SIG_VALIDATION_SUCCESS_UINT;
Expand Down