-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathReference.sol
38 lines (31 loc) · 1.33 KB
/
Reference.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
pragma solidity ^0.5.0;
/**
* @title MultiSignatureWallet
* @author Nick Dodson <[email protected]>
* @notice A solidity implimentation for the EIP712 MultiSignature Wallet developed in Yul.
*/
contract EIP712MultiSig {
uint256 public nonce;
uint256 public threshold;
mapping(address => bool) public isOwner;
function () external payable {}
constructor(address[] memory owners, uint256 requiredSignatures) public {
threshold = requiredSignatures;
for (uint256 i = 0; i < owners.length; i++)
isOwner[owners[i]] = true;
}
function execute(address dest, bytes calldata data, bytes32[] calldata signatures) external {
bytes32 hash = keccak256(abi.encodePacked(
"\x19\x01",
bytes32(0xb0609d81c5f719d8a516ae2f25079b20fb63da3e07590e23fbf0028e6745e5f2),
keccak256(abi.encode(0x4a0a6d86122c7bd7083e83912c312adabf207e986f1ac10a35dfeb610d28d0b6, dest, nonce++, data))));
address prev;
for (uint256 i = 0; i < threshold; i++) {
address addr = ecrecover(hash, uint8(signatures[i][31]), signatures[i + 1], signatures[1 + 2]);
assert(isOwner[addr] == true);
assert(addr > prev); // check for duplicates or zero value
prev = addr;
}
if(!dest.delegatecall(data)) revert();
}
}