From 47e306d8ab95140eb7e2589c05351d1663a507ae Mon Sep 17 00:00:00 2001 From: jxom <7336481+jxom@users.noreply.github.com> Date: Sat, 14 Dec 2024 13:44:42 +0100 Subject: [PATCH] feat(erc6492): universal validator exports (#40) * feat(erc6492): adds bytecode and abi constants Co-Authored-By: gregfromstl * feat: up * chore: changeset * chore: format --------- Co-authored-by: gregfromstl Co-authored-by: jxom --- .changeset/strange-toes-flash.md | 5 + contracts/generated.ts | 141 +++++++++++++++++- contracts/src/UniversalSigValidator.sol | 86 +++++++++++ .../DeploylessUniversalSigValidator.sol | 16 ++ src/erc6492/WrappedSignature.ts | 57 +++++++ 5 files changed, 301 insertions(+), 4 deletions(-) create mode 100644 .changeset/strange-toes-flash.md create mode 100644 contracts/src/UniversalSigValidator.sol create mode 100644 contracts/src/deployless/DeploylessUniversalSigValidator.sol diff --git a/.changeset/strange-toes-flash.md b/.changeset/strange-toes-flash.md new file mode 100644 index 00000000..8c8283a1 --- /dev/null +++ b/.changeset/strange-toes-flash.md @@ -0,0 +1,5 @@ +--- +"ox": patch +--- + +**ox/erc6492:** Added universal signature verification exports. diff --git a/contracts/generated.ts b/contracts/generated.ts index 2b3eed8f..3955bb9a 100644 --- a/contracts/generated.ts +++ b/contracts/generated.ts @@ -1,3 +1,76 @@ +export const IERC1271Wallet = { + "abi": [ + { + "type": "function", + "name": "isValidSignature", + "inputs": [ + { + "name": "hash", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "signature", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "magicValue", + "type": "bytes4", + "internalType": "bytes4" + } + ], + "stateMutability": "view" + } + ], + "bytecode": { + "object": "0x", + "sourceMap": "", + "linkReferences": {} + } +} as const; + +export const VerifySig = { + "abi": [ + { + "type": "function", + "name": "isValidSig", + "inputs": [ + { + "name": "_signer", + "type": "address", + "internalType": "address" + }, + { + "name": "_hash", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "_signature", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + } + ], + "bytecode": { + "object": "0x6080604052348015600e575f5ffd5b506107008061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c806398ef1ed81461002d575b5f5ffd5b61004061003b3660046104e4565b610054565b604051901515815260200160405180910390f35b5f7f649264926492649264926492649264926492649264926492649264926492649261007f8361042c565b036101e9575f6060808480602001905181019061009c91906105c6565b60405192955090935091505f906001600160a01b038516906100bf90859061063d565b5f604051808303815f865af19150503d805f81146100f8576040519150601f19603f3d011682016040523d82523d5f602084013e6100fd565b606091505b50509050876001600160a01b03163b5f0361016457806101645760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610194908b908790600401610653565b602060405180830381865afa1580156101af573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101d3919061068f565b6001600160e01b03191614945050505050610425565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e906102299087908790600401610653565b602060405180830381865afa158015610244573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610268919061068f565b6001600160e01b031916149050610425565b81516041146102f15760405162461bcd60e51b815260206004820152603a60248201527f5369676e617475726556616c696461746f72237265636f7665725369676e657260448201527f3a20696e76616c6964207369676e6174757265206c656e677468000000000000606482015260840161015b565b6102f9610443565b50602082015160408084015184518593925f91859190811061031d5761031d6106b6565b016020015160f81c9050601b811480159061033c57508060ff16601c14155b156103af5760405162461bcd60e51b815260206004820152603b60248201527f5369676e617475726556616c696461746f72237265636f7665725369676e657260448201527f3a20696e76616c6964207369676e617475726520762076616c75650000000000606482015260840161015b565b604080515f81526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa15801561040a573d5f5f3e3d5ffd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b5f60208251101561043b575f5ffd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b0381168114610475575f5ffd5b50565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff811182821017156104b5576104b5610478565b604052919050565b5f67ffffffffffffffff8211156104d6576104d6610478565b50601f01601f191660200190565b5f5f5f606084860312156104f6575f5ffd5b833561050181610461565b925060208401359150604084013567ffffffffffffffff811115610523575f5ffd5b8401601f81018613610533575f5ffd5b8035610546610541826104bd565b61048c565b81815287602083850101111561055a575f5ffd5b816020840160208301375f602083830101528093505050509250925092565b5f82601f830112610588575f5ffd5b8151610596610541826104bd565b8181528460208386010111156105aa575f5ffd5b8160208501602083015e5f918101602001919091529392505050565b5f5f5f606084860312156105d8575f5ffd5b83516105e381610461565b602085015190935067ffffffffffffffff8111156105ff575f5ffd5b61060b86828701610579565b925050604084015167ffffffffffffffff811115610627575f5ffd5b61063386828701610579565b9150509250925092565b5f82518060208501845e5f920191825250919050565b828152604060208201525f82518060408401528060208501606085015e5f606082850101526060601f19601f8301168401019150509392505050565b5f6020828403121561069f575f5ffd5b81516001600160e01b031981168114610425575f5ffd5b634e487b7160e01b5f52603260045260245ffdfea2646970667358221220a9ddcb9c588d78c3dda1ffd12723a6c843e07c1e5feba18b01aabd0018b60f2464736f6c634300081c0033", + "sourceMap": "285:2507:0:-:0;;;;;;;;;;;;;;;;;;;", + "linkReferences": {} + } +} as const; + export const NonConformingEvents = { "abi": [ { @@ -46,7 +119,7 @@ export const NonConformingEvents = { ], "bytecode": { "object": "0x6080604052348015600e575f5ffd5b5060ec8061001b5f395ff3fe6080604052348015600e575f5ffd5b50600436106026575f3560e01c8063a9059cbb14602a575b5f5ffd5b603960353660046083565b603b565b005b604080516001600160a01b03841681526020810183905233917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a25050565b5f5f604083850312156093575f5ffd5b82356001600160a01b038116811460a8575f5ffd5b94602093909301359350505056fea2646970667358221220f1a43a70e034d64a42c0c02f777280585aecd6e4e9728db86b68a4e4ed0b5b4864736f6c634300081c0033", - "sourceMap": "64:296:3:-:0;;;;;;;;;;;;;;;;;;;", + "sourceMap": "64:296:5:-:0;;;;;;;;;;;;;;;;;;;", "linkReferences": {} } } as const; @@ -88,7 +161,7 @@ export const Events = { ], "bytecode": { "object": "0x6080604052348015600e575f5ffd5b5060d780601a5f395ff3fe608060405260043610601b575f3560e01c80636146195414601f575b5f5ffd5b60256027565b005b336001600160a01b03167f7b2cff6dbed2a9cdb935eb6c46afadba8c4436a7aef48222ff62fce1ece4fcf3345f36604051606293929190606c565b60405180910390a2565b83815260406020820152816040820152818360608301375f818301606090810191909152601f909201601f191601019291505056fea264697066735822122046dd8d3b7894fce95fae19739eff9c19193682f91a782f02f49e69e40af13b1364736f6c634300081c0033", - "sourceMap": "64:203:2:-:0;;;;;;;;;;;;;;;;;;;", + "sourceMap": "64:203:4:-:0;;;;;;;;;;;;;;;;;;;", "linkReferences": {} } } as const; @@ -276,7 +349,67 @@ export const Errors = { ], "bytecode": { "object": "0x6080604052348015600e575f5ffd5b5061030f8061001c5f395ff3fe608060405234801561000f575f5ffd5b50600436106100f0575f3560e01c80638de18b9111610093578063c66cf13311610063578063c66cf13314610106578063d44de86614610127578063eb1aba20146100f4578063efbbf9951461013f575f5ffd5b80638de18b91146100fe578063940b8802146101375780639f55870914610137578063a997732e1461012f575f5ffd5b80634a9bc278116100ce5780634a9bc278146101205780634adac6eb14610127578063699389ca1461012057806388452b851461012f575f5ffd5b806304696152146100f45780631515d768146100fe57806324db9ba014610106575b5f5ffd5b6100fc610147565b005b6100fc610151565b61010e6101bb565b60405190815260200160405180910390f35b6100fc5f5ffd5b61010e6101d2565b6100fc6101e2565b6100fc6101fb565b6100fc610243565b61014f61025c565b565b6040805180820182525f815260456020820181815292516336dcc73d60e21b815291516001600160a01b0316600483015291516024820152608060448201526006608482015265313ab3b3b2b960d11b60a4820152606481019190915260c4015b60405180910390fd5b5f604581806101ca8184610270565b949350505050565b5f5f196001826101ca828461028f565b604051631f200c7360e31b81526004016101b2906102b4565b60405162461bcd60e51b815260206004820152601860248201527f54686973206973206120726576657274206d657373616765000000000000000060448201526064016101b2565b6040516333a3b5cd60e11b815260040160405180910390fd5b634e487b7160e01b5f52600160045260245ffd5b5f8261028a57634e487b7160e01b5f52601260045260245ffd5b500490565b808201808211156102ae57634e487b7160e01b5f52601160045260245ffd5b92915050565b602081525f6102ae602083016006815265313ab3b3b2b960d11b60208201526040019056fea2646970667358221220ec17f5501273e76af6d6e55ad15c5a2aa52d876b232a4c083f76967a9eb2688964736f6c634300081c0033", - "sourceMap": "64:2024:1:-:0;;;;;;;;;;;;;;;;;;;", + "sourceMap": "64:2024:3:-:0;;;;;;;;;;;;;;;;;;;", + "linkReferences": {} + } +} as const; + +export const DeploylessVerifySig = { + "abi": [ + { + "type": "constructor", + "inputs": [ + { + "name": "_signer", + "type": "address", + "internalType": "address" + }, + { + "name": "_hash", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "_signature", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "isValidSig", + "inputs": [ + { + "name": "_signer", + "type": "address", + "internalType": "address" + }, + { + "name": "_hash", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "_signature", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + } + ], + "bytecode": { + "object": "0x608060405234801561000f575f5ffd5b5060405161064438038061064483398101604081905261002e916104e0565b5f61003a848484610045565b9050805f526001601ff35b5f7f6492649264926492649264926492649264926492649264926492649264926492610070836103f7565b036101da575f6060808480602001905181019061008d9190610535565b60405192955090935091505f906001600160a01b038516906100b0908590610596565b5f604051808303815f865af19150503d805f81146100e9576040519150601f19603f3d011682016040523d82523d5f602084013e6100ee565b606091505b50509050876001600160a01b03163b5f0361015557806101555760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610185908b9087906004016105ac565b602060405180830381865afa1580156101a0573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101c491906105e8565b6001600160e01b031916149450505050506103f0565b6001600160a01b0384163b1561026b57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061021a90879087906004016105ac565b602060405180830381865afa158015610235573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061025991906105e8565b6001600160e01b0319161490506103f0565b81516041146102cf5760405162461bcd60e51b815260206004820152603a60248201525f5160206106245f395f51905f5260448201527f3a20696e76616c6964207369676e6174757265206c656e677468000000000000606482015260840161014c565b6102d761040e565b50602082015160408084015184518593925f9185919081106102fb576102fb61060f565b016020015160f81c9050601b811480159061031a57508060ff16601c14155b1561037a5760405162461bcd60e51b815260206004820152603b60248201525f5160206106245f395f51905f5260448201527f3a20696e76616c6964207369676e617475726520762076616c75650000000000606482015260840161014c565b604080515f81526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103d5573d5f5f3e3d5ffd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b5f602082511015610406575f5ffd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b0381168114610440575f5ffd5b50565b634e487b7160e01b5f52604160045260245ffd5b5f82601f830112610466575f5ffd5b81516001600160401b0381111561047f5761047f610443565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ad576104ad610443565b6040528181528382016020018510156104c4575f5ffd5b8160208501602083015e5f918101602001919091529392505050565b5f5f5f606084860312156104f2575f5ffd5b83516104fd8161042c565b6020850151604086015191945092506001600160401b0381111561051f575f5ffd5b61052b86828701610457565b9150509250925092565b5f5f5f60608486031215610547575f5ffd5b83516105528161042c565b60208501519093506001600160401b0381111561056d575f5ffd5b61057986828701610457565b604086015190935090506001600160401b0381111561051f575f5ffd5b5f82518060208501845e5f920191825250919050565b828152604060208201525f82518060408401528060208501606085015e5f606082850101526060601f19601f8301168401019150509392505050565b5f602082840312156105f8575f5ffd5b81516001600160e01b0319811681146103f0575f5ffd5b634e487b7160e01b5f52603260045260245ffdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572", + "sourceMap": "176:275:1:-:0;;;224:225;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;303:12;318:38;329:7;338:5;345:10;318;:38::i;:::-;303:53;;399:7;396:1;389:18;431:1;427:2;420:13;658:1911:0;781:4;434:66;1138:27;1154:10;1138:15;:27::i;:::-;:55;1134:674;;1209:22;1245:28;1287:24;1402:10;1374:93;;;;;;;;;;;;:::i;:::-;1501:36;;1325:142;;-1:-1:-1;1325:142:0;;-1:-1:-1;1325:142:0;-1:-1:-1;1483:12:0;;-1:-1:-1;;;;;1501:19:0;;;:36;;1325:142;;1501:36;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1482:55;;;1556:7;-1:-1:-1;;;;;1556:19:0;;1579:1;1556:24;1552:113;;1608:7;1600:50;;;;-1:-1:-1;;;1600:50:0;;2740:2:6;1600:50:0;;;2722:21:6;2779:2;2759:18;;;2752:30;2818:32;2798:18;;;2791:60;2868:18;;1600:50:0;;;;;;;;;1702:60;;-1:-1:-1;;;1702:60:0;;;1782:15;-1:-1:-1;;;;;1702:40:0;;;548:10;;1702:60;;1743:5;;1750:11;;1702:60;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;-1:-1:-1;;;;;1702:95:0;;;1679:118;;;;;;;;1134:674;-1:-1:-1;;;;;1822:19:0;;;:23;1818:171;;1884:59;;-1:-1:-1;;;1884:59:0;;;1963:15;-1:-1:-1;;;;;1884:40:0;;;548:10;;1884:59;;1925:5;;1932:10;;1884:59;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;-1:-1:-1;;;;;;1884:94:0;;;-1:-1:-1;1861:117:0;;1818:171;2054:10;:17;2075:2;2054:23;2033:128;;;;-1:-1:-1;;;2033:128:0;;3886:2:6;2033:128:0;;;3868:21:6;3925:2;3905:18;;;3898:30;-1:-1:-1;;;;;;;;;;;3944:18:6;;;3937:62;4035:28;4015:18;;;4008:56;4081:19;;2033:128:0;3684:422:6;2033:128:0;2171:22;;:::i;:::-;-1:-1:-1;2275:7:0;;;;2304;;;;;2337:14;;2234:10;;2275:7;2263:9;;2234:10;;2304:7;2337:14;;;;;;:::i;:::-;;;;;;;;-1:-1:-1;2371:2:0;2366:7;;;;;:18;;;2377:1;:7;;2382:2;2377:7;;2366:18;2362:148;;;2400:99;;-1:-1:-1;;;2400:99:0;;4445:2:6;2400:99:0;;;4427:21:6;4484:2;4464:18;;;4457:30;-1:-1:-1;;;;;;;;;;;4503:18:6;;;4496:62;4594:29;4574:18;;;4567:57;4641:19;;2400:99:0;4243:423:6;2362:148:0;2526:25;;;;;;;;;;;;4898::6;;;4971:4;4959:17;;4939:18;;;4932:45;;;;4993:18;;;4986:34;;;5036:18;;;5029:34;;;-1:-1:-1;;;;;2526:36:0;;;:25;;4870:19:6;;2526:25:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;2526:36:0;;2519:43;;;;;;658:1911;;;;;;:::o;2575:215::-;2656:11;2702:2;2687:4;:11;:17;;2679:26;;;;;;-1:-1:-1;2761:11:0;;2751:22;2745:29;;2575:215::o;176:275:1:-;;;;;;;;;;;;;;;;;;-1:-1:-1;176:275:1;;;-1:-1:-1;;176:275:1:o;14:131:6:-;-1:-1:-1;;;;;89:31:6;;79:42;;69:70;;135:1;132;125:12;69:70;14:131;:::o;150:127::-;211:10;206:3;202:20;199:1;192:31;242:4;239:1;232:15;266:4;263:1;256:15;282:722;335:5;388:3;381:4;373:6;369:17;365:27;355:55;;406:1;403;396:12;355:55;433:13;;-1:-1:-1;;;;;458:30:6;;455:56;;;491:18;;:::i;:::-;540:2;534:9;632:2;594:17;;-1:-1:-1;;590:31:6;;;623:2;586:40;582:54;570:67;;-1:-1:-1;;;;;652:34:6;;688:22;;;649:62;646:88;;;714:18;;:::i;:::-;750:2;743:22;774;;;815:19;;;836:4;811:30;808:39;-1:-1:-1;805:59:6;;;860:1;857;850:12;805:59;917:6;910:4;902:6;898:17;891:4;883:6;879:17;873:51;972:1;944:19;;;965:4;940:30;933:41;;;;948:6;282:722;-1:-1:-1;;;282:722:6:o;1009:524::-;1106:6;1114;1122;1175:2;1163:9;1154:7;1150:23;1146:32;1143:52;;;1191:1;1188;1181:12;1143:52;1223:9;1217:16;1242:31;1267:5;1242:31;:::i;:::-;1337:2;1322:18;;1316:25;1385:2;1370:18;;1364:25;1292:5;;-1:-1:-1;1316:25:6;-1:-1:-1;;;;;;1401:30:6;;1398:50;;;1444:1;1441;1434:12;1398:50;1467:60;1519:7;1510:6;1499:9;1495:22;1467:60;:::i;:::-;1457:70;;;1009:524;;;;;:::o;1538:689::-;1652:6;1660;1668;1721:2;1709:9;1700:7;1696:23;1692:32;1689:52;;;1737:1;1734;1727:12;1689:52;1769:9;1763:16;1788:31;1813:5;1788:31;:::i;:::-;1887:2;1872:18;;1866:25;1838:5;;-1:-1:-1;;;;;;1903:30:6;;1900:50;;;1946:1;1943;1936:12;1900:50;1969:60;2021:7;2012:6;2001:9;1997:22;1969:60;:::i;:::-;2075:2;2060:18;;2054:25;1959:70;;-1:-1:-1;2054:25:6;-1:-1:-1;;;;;;2091:32:6;;2088:52;;;2136:1;2133;2126:12;2232:301;2361:3;2399:6;2393:13;2445:6;2438:4;2430:6;2426:17;2421:3;2415:37;2507:1;2471:16;;2496:13;;;-1:-1:-1;2471:16:6;2232:301;-1:-1:-1;2232:301:6:o;2897:487::-;3072:6;3061:9;3054:25;3115:2;3110;3099:9;3095:18;3088:30;3035:4;3147:6;3141:13;3190:6;3185:2;3174:9;3170:18;3163:34;3249:6;3244:2;3236:6;3232:15;3227:2;3216:9;3212:18;3206:50;3305:1;3300:2;3291:6;3280:9;3276:22;3272:31;3265:42;3375:2;3368;3364:7;3359:2;3351:6;3347:15;3343:29;3332:9;3328:45;3324:54;3316:62;;;2897:487;;;;;:::o;3389:290::-;3458:6;3511:2;3499:9;3490:7;3486:23;3482:32;3479:52;;;3527:1;3524;3517:12;3479:52;3553:16;;-1:-1:-1;;;;;;3598:32:6;;3588:43;;3578:71;;3645:1;3642;3635:12;4111:127;4172:10;4167:3;4163:20;4160:1;4153:31;4203:4;4200:1;4193:15;4227:4;4224:1;4217:15", "linkReferences": {} } } as const; @@ -302,7 +435,7 @@ export const Constructor = { ], "bytecode": { "object": "0x6080604052348015600e575f5ffd5b5060405160ad38038060ad833981016040819052602991602f565b50506064565b5f5f60408385031215603f575f5ffd5b82516001600160a01b03811681146054575f5ffd5b6020939093015192949293505050565b603e80606f5f395ff3fe60806040525f5ffdfea26469706673582212208b9916d37ad73f2bbfce8faec2ac34926f33b83e62d9f362db436a5b684f215464736f6c634300081c0033", - "sourceMap": "64:78:0:-:0;;;91:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;64:78;;14:351:4;93:6;101;154:2;142:9;133:7;129:23;125:32;122:52;;;170:1;167;160:12;122:52;196:16;;-1:-1:-1;;;;;241:31:4;;231:42;;221:70;;287:1;284;277:12;221:70;355:2;340:18;;;;334:25;310:5;;334:25;;-1:-1:-1;;;14:351:4:o;:::-;64:78:0;;;;;;", + "sourceMap": "64:78:2:-:0;;;91:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;64:78;;14:351:6;93:6;101;154:2;142:9;133:7;129:23;125:32;122:52;;;170:1;167;160:12;122:52;196:16;;-1:-1:-1;;;;;241:31:6;;231:42;;221:70;;287:1;284;277:12;221:70;355:2;340:18;;;;334:25;310:5;;334:25;;-1:-1:-1;;;14:351:6:o;:::-;64:78:2;;;;;;", "linkReferences": {} } } as const; diff --git a/contracts/src/UniversalSigValidator.sol b/contracts/src/UniversalSigValidator.sol new file mode 100644 index 00000000..17eb6f74 --- /dev/null +++ b/contracts/src/UniversalSigValidator.sol @@ -0,0 +1,86 @@ +pragma solidity ^0.8.17; + +// SPDX-License-Identifier: UNLICENSED + +// https://github.com/AmbireTech/signature-validator + +interface IERC1271Wallet { + function isValidSignature( + bytes32 hash, + bytes calldata signature + ) external view returns (bytes4 magicValue); +} + +contract VerifySig { + // ERC-6492 suffix: https://eips.ethereum.org/EIPS/eip-6492 + bytes32 private constant ERC6492_DETECTION_SUFFIX = + 0x6492649264926492649264926492649264926492649264926492649264926492; + bytes4 private constant ERC1271_SUCCESS = 0x1626ba7e; + + /** + * @notice Verifies that the signature is valid for that signer and hash + */ + function isValidSig( + address _signer, + bytes32 _hash, + bytes memory _signature + ) public returns (bool) { + // The order here is strictly defined in https://eips.ethereum.org/EIPS/eip-6492 + // - ERC-6492 suffix check and verification first, while being permissive in case the contract is already deployed so as to not invalidate old sigs + // - ERC-1271 verification if there's contract code + // - finally, ecrecover + if (trailingBytes32(_signature) == ERC6492_DETECTION_SUFFIX) { + address create2Factory; + bytes memory factoryCalldata; + bytes memory originalSig; + (create2Factory, factoryCalldata, originalSig) = abi.decode( + _signature, + (address, bytes, bytes) + ); + + (bool success, ) = create2Factory.call(factoryCalldata); + + if (_signer.code.length == 0) { + require(success, "SignatureValidator: deployment"); + } + + return + IERC1271Wallet(_signer).isValidSignature(_hash, originalSig) == + ERC1271_SUCCESS; + } + + if (_signer.code.length > 0) { + return + IERC1271Wallet(_signer).isValidSignature(_hash, _signature) == + ERC1271_SUCCESS; + } + + // ecrecover verification + require( + _signature.length == 65, + "SignatureValidator#recoverSigner: invalid signature length" + ); + bytes32[3] memory _sig; + assembly { + _sig := _signature + } + bytes32 r = _sig[1]; + bytes32 s = _sig[2]; + uint8 v = uint8(_signature[64]); + if (v != 27 && v != 28) { + revert( + "SignatureValidator#recoverSigner: invalid signature v value" + ); + } + return ecrecover(_hash, v, r, s) == _signer; + } + + function trailingBytes32( + bytes memory data + ) internal pure returns (bytes32 ret) { + require(data.length >= 32); + assembly { + ret := mload(add(data, mload(data))) + } + } +} diff --git a/contracts/src/deployless/DeploylessUniversalSigValidator.sol b/contracts/src/deployless/DeploylessUniversalSigValidator.sol new file mode 100644 index 00000000..a25adc9e --- /dev/null +++ b/contracts/src/deployless/DeploylessUniversalSigValidator.sol @@ -0,0 +1,16 @@ +pragma solidity ^0.8.17; + +// SPDX-License-Identifier: UNLICENSED + +// https://github.com/AmbireTech/signature-validator +import {VerifySig} from "../UniversalSigValidator.sol"; + +contract DeploylessVerifySig is VerifySig { + constructor(address _signer, bytes32 _hash, bytes memory _signature) { + bool isValid = isValidSig(_signer, _hash, _signature); + assembly { + mstore(0, isValid) + return(31, 1) + } + } +} diff --git a/src/erc6492/WrappedSignature.ts b/src/erc6492/WrappedSignature.ts index 008c023a..96c2528b 100644 --- a/src/erc6492/WrappedSignature.ts +++ b/src/erc6492/WrappedSignature.ts @@ -1,3 +1,4 @@ +import type * as Abi from '../core/Abi.js' import * as AbiParameters from '../core/AbiParameters.js' import type * as Address from '../core/Address.js' import * as Errors from '../core/Errors.js' @@ -20,6 +21,62 @@ export type WrappedSignature = { export const magicBytes = '0x6492649264926492649264926492649264926492649264926492649264926492' as const +/** + * Bytecode constant universal signature validation contract. + */ +export const universalSignatureValidatorByteCode = + '0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572' + +/** + * ABI for the ERC-6492 universal deployless signature validator contract. + * + * Constructor return value is `0x1` (valid) or `0x0` (invalid). + */ +export const universalSignatureValidatorAbi = [ + { + inputs: [ + { + name: '_signer', + type: 'address', + }, + { + name: '_hash', + type: 'bytes32', + }, + { + name: '_signature', + type: 'bytes', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [ + { + name: '_signer', + type: 'address', + }, + { + name: '_hash', + type: 'bytes32', + }, + { + name: '_signature', + type: 'bytes', + }, + ], + outputs: [ + { + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + name: 'isValidSig', + }, +] as const satisfies Abi.Abi + /** * Asserts that the wrapped signature is valid. *