From 7e0b69725e9e9857478becfff5b630872a9685fb Mon Sep 17 00:00:00 2001 From: KONFeature Date: Mon, 8 Jan 2024 12:20:07 +0100 Subject: [PATCH 01/12] =?UTF-8?q?=F0=9F=9A=A7=20Simple=20webauthn=20valida?= =?UTF-8?q?tor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/WebAuthnWrapper.sol | 30 +++++++ src/validator/WebAuthnValidator.sol | 126 ++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 src/utils/WebAuthnWrapper.sol create mode 100644 src/validator/WebAuthnValidator.sol diff --git a/src/utils/WebAuthnWrapper.sol b/src/utils/WebAuthnWrapper.sol new file mode 100644 index 00000000..58c03425 --- /dev/null +++ b/src/utils/WebAuthnWrapper.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {FCL_WebAuthn} from "FreshCryptoLib/FCL_Webauthn.sol"; + +/// @title WebAuthnWrapper +/// @author obatirou +/// @notice A library used to verify ECDSA signatures over secp256r1 through +/// EIP-1271 of Webauthn payloads. +/// From https://github.com/cometh-game/p256-signer/blob/main/contracts/FCL/WrapperFCLWebAuthn.sol +/// @dev This lib is only a wrapper around the FCL_WebAuthn library. +/// It is meant to be used with 1271 signatures. +/// The wrapping is necessary because the FCL_WebAuthn has only internal +/// functions and use calldata. This makes it impossible to use it with +/// isValidSignature that use memory. +library WebAuthnWrapper { + function checkSignature( + bytes calldata authenticatorData, + bytes1 authenticatorDataFlagMask, + bytes calldata clientData, + bytes32 clientChallenge, + uint256 clientChallengeDataOffset, + uint256[2] calldata rs, + uint256[2] calldata Q + ) external view returns (bool) { + return FCL_WebAuthn.checkSignature( + authenticatorData, authenticatorDataFlagMask, clientData, clientChallenge, clientChallengeDataOffset, rs, Q + ); + } +} diff --git a/src/validator/WebAuthnValidator.sol b/src/validator/WebAuthnValidator.sol new file mode 100644 index 00000000..be0ad71f --- /dev/null +++ b/src/validator/WebAuthnValidator.sol @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {UserOperation} from "I4337/interfaces/UserOperation.sol"; +import {ECDSA} from "solady/utils/ECDSA.sol"; +import {IKernelValidator} from "../interfaces/IKernelValidator.sol"; +import {ValidationData} from "../common/Types.sol"; +import {SIG_VALIDATION_FAILED} from "../common/Constants.sol"; +import {WebAuthnWrapper} from "../utils/WebAuthnWrapper.sol"; + +/// @dev Storage layout for a kernel in the WebAuthnValidator contract. +struct WebAuthnValidatorStorage { + /// @dev The `x` coord of the secp256r1 public key used to sign the user operation. + uint256 x; + /// @dev The `y` coord of the secp256r1 public key used to sign the user operation. + uint256 y; +} + +/// @author @KONFeature +/// @title WebAuthnValidator +/// @notice Kernel validator used to validated user operations via WebAuthn signature (using P256 under the hood) +/// @notice Using the awesome FreshCryptoLib: https://github.com/rdubois-crypto/FreshCryptoLib/ +/// @notice Inspired by the cometh Gnosis Safe signer: https://github.com/cometh-game/p256-signer +contract WebAuthnValidator is IKernelValidator { + /// @dev Event emitted when the public key signing the WebAuthN user operation is changed for a given `kernel`. + event WebAuthnPublicKeyChanged(address indexed kernel, uint256 x, uint256 y); + + /// @dev Mapping of kernel address to each webAuthn specific storage + mapping(address kernel => WebAuthnValidatorStorage webAuthnStorage) private webAuthnValidatorStorage; + + /// @dev Disable this validator for a given `kernel` (msg.sender) + function disable(bytes calldata) external payable override { + delete webAuthnValidatorStorage[msg.sender]; + } + + /// @dev Enable this validator for a given `kernel` (msg.sender) + function enable(bytes calldata _data) external payable override { + // Extract the x & y coordinates of the public key from the `_data` bytes + (uint256 x, uint256 y) = abi.decode(_data, (uint256, uint256)); + // Update the pub key data + WebAuthnValidatorStorage storage kernelValidatorStorage = webAuthnValidatorStorage[msg.sender]; + kernelValidatorStorage.x = x; + kernelValidatorStorage.y = y; + // Emit the update event + emit WebAuthnPublicKeyChanged(msg.sender, x, y); + } + + /// @dev Validate a `_userOp` using a WebAuthn Signature for the kernel account who is the `_userOp` sender + function validateUserOp(UserOperation calldata _userOp, bytes32 _userOpHash, uint256) + external + payable + override + returns (ValidationData validationData) + { + WebAuthnValidatorStorage memory kernelValidatorStorage = webAuthnValidatorStorage[_userOp.sender]; + + // Perform a check against the direct userOpHash, if ok consider the user op as validated + if (!_checkSignature(kernelValidatorStorage, _userOpHash, _userOp.signature)) { + return ValidationData.wrap(0); + } + + return SIG_VALIDATION_FAILED; + } + + /// @dev Validate a `_signature` of the `_hash` ofor the given `kernel` (msg.sender) + function validateSignature(bytes32 _hash, bytes calldata _signature) + public + view + override + returns (ValidationData) + { + WebAuthnValidatorStorage memory kernelValidatorStorage = webAuthnValidatorStorage[msg.sender]; + + // Check the validity againt the hash directly + if (_checkSignature(kernelValidatorStorage, _hash, _signature)) { + return ValidationData.wrap(0); + } + + // Otherwise, all good + return SIG_VALIDATION_FAILED; + } + + /// @notice Validates the given `_signature` againt the `_hash` for the given `kernel` (msg.sender) + /// @param _kernelValidatorStorage The kernel storage replication (helping us to fetch the X & Y points of the public key) + /// @param _hash The hash signed + /// @param _signature The signature + function _checkSignature( + WebAuthnValidatorStorage memory _kernelValidatorStorage, + bytes32 _hash, + bytes memory _signature + ) private view returns (bool) { + // Decode the signature + (bytes memory authenticatorData, bytes memory clientData, uint256 challengeOffset, uint256[2] memory rs) = + abi.decode(_signature, (bytes, bytes, uint256, uint256[2])); + + // Verify the signature + return WebAuthnWrapper.checkSignature( + authenticatorData, + 0x01, + clientData, + _hash, + challengeOffset, + rs, + [_kernelValidatorStorage.x, _kernelValidatorStorage.y] + ); + } + + /// @dev Check if the caller is a valid signer, this don't apply to the WebAuthN validator, since it's using a public key + function validCaller(address, bytes calldata) external pure override returns (bool) { + revert NotImplemented(); + } + + /* -------------------------------------------------------------------------- */ + /* Public view methods */ + /* -------------------------------------------------------------------------- */ + + /// @dev Get the owner of a given `kernel` + function getPublicKey(address _kernel) public view returns (uint256 x, uint256 y) { + // Compute the storage slot + WebAuthnValidatorStorage storage kernelValidatorStorage = webAuthnValidatorStorage[_kernel]; + + // Access it for x and y + x = kernelValidatorStorage.x; + y = kernelValidatorStorage.y; + } +} From 2b8d585e22726a0ac5c5da47fe669f9cc61f67b1 Mon Sep 17 00:00:00 2001 From: KONFeature Date: Mon, 8 Jan 2024 15:25:45 +0100 Subject: [PATCH 02/12] =?UTF-8?q?=F0=9F=9A=A7=20Add=20deploy=20script=20fo?= =?UTF-8?q?r=20WebAuthN=20validator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../80001/run-1704722702.json | 52 ++++++++ .../80001/run-1704722737.json | 55 ++++++++ .../80001/run-1704722750.json | 119 ++++++++++++++++++ .../80001/run-latest.json | 119 ++++++++++++++++++ scripts/DeployWebAuthnValidator.s.sol | 19 +++ 5 files changed, 364 insertions(+) create mode 100644 broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722702.json create mode 100644 broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722737.json create mode 100644 broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722750.json create mode 100644 broadcast/DeployWebAuthnValidator.s.sol/80001/run-latest.json create mode 100644 scripts/DeployWebAuthnValidator.s.sol diff --git a/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722702.json b/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722702.json new file mode 100644 index 00000000..63025e8e --- /dev/null +++ b/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722702.json @@ -0,0 +1,52 @@ +{ + "transactions": [ + { + "hash": null, + "transactionType": "CREATE", + "contractName": "WebAuthnWrapper", + "contractAddress": "0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519", + "function": null, + "arguments": null, + "transaction": { + "type": "0x02", + "from": "0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38", + "gas": "0x12e329", + "data": "0x6080806040523461001a576110449081610020823930815050f35b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c630d5efec91461002857600080fd5b6101203660031901126100c35767ffffffffffffffff6004358181116100c6576100569036906004016100ca565b90916024359360ff60f81b851685036100c3576044359182116100c3576100bf6100ad86868661008936600489016100ca565b610095939193366100fd565b9361009f3661010a565b956084359460643594610118565b60405190151581529081906020820190565b0390f35b80fd5b8280fd5b9181601f840112156100f85782359167ffffffffffffffff83116100f857602083818601950101116100f857565b600080fd5b9060a49160e4116100f857565b9060e491610124116100f857565b939291979695949094602098806101406101328989610258565b356001600160f81b03191690565b169060ff60f81b8091169116036102465760405189810192835291829003808352601f199261017b916101769060200182610293565b610f0f565b9061018682516102fa565b80518b82019286018337519020916101b560405191826101a98d8201809661032c565b03908101835282610293565b51902003610234578691600091856101d46101cf8261036d565b6102fa565b95858701376101e86040518093819361038e565b039060025afa1561022f5761020f600091869384845191830101526040519182809261032c565b039060025afa1561022f5761022c928201359135906000516103c4565b90565b61039c565b60405163ebab5d2960e01b8152600490fd5b604051637e49a3c960e11b8152600490fd5b90602010156102675760200190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102b557604052565b61027d565b67ffffffffffffffff81116102b557601f01601f191660200190565b604051906020820182811067ffffffffffffffff8211176102b55760405260008252565b90610304826102ba565b6103116040519182610293565b8281528092610322601f19916102ba565b0190602036910137565b9081519160005b838110610344575050016000815290565b8060208092840101518185015201610333565b634e487b7160e01b600052601160045260246000fd5b906020820180921161037b57565b610357565b906002820180921161037b57565b908092918237016000815290565b6040513d6000823e3d90fd5b9060008051602061100483398151915291820391821161037b57565b60209382359390928501359190841580156104aa575b80156104a2575b801561048a575b61047f576103f684826104c2565b1561047f5760405192868452868085015286604085015260608401527fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f6080840152600080516020611004833981519152958660a08501528360c0816005600019fa156100f8576104799386610473945181818909940991610583565b916103a8565b90081590565b505050505050600090565b506000805160206110048339815191528310156103e8565b5082156103e1565b506000805160206110048339815191528510156103da565b80158061057b575b8015610564575b801561054d575b61054657600160601b63ffffffff60c01b03199081907f5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b90829081807fffffffff00000001000000000000000000000000fffffffffffffffffffffffc830991818180090908089180091490565b5050600090565b50600160601b63ffffffff60c01b031982146104d8565b50600160601b63ffffffff60c01b031981146104d1565b5081156104ca565b60009260ff92849291801580610c67575b610c5b576105a28284610c6f565b9095861580610c53575b610c33575b82811c60028a60fe1c16015b15610c1957600183821c1660028a831c60011b160160018114610be0575b60028114610bcf575b600314610bc2575b600198600019919091019692959493928992915b8a896000191161066f575050505050505050505060405191606083015260208252602080830152602060408301526000805160206110248339815191526080830152600163ffffffff60601b0360601b19918260a082015260208160c0816005600019fa156100f85751900990565b90919293949596979899600163ffffffff60601b0360601b198960020998600160601b63ffffffff60c01b03198a800999600160601b63ffffffff60c01b03198b840990600160601b63ffffffff60c01b0319908c900993849390600160601b63ffffffff60c01b03199081908181850890600160601b63ffffffff60c01b031990810385080960030998600160601b63ffffffff60c01b03199085099e600160601b63ffffffff60c01b0319908d099b600160601b63ffffffff60c01b031991829182910960008051602061102483398151915209600160601b63ffffffff60c01b03198a80090897600160601b63ffffffff60c01b031991829081038a08900992600160601b63ffffffff60c01b03199184918391900908918a8c1c600116848d1c60011b6002160115610ba35760018c600286838f841c16921c831b160114610b6c575b838c8c6002600182841c168185851c60011b160114610b59575b6003926001600292841c16921c60011b160114610b50575b8915610b3d57600160601b63ffffffff60c01b031990839082908f90090890600160601b63ffffffff60c01b0319908782039082908c900908988115610909575b600160601b63ffffffff60c01b031990818b800990099b600160601b63ffffffff60c01b031990818b8181800909900995600160601b63ffffffff60c01b031990818b80099009600160601b63ffffffff60c01b0319808260008051602061102483398151915209600160601b63ffffffff60c01b0319808d8181800909600160601b63ffffffff60c01b031990810390868009080899600160601b63ffffffff60c01b031993849182908181800909900991600160601b63ffffffff60c01b03199182908c82039008090896985b600019019796959493929190610600565b8961082957959b9a9850600160601b63ffffffff60c01b0319905080808360008051602061102483398151915209600160601b63ffffffff60c01b03198460008051602061102483398151915209098c0999600160601b63ffffffff60c01b0319808781038e08600160601b63ffffffff60c01b0319888f0809600160601b63ffffffff60c01b03199060030990600160601b63ffffffff60c01b0319908180808660008051602061102483398151915209600160601b63ffffffff60c01b0319876000805160206110248339815191520909600160601b63ffffffff60c01b03198660008051602061102483398151915209090995600160601b63ffffffff60c01b03199081808560008051602061102483398151915209600160601b63ffffffff60c01b0319866000805160206110248339815191520909099b600160601b63ffffffff60c01b0319908190819081808760008051602061102483398151915209600160601b63ffffffff60c01b0319886000805160206110248339815191520909900960008051602061102483398151915209600160601b63ffffffff60c01b0319838009089a600160601b63ffffffff60c01b03199283908180808360008051602061102483398151915209600160601b63ffffffff60c01b0319846000805160206110248339815191520909600160601b63ffffffff60c01b03198360008051602061102483398151915209090991600160601b63ffffffff60c01b03199182908e82039008900908966108f8565b60019c50909a9098508b955090506108f8565b505082846107e8565b508a93508992508591508d90508c6107d0565b5050600080516020610fe48339815191527f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f56107b6565b50979a9499600160601b63ffffffff60c01b03199190910397506108f8565b94509550849580946105ec565b9550965083966003849690506105e4565b600080516020610fe483398151915298507f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f596506105db565b60001901600160028185841c16918b841c901b16016105bd565b9790916000805160206110048339815191529182039008906000976105b1565b5081156105ac565b50505050505050600090565b508615610594565b7f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f59291600080516020610fe4833981519152918115610dc75780831480610dbe575b15610da75750600160601b63ffffffff60c01b03199190508184600209918083800992818080808781818909950995817fffffffff00000001000000000000000000000000fffffffffffffffffffffffe816001840892080960030981808080866000805160206110248339815191520981858009089981600181818b099a099709810393898203900890090893915b60405190602082526020808301526020604083015260608201526000805160206110248339815191526080820152600163ffffffff60601b0360601b19928360a083015260208260c0816005600019fa156100f857838080935180950980099009930990565b909150610db5929350610dcd565b91939291610d41565b50818514610cb1565b50509190565b60019283927f94e82e0c1ed3bdb90743191a9c5bbf0d88fc827fd214cc5f0b5ec6ba27673d69600163ffffffff60601b0360601b198095818094817fb01cbd1c01e58065711814b583f061e9d431cca994cea1313449bf97c840ae0a9a8b920908950908928080808087800996870994818088600080516020610fe483398151915209918180808560008051602061102483398151915209818b810381868009080893818a869d0994820390080908946001099260010990565b604051906060820182811067ffffffffffffffff8211176102b557604052604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b600281901b91906001600160fe1b0381160361037b57565b805115610fda57610f1e610e87565b610f3d6101cf610f38610f318551610380565b6003900490565b610ef7565b9160208301918182518301915b828210610f8857505050600390510680600114610f7e57600214610f75575b819003601f1901815290565b60001901610f69565b5060011901610f69565b9091936004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c1688010151600286015316850101519082015301939190610f4a565b5061022c6102d656fe6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551ffffffff00000001000000000000000000000000fffffffffffffffffffffffd", + "nonce": "0x0", + "accessList": [] + }, + "additionalContracts": [], + "isFixedGasLimit": false + }, + { + "hash": null, + "transactionType": "CREATE2", + "contractName": "WebAuthnValidator", + "contractAddress": "0x4Ab13AE00422a94AA9F187f8d7EBBF75dAfc0f3b", + "function": null, + "arguments": null, + "transaction": { + "type": "0x02", + "from": "0x7caf754c934710d7c73bc453654552beca38223f", + "to": "0x4e59b44847b379578588920ca78fbf26c0b4956c", + "gas": "0x92893", + "value": "0x0", + "data": "0x00000000000000000000000000000000000000000000000000000000000000006080806040523461001657610671908161001c8239f35b600080fdfe608060408181526004918236101561001657600080fd5b600090813560e01c9081630c959556146101c957508063333daf921461018a5780633a871cdd14610143578063857cdbb8146100fe5780638fc925aa146100b257639ea9bd591461006657600080fd5b346100af57816003193601126100af5761007e610288565b506024359067ffffffffffffffff82116100af57506100a09036908401610255565b50505163d623472560e01b8152fd5b80fd5b5091829160203660031901126100fa57813567ffffffffffffffff81116100f5576001926100e291369101610255565b5050338352826020528220828155015580f35b505050fd5b5050fd5b50903461013f57602036600319011261013f579081906001600160a01b03610124610288565b16815280602052206001815491015482519182526020820152f35b5080fd5b50600319906060368301126100af5783359167ffffffffffffffff831161013f576101609083360301126100af5750602092610183916024359101610345565b9051908152f35b50346100af57816003193601126100af576024359067ffffffffffffffff82116100af57506020926101c26101839236908301610255565b91356103dc565b90508284602036600319011261024d57803567ffffffffffffffff81116102515782916101f891369101610255565b908093918101031261024d578160207f09b72addb8ad094c9a8a8a968606cc44820134a10b0c58144a18cce1b43e2b20933591013590338652856020528160018488208381550155845260208401523392a280f35b8380fd5b8480fd5b9181601f840112156102835782359167ffffffffffffffff8311610283576020838186019501011161028357565b600080fd5b600435906001600160a01b038216820361028357565b6040810190811067ffffffffffffffff8211176102ba57604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102ba57604052565b67ffffffffffffffff81116102ba57601f01601f191660200190565b92919261031a826102f2565b9161032860405193846102d0565b829481845281830111610283578281602093846000960137010152565b80356001600160a01b03811692908390036102835760009283528260205260408320916001604051936103778561029e565b805485520154602084015261014081013590601e1981360301821215610251570180359067ffffffffffffffff821161025157602001908036038213610251576103ce9392916103c891369161030e565b916104d4565b156103d95750600190565b90565b6103c861041493923360005260006020526040600020936001604051956104028761029e565b8054875201546020860152369161030e565b61041d57600190565b600090565b60005b8381106104355750506000910152565b8181015183820152602001610425565b81601f8201121561028357805161045b816102f2565b9261046960405194856102d0565b81845260208284010111610283576103d99160208085019101610422565b906020916104a081518092818552858086019101610422565b601f01601f1916010190565b6000915b600283106104bd57505050565b6001908251815260208091019201920191906104b0565b909180519260209382019260a08386860195031261028357848301519267ffffffffffffffff9384811161028357858761051092840101610445565b93604082015190811161028357858761052b92840101610445565b9460608201519080609f84011215610283576040519261054a8461029e565b839060c08101928311610283579060808a9795989694939201905b82821061066157505050906105ed85966105f7936105bc976040519461058a8661029e565b805186520151898501526105d86040519a8b998a99630d5efec960e01b8b5261012060048c01526101248b0190610487565b600160f81b60248b01528981036003190160448b015290610487565b956064880152608487015260a48601906104ac565b60e48401906104ac565b0381735b73c5498c1e3b4dba84de0f1833c4a029d905195af49182156106555760009261062357505090565b81813d831161064e575b61063781836102d0565b8101031261013f57519081151582036100af575090565b503d61062d565b6040513d6000823e3d90fd5b815181528a97918201910161056556", + "nonce": "0x2554", + "accessList": [] + }, + "additionalContracts": [], + "isFixedGasLimit": false + } + ], + "receipts": [], + "libraries": [ + "src/utils/WebAuthnWrapper.sol:WebAuthnWrapper:0x5b73c5498c1e3b4dba84de0f1833c4a029d90519" + ], + "pending": [], + "returns": {}, + "timestamp": 1704722702, + "chain": 80001, + "multi": false, + "commit": "a611cec" +} \ No newline at end of file diff --git a/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722737.json b/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722737.json new file mode 100644 index 00000000..f3a73f41 --- /dev/null +++ b/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722737.json @@ -0,0 +1,55 @@ +{ + "transactions": [ + { + "hash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", + "transactionType": "CREATE", + "contractName": "WebAuthnWrapper", + "contractAddress": "0x9C4538396993166b7F7ec93552C8763d4742DEDB", + "function": null, + "arguments": null, + "transaction": { + "type": "0x02", + "from": "0x7caf754c934710d7c73bc453654552beca38223f", + "gas": "0x12e329", + "data": "0x6080806040523461001a576110449081610020823930815050f35b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c630d5efec91461002857600080fd5b6101203660031901126100c35767ffffffffffffffff6004358181116100c6576100569036906004016100ca565b90916024359360ff60f81b851685036100c3576044359182116100c3576100bf6100ad86868661008936600489016100ca565b610095939193366100fd565b9361009f3661010a565b956084359460643594610118565b60405190151581529081906020820190565b0390f35b80fd5b8280fd5b9181601f840112156100f85782359167ffffffffffffffff83116100f857602083818601950101116100f857565b600080fd5b9060a49160e4116100f857565b9060e491610124116100f857565b939291979695949094602098806101406101328989610258565b356001600160f81b03191690565b169060ff60f81b8091169116036102465760405189810192835291829003808352601f199261017b916101769060200182610293565b610f0f565b9061018682516102fa565b80518b82019286018337519020916101b560405191826101a98d8201809661032c565b03908101835282610293565b51902003610234578691600091856101d46101cf8261036d565b6102fa565b95858701376101e86040518093819361038e565b039060025afa1561022f5761020f600091869384845191830101526040519182809261032c565b039060025afa1561022f5761022c928201359135906000516103c4565b90565b61039c565b60405163ebab5d2960e01b8152600490fd5b604051637e49a3c960e11b8152600490fd5b90602010156102675760200190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102b557604052565b61027d565b67ffffffffffffffff81116102b557601f01601f191660200190565b604051906020820182811067ffffffffffffffff8211176102b55760405260008252565b90610304826102ba565b6103116040519182610293565b8281528092610322601f19916102ba565b0190602036910137565b9081519160005b838110610344575050016000815290565b8060208092840101518185015201610333565b634e487b7160e01b600052601160045260246000fd5b906020820180921161037b57565b610357565b906002820180921161037b57565b908092918237016000815290565b6040513d6000823e3d90fd5b9060008051602061100483398151915291820391821161037b57565b60209382359390928501359190841580156104aa575b80156104a2575b801561048a575b61047f576103f684826104c2565b1561047f5760405192868452868085015286604085015260608401527fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f6080840152600080516020611004833981519152958660a08501528360c0816005600019fa156100f8576104799386610473945181818909940991610583565b916103a8565b90081590565b505050505050600090565b506000805160206110048339815191528310156103e8565b5082156103e1565b506000805160206110048339815191528510156103da565b80158061057b575b8015610564575b801561054d575b61054657600160601b63ffffffff60c01b03199081907f5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b90829081807fffffffff00000001000000000000000000000000fffffffffffffffffffffffc830991818180090908089180091490565b5050600090565b50600160601b63ffffffff60c01b031982146104d8565b50600160601b63ffffffff60c01b031981146104d1565b5081156104ca565b60009260ff92849291801580610c67575b610c5b576105a28284610c6f565b9095861580610c53575b610c33575b82811c60028a60fe1c16015b15610c1957600183821c1660028a831c60011b160160018114610be0575b60028114610bcf575b600314610bc2575b600198600019919091019692959493928992915b8a896000191161066f575050505050505050505060405191606083015260208252602080830152602060408301526000805160206110248339815191526080830152600163ffffffff60601b0360601b19918260a082015260208160c0816005600019fa156100f85751900990565b90919293949596979899600163ffffffff60601b0360601b198960020998600160601b63ffffffff60c01b03198a800999600160601b63ffffffff60c01b03198b840990600160601b63ffffffff60c01b0319908c900993849390600160601b63ffffffff60c01b03199081908181850890600160601b63ffffffff60c01b031990810385080960030998600160601b63ffffffff60c01b03199085099e600160601b63ffffffff60c01b0319908d099b600160601b63ffffffff60c01b031991829182910960008051602061102483398151915209600160601b63ffffffff60c01b03198a80090897600160601b63ffffffff60c01b031991829081038a08900992600160601b63ffffffff60c01b03199184918391900908918a8c1c600116848d1c60011b6002160115610ba35760018c600286838f841c16921c831b160114610b6c575b838c8c6002600182841c168185851c60011b160114610b59575b6003926001600292841c16921c60011b160114610b50575b8915610b3d57600160601b63ffffffff60c01b031990839082908f90090890600160601b63ffffffff60c01b0319908782039082908c900908988115610909575b600160601b63ffffffff60c01b031990818b800990099b600160601b63ffffffff60c01b031990818b8181800909900995600160601b63ffffffff60c01b031990818b80099009600160601b63ffffffff60c01b0319808260008051602061102483398151915209600160601b63ffffffff60c01b0319808d8181800909600160601b63ffffffff60c01b031990810390868009080899600160601b63ffffffff60c01b031993849182908181800909900991600160601b63ffffffff60c01b03199182908c82039008090896985b600019019796959493929190610600565b8961082957959b9a9850600160601b63ffffffff60c01b0319905080808360008051602061102483398151915209600160601b63ffffffff60c01b03198460008051602061102483398151915209098c0999600160601b63ffffffff60c01b0319808781038e08600160601b63ffffffff60c01b0319888f0809600160601b63ffffffff60c01b03199060030990600160601b63ffffffff60c01b0319908180808660008051602061102483398151915209600160601b63ffffffff60c01b0319876000805160206110248339815191520909600160601b63ffffffff60c01b03198660008051602061102483398151915209090995600160601b63ffffffff60c01b03199081808560008051602061102483398151915209600160601b63ffffffff60c01b0319866000805160206110248339815191520909099b600160601b63ffffffff60c01b0319908190819081808760008051602061102483398151915209600160601b63ffffffff60c01b0319886000805160206110248339815191520909900960008051602061102483398151915209600160601b63ffffffff60c01b0319838009089a600160601b63ffffffff60c01b03199283908180808360008051602061102483398151915209600160601b63ffffffff60c01b0319846000805160206110248339815191520909600160601b63ffffffff60c01b03198360008051602061102483398151915209090991600160601b63ffffffff60c01b03199182908e82039008900908966108f8565b60019c50909a9098508b955090506108f8565b505082846107e8565b508a93508992508591508d90508c6107d0565b5050600080516020610fe48339815191527f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f56107b6565b50979a9499600160601b63ffffffff60c01b03199190910397506108f8565b94509550849580946105ec565b9550965083966003849690506105e4565b600080516020610fe483398151915298507f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f596506105db565b60001901600160028185841c16918b841c901b16016105bd565b9790916000805160206110048339815191529182039008906000976105b1565b5081156105ac565b50505050505050600090565b508615610594565b7f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f59291600080516020610fe4833981519152918115610dc75780831480610dbe575b15610da75750600160601b63ffffffff60c01b03199190508184600209918083800992818080808781818909950995817fffffffff00000001000000000000000000000000fffffffffffffffffffffffe816001840892080960030981808080866000805160206110248339815191520981858009089981600181818b099a099709810393898203900890090893915b60405190602082526020808301526020604083015260608201526000805160206110248339815191526080820152600163ffffffff60601b0360601b19928360a083015260208260c0816005600019fa156100f857838080935180950980099009930990565b909150610db5929350610dcd565b91939291610d41565b50818514610cb1565b50509190565b60019283927f94e82e0c1ed3bdb90743191a9c5bbf0d88fc827fd214cc5f0b5ec6ba27673d69600163ffffffff60601b0360601b198095818094817fb01cbd1c01e58065711814b583f061e9d431cca994cea1313449bf97c840ae0a9a8b920908950908928080808087800996870994818088600080516020610fe483398151915209918180808560008051602061102483398151915209818b810381868009080893818a869d0994820390080908946001099260010990565b604051906060820182811067ffffffffffffffff8211176102b557604052604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b600281901b91906001600160fe1b0381160361037b57565b805115610fda57610f1e610e87565b610f3d6101cf610f38610f318551610380565b6003900490565b610ef7565b9160208301918182518301915b828210610f8857505050600390510680600114610f7e57600214610f75575b819003601f1901815290565b60001901610f69565b5060011901610f69565b9091936004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c1688010151600286015316850101519082015301939190610f4a565b5061022c6102d656fe6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551ffffffff00000001000000000000000000000000fffffffffffffffffffffffd", + "nonce": "0x2554", + "accessList": [] + }, + "additionalContracts": [], + "isFixedGasLimit": false + }, + { + "hash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", + "transactionType": "CREATE2", + "contractName": "WebAuthnValidator", + "contractAddress": "0x52F06b3E336198BC55f981B10de94B5713f9aE1a", + "function": null, + "arguments": null, + "transaction": { + "type": "0x02", + "from": "0x7caf754c934710d7c73bc453654552beca38223f", + "to": "0x4e59b44847b379578588920ca78fbf26c0b4956c", + "gas": "0x92893", + "value": "0x0", + "data": "0x00000000000000000000000000000000000000000000000000000000000000006080806040523461001657610671908161001c8239f35b600080fdfe608060408181526004918236101561001657600080fd5b600090813560e01c9081630c959556146101c957508063333daf921461018a5780633a871cdd14610143578063857cdbb8146100fe5780638fc925aa146100b257639ea9bd591461006657600080fd5b346100af57816003193601126100af5761007e610288565b506024359067ffffffffffffffff82116100af57506100a09036908401610255565b50505163d623472560e01b8152fd5b80fd5b5091829160203660031901126100fa57813567ffffffffffffffff81116100f5576001926100e291369101610255565b5050338352826020528220828155015580f35b505050fd5b5050fd5b50903461013f57602036600319011261013f579081906001600160a01b03610124610288565b16815280602052206001815491015482519182526020820152f35b5080fd5b50600319906060368301126100af5783359167ffffffffffffffff831161013f576101609083360301126100af5750602092610183916024359101610345565b9051908152f35b50346100af57816003193601126100af576024359067ffffffffffffffff82116100af57506020926101c26101839236908301610255565b91356103dc565b90508284602036600319011261024d57803567ffffffffffffffff81116102515782916101f891369101610255565b908093918101031261024d578160207f09b72addb8ad094c9a8a8a968606cc44820134a10b0c58144a18cce1b43e2b20933591013590338652856020528160018488208381550155845260208401523392a280f35b8380fd5b8480fd5b9181601f840112156102835782359167ffffffffffffffff8311610283576020838186019501011161028357565b600080fd5b600435906001600160a01b038216820361028357565b6040810190811067ffffffffffffffff8211176102ba57604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102ba57604052565b67ffffffffffffffff81116102ba57601f01601f191660200190565b92919261031a826102f2565b9161032860405193846102d0565b829481845281830111610283578281602093846000960137010152565b80356001600160a01b03811692908390036102835760009283528260205260408320916001604051936103778561029e565b805485520154602084015261014081013590601e1981360301821215610251570180359067ffffffffffffffff821161025157602001908036038213610251576103ce9392916103c891369161030e565b916104d4565b156103d95750600190565b90565b6103c861041493923360005260006020526040600020936001604051956104028761029e565b8054875201546020860152369161030e565b61041d57600190565b600090565b60005b8381106104355750506000910152565b8181015183820152602001610425565b81601f8201121561028357805161045b816102f2565b9261046960405194856102d0565b81845260208284010111610283576103d99160208085019101610422565b906020916104a081518092818552858086019101610422565b601f01601f1916010190565b6000915b600283106104bd57505050565b6001908251815260208091019201920191906104b0565b909180519260209382019260a08386860195031261028357848301519267ffffffffffffffff9384811161028357858761051092840101610445565b93604082015190811161028357858761052b92840101610445565b9460608201519080609f84011215610283576040519261054a8461029e565b839060c08101928311610283579060808a9795989694939201905b82821061066157505050906105ed85966105f7936105bc976040519461058a8661029e565b805186520151898501526105d86040519a8b998a99630d5efec960e01b8b5261012060048c01526101248b0190610487565b600160f81b60248b01528981036003190160448b015290610487565b956064880152608487015260a48601906104ac565b60e48401906104ac565b0381739c4538396993166b7f7ec93552c8763d4742dedb5af49182156106555760009261062357505090565b81813d831161064e575b61063781836102d0565b8101031261013f57519081151582036100af575090565b503d61062d565b6040513d6000823e3d90fd5b815181528a97918201910161056556", + "nonce": "0x2555", + "accessList": [] + }, + "additionalContracts": [], + "isFixedGasLimit": false + } + ], + "receipts": [], + "libraries": [ + "src/utils/WebAuthnWrapper.sol:WebAuthnWrapper:0x9c4538396993166b7f7ec93552c8763d4742dedb" + ], + "pending": [ + "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", + "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf" + ], + "returns": {}, + "timestamp": 1704722737, + "chain": 80001, + "multi": false, + "commit": "a611cec" +} \ No newline at end of file diff --git a/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722750.json b/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722750.json new file mode 100644 index 00000000..3469067a --- /dev/null +++ b/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722750.json @@ -0,0 +1,119 @@ +{ + "transactions": [ + { + "hash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", + "transactionType": "CREATE", + "contractName": "WebAuthnWrapper", + "contractAddress": "0x9C4538396993166b7F7ec93552C8763d4742DEDB", + "function": null, + "arguments": null, + "transaction": { + "type": "0x02", + "from": "0x7caf754c934710d7c73bc453654552beca38223f", + "gas": "0x12e329", + "data": "0x6080806040523461001a576110449081610020823930815050f35b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c630d5efec91461002857600080fd5b6101203660031901126100c35767ffffffffffffffff6004358181116100c6576100569036906004016100ca565b90916024359360ff60f81b851685036100c3576044359182116100c3576100bf6100ad86868661008936600489016100ca565b610095939193366100fd565b9361009f3661010a565b956084359460643594610118565b60405190151581529081906020820190565b0390f35b80fd5b8280fd5b9181601f840112156100f85782359167ffffffffffffffff83116100f857602083818601950101116100f857565b600080fd5b9060a49160e4116100f857565b9060e491610124116100f857565b939291979695949094602098806101406101328989610258565b356001600160f81b03191690565b169060ff60f81b8091169116036102465760405189810192835291829003808352601f199261017b916101769060200182610293565b610f0f565b9061018682516102fa565b80518b82019286018337519020916101b560405191826101a98d8201809661032c565b03908101835282610293565b51902003610234578691600091856101d46101cf8261036d565b6102fa565b95858701376101e86040518093819361038e565b039060025afa1561022f5761020f600091869384845191830101526040519182809261032c565b039060025afa1561022f5761022c928201359135906000516103c4565b90565b61039c565b60405163ebab5d2960e01b8152600490fd5b604051637e49a3c960e11b8152600490fd5b90602010156102675760200190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102b557604052565b61027d565b67ffffffffffffffff81116102b557601f01601f191660200190565b604051906020820182811067ffffffffffffffff8211176102b55760405260008252565b90610304826102ba565b6103116040519182610293565b8281528092610322601f19916102ba565b0190602036910137565b9081519160005b838110610344575050016000815290565b8060208092840101518185015201610333565b634e487b7160e01b600052601160045260246000fd5b906020820180921161037b57565b610357565b906002820180921161037b57565b908092918237016000815290565b6040513d6000823e3d90fd5b9060008051602061100483398151915291820391821161037b57565b60209382359390928501359190841580156104aa575b80156104a2575b801561048a575b61047f576103f684826104c2565b1561047f5760405192868452868085015286604085015260608401527fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f6080840152600080516020611004833981519152958660a08501528360c0816005600019fa156100f8576104799386610473945181818909940991610583565b916103a8565b90081590565b505050505050600090565b506000805160206110048339815191528310156103e8565b5082156103e1565b506000805160206110048339815191528510156103da565b80158061057b575b8015610564575b801561054d575b61054657600160601b63ffffffff60c01b03199081907f5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b90829081807fffffffff00000001000000000000000000000000fffffffffffffffffffffffc830991818180090908089180091490565b5050600090565b50600160601b63ffffffff60c01b031982146104d8565b50600160601b63ffffffff60c01b031981146104d1565b5081156104ca565b60009260ff92849291801580610c67575b610c5b576105a28284610c6f565b9095861580610c53575b610c33575b82811c60028a60fe1c16015b15610c1957600183821c1660028a831c60011b160160018114610be0575b60028114610bcf575b600314610bc2575b600198600019919091019692959493928992915b8a896000191161066f575050505050505050505060405191606083015260208252602080830152602060408301526000805160206110248339815191526080830152600163ffffffff60601b0360601b19918260a082015260208160c0816005600019fa156100f85751900990565b90919293949596979899600163ffffffff60601b0360601b198960020998600160601b63ffffffff60c01b03198a800999600160601b63ffffffff60c01b03198b840990600160601b63ffffffff60c01b0319908c900993849390600160601b63ffffffff60c01b03199081908181850890600160601b63ffffffff60c01b031990810385080960030998600160601b63ffffffff60c01b03199085099e600160601b63ffffffff60c01b0319908d099b600160601b63ffffffff60c01b031991829182910960008051602061102483398151915209600160601b63ffffffff60c01b03198a80090897600160601b63ffffffff60c01b031991829081038a08900992600160601b63ffffffff60c01b03199184918391900908918a8c1c600116848d1c60011b6002160115610ba35760018c600286838f841c16921c831b160114610b6c575b838c8c6002600182841c168185851c60011b160114610b59575b6003926001600292841c16921c60011b160114610b50575b8915610b3d57600160601b63ffffffff60c01b031990839082908f90090890600160601b63ffffffff60c01b0319908782039082908c900908988115610909575b600160601b63ffffffff60c01b031990818b800990099b600160601b63ffffffff60c01b031990818b8181800909900995600160601b63ffffffff60c01b031990818b80099009600160601b63ffffffff60c01b0319808260008051602061102483398151915209600160601b63ffffffff60c01b0319808d8181800909600160601b63ffffffff60c01b031990810390868009080899600160601b63ffffffff60c01b031993849182908181800909900991600160601b63ffffffff60c01b03199182908c82039008090896985b600019019796959493929190610600565b8961082957959b9a9850600160601b63ffffffff60c01b0319905080808360008051602061102483398151915209600160601b63ffffffff60c01b03198460008051602061102483398151915209098c0999600160601b63ffffffff60c01b0319808781038e08600160601b63ffffffff60c01b0319888f0809600160601b63ffffffff60c01b03199060030990600160601b63ffffffff60c01b0319908180808660008051602061102483398151915209600160601b63ffffffff60c01b0319876000805160206110248339815191520909600160601b63ffffffff60c01b03198660008051602061102483398151915209090995600160601b63ffffffff60c01b03199081808560008051602061102483398151915209600160601b63ffffffff60c01b0319866000805160206110248339815191520909099b600160601b63ffffffff60c01b0319908190819081808760008051602061102483398151915209600160601b63ffffffff60c01b0319886000805160206110248339815191520909900960008051602061102483398151915209600160601b63ffffffff60c01b0319838009089a600160601b63ffffffff60c01b03199283908180808360008051602061102483398151915209600160601b63ffffffff60c01b0319846000805160206110248339815191520909600160601b63ffffffff60c01b03198360008051602061102483398151915209090991600160601b63ffffffff60c01b03199182908e82039008900908966108f8565b60019c50909a9098508b955090506108f8565b505082846107e8565b508a93508992508591508d90508c6107d0565b5050600080516020610fe48339815191527f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f56107b6565b50979a9499600160601b63ffffffff60c01b03199190910397506108f8565b94509550849580946105ec565b9550965083966003849690506105e4565b600080516020610fe483398151915298507f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f596506105db565b60001901600160028185841c16918b841c901b16016105bd565b9790916000805160206110048339815191529182039008906000976105b1565b5081156105ac565b50505050505050600090565b508615610594565b7f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f59291600080516020610fe4833981519152918115610dc75780831480610dbe575b15610da75750600160601b63ffffffff60c01b03199190508184600209918083800992818080808781818909950995817fffffffff00000001000000000000000000000000fffffffffffffffffffffffe816001840892080960030981808080866000805160206110248339815191520981858009089981600181818b099a099709810393898203900890090893915b60405190602082526020808301526020604083015260608201526000805160206110248339815191526080820152600163ffffffff60601b0360601b19928360a083015260208260c0816005600019fa156100f857838080935180950980099009930990565b909150610db5929350610dcd565b91939291610d41565b50818514610cb1565b50509190565b60019283927f94e82e0c1ed3bdb90743191a9c5bbf0d88fc827fd214cc5f0b5ec6ba27673d69600163ffffffff60601b0360601b198095818094817fb01cbd1c01e58065711814b583f061e9d431cca994cea1313449bf97c840ae0a9a8b920908950908928080808087800996870994818088600080516020610fe483398151915209918180808560008051602061102483398151915209818b810381868009080893818a869d0994820390080908946001099260010990565b604051906060820182811067ffffffffffffffff8211176102b557604052604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b600281901b91906001600160fe1b0381160361037b57565b805115610fda57610f1e610e87565b610f3d6101cf610f38610f318551610380565b6003900490565b610ef7565b9160208301918182518301915b828210610f8857505050600390510680600114610f7e57600214610f75575b819003601f1901815290565b60001901610f69565b5060011901610f69565b9091936004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c1688010151600286015316850101519082015301939190610f4a565b5061022c6102d656fe6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551ffffffff00000001000000000000000000000000fffffffffffffffffffffffd", + "nonce": "0x2554", + "accessList": [] + }, + "additionalContracts": [], + "isFixedGasLimit": false + }, + { + "hash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", + "transactionType": "CREATE2", + "contractName": "WebAuthnValidator", + "contractAddress": "0x52F06b3E336198BC55f981B10de94B5713f9aE1a", + "function": null, + "arguments": null, + "transaction": { + "type": "0x02", + "from": "0x7caf754c934710d7c73bc453654552beca38223f", + "to": "0x4e59b44847b379578588920ca78fbf26c0b4956c", + "gas": "0x92893", + "value": "0x0", + "data": "0x00000000000000000000000000000000000000000000000000000000000000006080806040523461001657610671908161001c8239f35b600080fdfe608060408181526004918236101561001657600080fd5b600090813560e01c9081630c959556146101c957508063333daf921461018a5780633a871cdd14610143578063857cdbb8146100fe5780638fc925aa146100b257639ea9bd591461006657600080fd5b346100af57816003193601126100af5761007e610288565b506024359067ffffffffffffffff82116100af57506100a09036908401610255565b50505163d623472560e01b8152fd5b80fd5b5091829160203660031901126100fa57813567ffffffffffffffff81116100f5576001926100e291369101610255565b5050338352826020528220828155015580f35b505050fd5b5050fd5b50903461013f57602036600319011261013f579081906001600160a01b03610124610288565b16815280602052206001815491015482519182526020820152f35b5080fd5b50600319906060368301126100af5783359167ffffffffffffffff831161013f576101609083360301126100af5750602092610183916024359101610345565b9051908152f35b50346100af57816003193601126100af576024359067ffffffffffffffff82116100af57506020926101c26101839236908301610255565b91356103dc565b90508284602036600319011261024d57803567ffffffffffffffff81116102515782916101f891369101610255565b908093918101031261024d578160207f09b72addb8ad094c9a8a8a968606cc44820134a10b0c58144a18cce1b43e2b20933591013590338652856020528160018488208381550155845260208401523392a280f35b8380fd5b8480fd5b9181601f840112156102835782359167ffffffffffffffff8311610283576020838186019501011161028357565b600080fd5b600435906001600160a01b038216820361028357565b6040810190811067ffffffffffffffff8211176102ba57604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102ba57604052565b67ffffffffffffffff81116102ba57601f01601f191660200190565b92919261031a826102f2565b9161032860405193846102d0565b829481845281830111610283578281602093846000960137010152565b80356001600160a01b03811692908390036102835760009283528260205260408320916001604051936103778561029e565b805485520154602084015261014081013590601e1981360301821215610251570180359067ffffffffffffffff821161025157602001908036038213610251576103ce9392916103c891369161030e565b916104d4565b156103d95750600190565b90565b6103c861041493923360005260006020526040600020936001604051956104028761029e565b8054875201546020860152369161030e565b61041d57600190565b600090565b60005b8381106104355750506000910152565b8181015183820152602001610425565b81601f8201121561028357805161045b816102f2565b9261046960405194856102d0565b81845260208284010111610283576103d99160208085019101610422565b906020916104a081518092818552858086019101610422565b601f01601f1916010190565b6000915b600283106104bd57505050565b6001908251815260208091019201920191906104b0565b909180519260209382019260a08386860195031261028357848301519267ffffffffffffffff9384811161028357858761051092840101610445565b93604082015190811161028357858761052b92840101610445565b9460608201519080609f84011215610283576040519261054a8461029e565b839060c08101928311610283579060808a9795989694939201905b82821061066157505050906105ed85966105f7936105bc976040519461058a8661029e565b805186520151898501526105d86040519a8b998a99630d5efec960e01b8b5261012060048c01526101248b0190610487565b600160f81b60248b01528981036003190160448b015290610487565b956064880152608487015260a48601906104ac565b60e48401906104ac565b0381739c4538396993166b7f7ec93552c8763d4742dedb5af49182156106555760009261062357505090565b81813d831161064e575b61063781836102d0565b8101031261013f57519081151582036100af575090565b503d61062d565b6040513d6000823e3d90fd5b815181528a97918201910161056556", + "nonce": "0x2555", + "accessList": [] + }, + "additionalContracts": [], + "isFixedGasLimit": false + } + ], + "receipts": [ + { + "transactionHash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", + "transactionIndex": "0x0", + "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", + "blockNumber": "0x2a7ac87", + "from": "0x7caF754C934710D7C73bc453654552BEcA38223F", + "to": null, + "cumulativeGasUsed": "0xe8863", + "gasUsed": "0xe8863", + "contractAddress": "0x9C4538396993166b7F7ec93552C8763d4742DEDB", + "logs": [ + { + "address": "0x0000000000000000000000000000000000001010", + "topics": [ + "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", + "0x0000000000000000000000000000000000000000000000000000000000001010", + "0x0000000000000000000000007caf754c934710d7c73bc453654552beca38223f", + "0x0000000000000000000000005082f249cdb2f2c1ee035e4f423c46ea2dab3ab1" + ], + "data": "0x00000000000000000000000000000000000000000000000000658299dd2b8400000000000000000000000000000000000000000000000006bfce90352866ec930000000000000000000000000000000000000000000005083ff6eb3d8b290556000000000000000000000000000000000000000000000006bf690d9b4b3b6893000000000000000000000000000000000000000000000508405c6dd768548956", + "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", + "blockNumber": "0x2a7ac87", + "transactionHash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", + "transactionIndex": "0x0", + "logIndex": "0x0", + "removed": false + } + ], + "status": "0x1", + "logsBloom": "0x00000000000000000000000000000000000200000000000000000000020000000000000002000000000000000000000000008000000000000000000000000000000000000000000000000000000000800000000000000000000100000000000000000000000000000000000000000002000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000008000000000000000004000000000000000000001000000000000000000000000000000100000000000000000000000000080000000000000000000000000000000000000000000100000", + "type": "0x2", + "effectiveGasPrice": "0x6fc23ac11" + }, + { + "transactionHash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", + "transactionIndex": "0x1", + "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", + "blockNumber": "0x2a7ac87", + "from": "0x7caF754C934710D7C73bc453654552BEcA38223F", + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "cumulativeGasUsed": "0x14cbee", + "gasUsed": "0x6438b", + "contractAddress": null, + "logs": [ + { + "address": "0x0000000000000000000000000000000000001010", + "topics": [ + "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", + "0x0000000000000000000000000000000000000000000000000000000000001010", + "0x0000000000000000000000007caf754c934710d7c73bc453654552beca38223f", + "0x0000000000000000000000005082f249cdb2f2c1ee035e4f423c46ea2dab3ab1" + ], + "data": "0x000000000000000000000000000000000000000000000000002bc09e45626400000000000000000000000000000000000000000000000006bf690d9b4a445a00000000000000000000000000000000000000000000000508405c6dd768548956000000000000000000000000000000000000000000000006bf3d4cfd04e1f60000000000000000000000000000000000000000000000050840882e75adb6ed56", + "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", + "blockNumber": "0x2a7ac87", + "transactionHash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", + "transactionIndex": "0x1", + "logIndex": "0x1", + "removed": false + } + ], + "status": "0x1", + "logsBloom": "0x00000000000000000000000000000000000200000000000000000000020000000000000002000000000000000000000000008000000000000000000000000000000000000000000000000000000000800000000000000000000100000000000000000000000000000000000000000002000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000008000000000000000004000000000000000000001000000000000000000000000000000100000000000000000000000000080000000000000000000000000000000000000000000100000", + "type": "0x2", + "effectiveGasPrice": "0x6fc23ac11" + } + ], + "libraries": [ + "src/utils/WebAuthnWrapper.sol:WebAuthnWrapper:0x9c4538396993166b7f7ec93552c8763d4742dedb" + ], + "pending": [], + "returns": {}, + "timestamp": 1704722750, + "chain": 80001, + "multi": false, + "commit": "a611cec" +} \ No newline at end of file diff --git a/broadcast/DeployWebAuthnValidator.s.sol/80001/run-latest.json b/broadcast/DeployWebAuthnValidator.s.sol/80001/run-latest.json new file mode 100644 index 00000000..3469067a --- /dev/null +++ b/broadcast/DeployWebAuthnValidator.s.sol/80001/run-latest.json @@ -0,0 +1,119 @@ +{ + "transactions": [ + { + "hash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", + "transactionType": "CREATE", + "contractName": "WebAuthnWrapper", + "contractAddress": "0x9C4538396993166b7F7ec93552C8763d4742DEDB", + "function": null, + "arguments": null, + "transaction": { + "type": "0x02", + "from": "0x7caf754c934710d7c73bc453654552beca38223f", + "gas": "0x12e329", + "data": "0x6080806040523461001a576110449081610020823930815050f35b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c630d5efec91461002857600080fd5b6101203660031901126100c35767ffffffffffffffff6004358181116100c6576100569036906004016100ca565b90916024359360ff60f81b851685036100c3576044359182116100c3576100bf6100ad86868661008936600489016100ca565b610095939193366100fd565b9361009f3661010a565b956084359460643594610118565b60405190151581529081906020820190565b0390f35b80fd5b8280fd5b9181601f840112156100f85782359167ffffffffffffffff83116100f857602083818601950101116100f857565b600080fd5b9060a49160e4116100f857565b9060e491610124116100f857565b939291979695949094602098806101406101328989610258565b356001600160f81b03191690565b169060ff60f81b8091169116036102465760405189810192835291829003808352601f199261017b916101769060200182610293565b610f0f565b9061018682516102fa565b80518b82019286018337519020916101b560405191826101a98d8201809661032c565b03908101835282610293565b51902003610234578691600091856101d46101cf8261036d565b6102fa565b95858701376101e86040518093819361038e565b039060025afa1561022f5761020f600091869384845191830101526040519182809261032c565b039060025afa1561022f5761022c928201359135906000516103c4565b90565b61039c565b60405163ebab5d2960e01b8152600490fd5b604051637e49a3c960e11b8152600490fd5b90602010156102675760200190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102b557604052565b61027d565b67ffffffffffffffff81116102b557601f01601f191660200190565b604051906020820182811067ffffffffffffffff8211176102b55760405260008252565b90610304826102ba565b6103116040519182610293565b8281528092610322601f19916102ba565b0190602036910137565b9081519160005b838110610344575050016000815290565b8060208092840101518185015201610333565b634e487b7160e01b600052601160045260246000fd5b906020820180921161037b57565b610357565b906002820180921161037b57565b908092918237016000815290565b6040513d6000823e3d90fd5b9060008051602061100483398151915291820391821161037b57565b60209382359390928501359190841580156104aa575b80156104a2575b801561048a575b61047f576103f684826104c2565b1561047f5760405192868452868085015286604085015260608401527fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f6080840152600080516020611004833981519152958660a08501528360c0816005600019fa156100f8576104799386610473945181818909940991610583565b916103a8565b90081590565b505050505050600090565b506000805160206110048339815191528310156103e8565b5082156103e1565b506000805160206110048339815191528510156103da565b80158061057b575b8015610564575b801561054d575b61054657600160601b63ffffffff60c01b03199081907f5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b90829081807fffffffff00000001000000000000000000000000fffffffffffffffffffffffc830991818180090908089180091490565b5050600090565b50600160601b63ffffffff60c01b031982146104d8565b50600160601b63ffffffff60c01b031981146104d1565b5081156104ca565b60009260ff92849291801580610c67575b610c5b576105a28284610c6f565b9095861580610c53575b610c33575b82811c60028a60fe1c16015b15610c1957600183821c1660028a831c60011b160160018114610be0575b60028114610bcf575b600314610bc2575b600198600019919091019692959493928992915b8a896000191161066f575050505050505050505060405191606083015260208252602080830152602060408301526000805160206110248339815191526080830152600163ffffffff60601b0360601b19918260a082015260208160c0816005600019fa156100f85751900990565b90919293949596979899600163ffffffff60601b0360601b198960020998600160601b63ffffffff60c01b03198a800999600160601b63ffffffff60c01b03198b840990600160601b63ffffffff60c01b0319908c900993849390600160601b63ffffffff60c01b03199081908181850890600160601b63ffffffff60c01b031990810385080960030998600160601b63ffffffff60c01b03199085099e600160601b63ffffffff60c01b0319908d099b600160601b63ffffffff60c01b031991829182910960008051602061102483398151915209600160601b63ffffffff60c01b03198a80090897600160601b63ffffffff60c01b031991829081038a08900992600160601b63ffffffff60c01b03199184918391900908918a8c1c600116848d1c60011b6002160115610ba35760018c600286838f841c16921c831b160114610b6c575b838c8c6002600182841c168185851c60011b160114610b59575b6003926001600292841c16921c60011b160114610b50575b8915610b3d57600160601b63ffffffff60c01b031990839082908f90090890600160601b63ffffffff60c01b0319908782039082908c900908988115610909575b600160601b63ffffffff60c01b031990818b800990099b600160601b63ffffffff60c01b031990818b8181800909900995600160601b63ffffffff60c01b031990818b80099009600160601b63ffffffff60c01b0319808260008051602061102483398151915209600160601b63ffffffff60c01b0319808d8181800909600160601b63ffffffff60c01b031990810390868009080899600160601b63ffffffff60c01b031993849182908181800909900991600160601b63ffffffff60c01b03199182908c82039008090896985b600019019796959493929190610600565b8961082957959b9a9850600160601b63ffffffff60c01b0319905080808360008051602061102483398151915209600160601b63ffffffff60c01b03198460008051602061102483398151915209098c0999600160601b63ffffffff60c01b0319808781038e08600160601b63ffffffff60c01b0319888f0809600160601b63ffffffff60c01b03199060030990600160601b63ffffffff60c01b0319908180808660008051602061102483398151915209600160601b63ffffffff60c01b0319876000805160206110248339815191520909600160601b63ffffffff60c01b03198660008051602061102483398151915209090995600160601b63ffffffff60c01b03199081808560008051602061102483398151915209600160601b63ffffffff60c01b0319866000805160206110248339815191520909099b600160601b63ffffffff60c01b0319908190819081808760008051602061102483398151915209600160601b63ffffffff60c01b0319886000805160206110248339815191520909900960008051602061102483398151915209600160601b63ffffffff60c01b0319838009089a600160601b63ffffffff60c01b03199283908180808360008051602061102483398151915209600160601b63ffffffff60c01b0319846000805160206110248339815191520909600160601b63ffffffff60c01b03198360008051602061102483398151915209090991600160601b63ffffffff60c01b03199182908e82039008900908966108f8565b60019c50909a9098508b955090506108f8565b505082846107e8565b508a93508992508591508d90508c6107d0565b5050600080516020610fe48339815191527f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f56107b6565b50979a9499600160601b63ffffffff60c01b03199190910397506108f8565b94509550849580946105ec565b9550965083966003849690506105e4565b600080516020610fe483398151915298507f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f596506105db565b60001901600160028185841c16918b841c901b16016105bd565b9790916000805160206110048339815191529182039008906000976105b1565b5081156105ac565b50505050505050600090565b508615610594565b7f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f59291600080516020610fe4833981519152918115610dc75780831480610dbe575b15610da75750600160601b63ffffffff60c01b03199190508184600209918083800992818080808781818909950995817fffffffff00000001000000000000000000000000fffffffffffffffffffffffe816001840892080960030981808080866000805160206110248339815191520981858009089981600181818b099a099709810393898203900890090893915b60405190602082526020808301526020604083015260608201526000805160206110248339815191526080820152600163ffffffff60601b0360601b19928360a083015260208260c0816005600019fa156100f857838080935180950980099009930990565b909150610db5929350610dcd565b91939291610d41565b50818514610cb1565b50509190565b60019283927f94e82e0c1ed3bdb90743191a9c5bbf0d88fc827fd214cc5f0b5ec6ba27673d69600163ffffffff60601b0360601b198095818094817fb01cbd1c01e58065711814b583f061e9d431cca994cea1313449bf97c840ae0a9a8b920908950908928080808087800996870994818088600080516020610fe483398151915209918180808560008051602061102483398151915209818b810381868009080893818a869d0994820390080908946001099260010990565b604051906060820182811067ffffffffffffffff8211176102b557604052604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b600281901b91906001600160fe1b0381160361037b57565b805115610fda57610f1e610e87565b610f3d6101cf610f38610f318551610380565b6003900490565b610ef7565b9160208301918182518301915b828210610f8857505050600390510680600114610f7e57600214610f75575b819003601f1901815290565b60001901610f69565b5060011901610f69565b9091936004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c1688010151600286015316850101519082015301939190610f4a565b5061022c6102d656fe6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551ffffffff00000001000000000000000000000000fffffffffffffffffffffffd", + "nonce": "0x2554", + "accessList": [] + }, + "additionalContracts": [], + "isFixedGasLimit": false + }, + { + "hash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", + "transactionType": "CREATE2", + "contractName": "WebAuthnValidator", + "contractAddress": "0x52F06b3E336198BC55f981B10de94B5713f9aE1a", + "function": null, + "arguments": null, + "transaction": { + "type": "0x02", + "from": "0x7caf754c934710d7c73bc453654552beca38223f", + "to": "0x4e59b44847b379578588920ca78fbf26c0b4956c", + "gas": "0x92893", + "value": "0x0", + "data": "0x00000000000000000000000000000000000000000000000000000000000000006080806040523461001657610671908161001c8239f35b600080fdfe608060408181526004918236101561001657600080fd5b600090813560e01c9081630c959556146101c957508063333daf921461018a5780633a871cdd14610143578063857cdbb8146100fe5780638fc925aa146100b257639ea9bd591461006657600080fd5b346100af57816003193601126100af5761007e610288565b506024359067ffffffffffffffff82116100af57506100a09036908401610255565b50505163d623472560e01b8152fd5b80fd5b5091829160203660031901126100fa57813567ffffffffffffffff81116100f5576001926100e291369101610255565b5050338352826020528220828155015580f35b505050fd5b5050fd5b50903461013f57602036600319011261013f579081906001600160a01b03610124610288565b16815280602052206001815491015482519182526020820152f35b5080fd5b50600319906060368301126100af5783359167ffffffffffffffff831161013f576101609083360301126100af5750602092610183916024359101610345565b9051908152f35b50346100af57816003193601126100af576024359067ffffffffffffffff82116100af57506020926101c26101839236908301610255565b91356103dc565b90508284602036600319011261024d57803567ffffffffffffffff81116102515782916101f891369101610255565b908093918101031261024d578160207f09b72addb8ad094c9a8a8a968606cc44820134a10b0c58144a18cce1b43e2b20933591013590338652856020528160018488208381550155845260208401523392a280f35b8380fd5b8480fd5b9181601f840112156102835782359167ffffffffffffffff8311610283576020838186019501011161028357565b600080fd5b600435906001600160a01b038216820361028357565b6040810190811067ffffffffffffffff8211176102ba57604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102ba57604052565b67ffffffffffffffff81116102ba57601f01601f191660200190565b92919261031a826102f2565b9161032860405193846102d0565b829481845281830111610283578281602093846000960137010152565b80356001600160a01b03811692908390036102835760009283528260205260408320916001604051936103778561029e565b805485520154602084015261014081013590601e1981360301821215610251570180359067ffffffffffffffff821161025157602001908036038213610251576103ce9392916103c891369161030e565b916104d4565b156103d95750600190565b90565b6103c861041493923360005260006020526040600020936001604051956104028761029e565b8054875201546020860152369161030e565b61041d57600190565b600090565b60005b8381106104355750506000910152565b8181015183820152602001610425565b81601f8201121561028357805161045b816102f2565b9261046960405194856102d0565b81845260208284010111610283576103d99160208085019101610422565b906020916104a081518092818552858086019101610422565b601f01601f1916010190565b6000915b600283106104bd57505050565b6001908251815260208091019201920191906104b0565b909180519260209382019260a08386860195031261028357848301519267ffffffffffffffff9384811161028357858761051092840101610445565b93604082015190811161028357858761052b92840101610445565b9460608201519080609f84011215610283576040519261054a8461029e565b839060c08101928311610283579060808a9795989694939201905b82821061066157505050906105ed85966105f7936105bc976040519461058a8661029e565b805186520151898501526105d86040519a8b998a99630d5efec960e01b8b5261012060048c01526101248b0190610487565b600160f81b60248b01528981036003190160448b015290610487565b956064880152608487015260a48601906104ac565b60e48401906104ac565b0381739c4538396993166b7f7ec93552c8763d4742dedb5af49182156106555760009261062357505090565b81813d831161064e575b61063781836102d0565b8101031261013f57519081151582036100af575090565b503d61062d565b6040513d6000823e3d90fd5b815181528a97918201910161056556", + "nonce": "0x2555", + "accessList": [] + }, + "additionalContracts": [], + "isFixedGasLimit": false + } + ], + "receipts": [ + { + "transactionHash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", + "transactionIndex": "0x0", + "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", + "blockNumber": "0x2a7ac87", + "from": "0x7caF754C934710D7C73bc453654552BEcA38223F", + "to": null, + "cumulativeGasUsed": "0xe8863", + "gasUsed": "0xe8863", + "contractAddress": "0x9C4538396993166b7F7ec93552C8763d4742DEDB", + "logs": [ + { + "address": "0x0000000000000000000000000000000000001010", + "topics": [ + "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", + "0x0000000000000000000000000000000000000000000000000000000000001010", + "0x0000000000000000000000007caf754c934710d7c73bc453654552beca38223f", + "0x0000000000000000000000005082f249cdb2f2c1ee035e4f423c46ea2dab3ab1" + ], + "data": "0x00000000000000000000000000000000000000000000000000658299dd2b8400000000000000000000000000000000000000000000000006bfce90352866ec930000000000000000000000000000000000000000000005083ff6eb3d8b290556000000000000000000000000000000000000000000000006bf690d9b4b3b6893000000000000000000000000000000000000000000000508405c6dd768548956", + "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", + "blockNumber": "0x2a7ac87", + "transactionHash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", + "transactionIndex": "0x0", + "logIndex": "0x0", + "removed": false + } + ], + "status": "0x1", + "logsBloom": "0x00000000000000000000000000000000000200000000000000000000020000000000000002000000000000000000000000008000000000000000000000000000000000000000000000000000000000800000000000000000000100000000000000000000000000000000000000000002000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000008000000000000000004000000000000000000001000000000000000000000000000000100000000000000000000000000080000000000000000000000000000000000000000000100000", + "type": "0x2", + "effectiveGasPrice": "0x6fc23ac11" + }, + { + "transactionHash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", + "transactionIndex": "0x1", + "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", + "blockNumber": "0x2a7ac87", + "from": "0x7caF754C934710D7C73bc453654552BEcA38223F", + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "cumulativeGasUsed": "0x14cbee", + "gasUsed": "0x6438b", + "contractAddress": null, + "logs": [ + { + "address": "0x0000000000000000000000000000000000001010", + "topics": [ + "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", + "0x0000000000000000000000000000000000000000000000000000000000001010", + "0x0000000000000000000000007caf754c934710d7c73bc453654552beca38223f", + "0x0000000000000000000000005082f249cdb2f2c1ee035e4f423c46ea2dab3ab1" + ], + "data": "0x000000000000000000000000000000000000000000000000002bc09e45626400000000000000000000000000000000000000000000000006bf690d9b4a445a00000000000000000000000000000000000000000000000508405c6dd768548956000000000000000000000000000000000000000000000006bf3d4cfd04e1f60000000000000000000000000000000000000000000000050840882e75adb6ed56", + "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", + "blockNumber": "0x2a7ac87", + "transactionHash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", + "transactionIndex": "0x1", + "logIndex": "0x1", + "removed": false + } + ], + "status": "0x1", + "logsBloom": "0x00000000000000000000000000000000000200000000000000000000020000000000000002000000000000000000000000008000000000000000000000000000000000000000000000000000000000800000000000000000000100000000000000000000000000000000000000000002000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000008000000000000000004000000000000000000001000000000000000000000000000000100000000000000000000000000080000000000000000000000000000000000000000000100000", + "type": "0x2", + "effectiveGasPrice": "0x6fc23ac11" + } + ], + "libraries": [ + "src/utils/WebAuthnWrapper.sol:WebAuthnWrapper:0x9c4538396993166b7f7ec93552c8763d4742dedb" + ], + "pending": [], + "returns": {}, + "timestamp": 1704722750, + "chain": 80001, + "multi": false, + "commit": "a611cec" +} \ No newline at end of file diff --git a/scripts/DeployWebAuthnValidator.s.sol b/scripts/DeployWebAuthnValidator.s.sol new file mode 100644 index 00000000..e1f590b4 --- /dev/null +++ b/scripts/DeployWebAuthnValidator.s.sol @@ -0,0 +1,19 @@ +pragma solidity ^0.8.0; + +import "src/factory/KernelFactory.sol"; +import "src/validator/WebAuthnValidator.sol"; +import "forge-std/Script.sol"; +import "forge-std/console.sol"; +contract DeployWebAuthnValidator is Script { + + function run() public { + uint256 key = vm.envUint("DEPLOYER_PRIVATE_KEY"); + vm.startBroadcast(key); + + WebAuthnValidator validator = new WebAuthnValidator{salt:0}(); + console.log("validator address: %s", address(validator)); + + vm.stopBroadcast(); + } +} + From 0a94e6908d267be59711b8fe37e64b90939b1a72 Mon Sep 17 00:00:00 2001 From: KONFeature Date: Tue, 9 Jan 2024 19:09:07 +0100 Subject: [PATCH 03/12] =?UTF-8?q?=F0=9F=9A=A7=20Fix=20pre=20op=20estimatio?= =?UTF-8?q?n=20by=20removing=20early=20exit=20during=20webauthn=20msg=20fo?= =?UTF-8?q?rmat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/WebAuthnWrapper.sol | 73 +++++++++++++++++++++++++++-- src/validator/WebAuthnValidator.sol | 12 +++-- 2 files changed, 77 insertions(+), 8 deletions(-) diff --git a/src/utils/WebAuthnWrapper.sol b/src/utils/WebAuthnWrapper.sol index 58c03425..6ea11347 100644 --- a/src/utils/WebAuthnWrapper.sol +++ b/src/utils/WebAuthnWrapper.sol @@ -1,19 +1,26 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {FCL_WebAuthn} from "FreshCryptoLib/FCL_Webauthn.sol"; +import {FCL_ecdsa_utils} from "FreshCryptoLib/FCL_ecdsa_utils.sol"; +import {Base64Url} from "FreshCryptoLib/utils/Base64Url.sol"; /// @title WebAuthnWrapper +/// @author rdubois-crypto /// @author obatirou +/// @author KONFeature /// @notice A library used to verify ECDSA signatures over secp256r1 through /// EIP-1271 of Webauthn payloads. /// From https://github.com/cometh-game/p256-signer/blob/main/contracts/FCL/WrapperFCLWebAuthn.sol +/// And https://github.com/rdubois-crypto/FreshCryptoLib/blob/master/solidity/src/FCL_Webauthn.sol /// @dev This lib is only a wrapper around the FCL_WebAuthn library. /// It is meant to be used with 1271 signatures. /// The wrapping is necessary because the FCL_WebAuthn has only internal /// functions and use calldata. This makes it impossible to use it with /// isValidSignature that use memory. +/// It's also needed to prevent all the early exit, and so making it +/// impossible to have a precise gas estimation for the verification phase. library WebAuthnWrapper { + /// @dev Check the validity of a signature function checkSignature( bytes calldata authenticatorData, bytes1 authenticatorDataFlagMask, @@ -21,10 +28,68 @@ library WebAuthnWrapper { bytes32 clientChallenge, uint256 clientChallengeDataOffset, uint256[2] calldata rs, - uint256[2] calldata Q + uint256[2] calldata xy ) external view returns (bool) { - return FCL_WebAuthn.checkSignature( - authenticatorData, authenticatorDataFlagMask, clientData, clientChallenge, clientChallengeDataOffset, rs, Q + // Format the msg signed via the p256 curve + bytes32 message = formatWebAuthNChallenge( + authenticatorData, authenticatorDataFlagMask, clientData, clientChallenge, clientChallengeDataOffset, rs ); + + // Perform the verification + return FCL_ecdsa_utils.ecdsa_verify(message, rs, xy); + } + + /// @dev Format a web auth n message, return the challenge that has been signed by the user + function formatWebAuthNChallenge( + bytes calldata authenticatorData, + bytes1 authenticatorDataFlagMask, + bytes calldata clientData, + bytes32 clientChallenge, + uint256 clientChallengeDataOffset, + uint256[2] calldata // rs + ) internal pure returns (bytes32) { + // Let the caller check if User Presence (0x01) or User Verification (0x04) are set + { + if ((authenticatorData[32] & authenticatorDataFlagMask) != authenticatorDataFlagMask) { + // TODO: Cleanup that stuff until we are aable to generate offchain dummy sig that pass that verification + return 0; + } + // Verify that clientData commits to the expected client challenge + // Use the Base64Url encoding which omits padding characters to match WebAuthn Specification + string memory challengeEncoded = Base64Url.encode(abi.encodePacked(clientChallenge)); + bytes memory challengeExtracted = new bytes(bytes(challengeEncoded).length); + + assembly { + calldatacopy( + add(challengeExtracted, 32), + add(clientData.offset, clientChallengeDataOffset), + mload(challengeExtracted) + ) + } + + bytes32 moreData; //=keccak256(abi.encodePacked(challengeExtracted)); + assembly { + moreData := keccak256(add(challengeExtracted, 32), mload(challengeExtracted)) + } + + if (keccak256(abi.encodePacked(bytes(challengeEncoded))) != moreData) { + // TODO: Cleanup that stuff until we are aable to generate offchain dummy sig that pass that verification + return 0; + } + } //avoid stack full + + // Verify the signature over sha256(authenticatorData || sha256(clientData)) + bytes memory verifyData = new bytes(authenticatorData.length + 32); + + assembly { + calldatacopy(add(verifyData, 32), authenticatorData.offset, authenticatorData.length) + } + + bytes32 more = sha256(clientData); + assembly { + mstore(add(verifyData, add(authenticatorData.length, 32)), more) + } + + return sha256(verifyData); } } diff --git a/src/validator/WebAuthnValidator.sol b/src/validator/WebAuthnValidator.sol index be0ad71f..8228231f 100644 --- a/src/validator/WebAuthnValidator.sol +++ b/src/validator/WebAuthnValidator.sol @@ -55,7 +55,7 @@ contract WebAuthnValidator is IKernelValidator { WebAuthnValidatorStorage memory kernelValidatorStorage = webAuthnValidatorStorage[_userOp.sender]; // Perform a check against the direct userOpHash, if ok consider the user op as validated - if (!_checkSignature(kernelValidatorStorage, _userOpHash, _userOp.signature)) { + if (_checkSignature(kernelValidatorStorage, _userOpHash, _userOp.signature)) { return ValidationData.wrap(0); } @@ -88,13 +88,13 @@ contract WebAuthnValidator is IKernelValidator { WebAuthnValidatorStorage memory _kernelValidatorStorage, bytes32 _hash, bytes memory _signature - ) private view returns (bool) { + ) private view returns (bool isValid) { // Decode the signature (bytes memory authenticatorData, bytes memory clientData, uint256 challengeOffset, uint256[2] memory rs) = abi.decode(_signature, (bytes, bytes, uint256, uint256[2])); // Verify the signature - return WebAuthnWrapper.checkSignature( + try WebAuthnWrapper.checkSignature( authenticatorData, 0x01, clientData, @@ -102,7 +102,11 @@ contract WebAuthnValidator is IKernelValidator { challengeOffset, rs, [_kernelValidatorStorage.x, _kernelValidatorStorage.y] - ); + ) returns (bool _result) { + isValid = _result; + } catch { + isValid = false; + } } /// @dev Check if the caller is a valid signer, this don't apply to the WebAuthN validator, since it's using a public key From ba7156d2e2a907d9409810959747fac5694ff59c Mon Sep 17 00:00:00 2001 From: KONFeature Date: Fri, 19 Jan 2024 14:48:50 +0100 Subject: [PATCH 04/12] =?UTF-8?q?=E2=9C=85=20Add=20webauthn=20validator=20?= =?UTF-8?q?unit=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gas-snapshot | 339 +++++++++++++----- src/utils/WebAuthnWrapper.sol | 7 +- .../foundry/validator/WebAuthnValidator.t.sol | 288 +++++++++++++++ 3 files changed, 533 insertions(+), 101 deletions(-) create mode 100644 test/foundry/validator/WebAuthnValidator.t.sol diff --git a/.gas-snapshot b/.gas-snapshot index e41656f8..d0c974fc 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,17 +1,17 @@ KernelECDSATest:test_default_validator_disable() (gas: 0) -KernelECDSATest:test_default_validator_disable() (gas: 180311) +KernelECDSATest:test_default_validator_disable() (gas: 180620) KernelECDSATest:test_default_validator_enable() (gas: 0) -KernelECDSATest:test_default_validator_enable() (gas: 187800) -KernelECDSATest:test_disable_mode() (gas: 182795) -KernelECDSATest:test_disable_mode() (gas: 192079) +KernelECDSATest:test_default_validator_enable() (gas: 188112) +KernelECDSATest:test_disable_mode() (gas: 183122) +KernelECDSATest:test_disable_mode() (gas: 192700) KernelECDSATest:test_eip712() (gas: 15684) KernelECDSATest:test_eip712() (gas: 15684) -KernelECDSATest:test_enable_then_mode_1() (gas: 277994) -KernelECDSATest:test_enable_then_mode_1() (gas: 286106) -KernelECDSATest:test_external_call_batch_execute_fail() (gas: 23628) -KernelECDSATest:test_external_call_batch_execute_fail() (gas: 29534) -KernelECDSATest:test_external_call_batch_execute_success() (gas: 20629) -KernelECDSATest:test_external_call_batch_execute_success() (gas: 26536) +KernelECDSATest:test_enable_then_mode_1() (gas: 279619) +KernelECDSATest:test_enable_then_mode_1() (gas: 287374) +KernelECDSATest:test_external_call_batch_execute_fail() (gas: 23625) +KernelECDSATest:test_external_call_batch_execute_fail() (gas: 29531) +KernelECDSATest:test_external_call_batch_execute_success() (gas: 20626) +KernelECDSATest:test_external_call_batch_execute_success() (gas: 26533) KernelECDSATest:test_external_call_default() (gas: 23511) KernelECDSATest:test_external_call_default() (gas: 29338) KernelECDSATest:test_external_call_execute_delegatecall_fail() (gas: 22499) @@ -24,137 +24,282 @@ KernelECDSATest:test_external_call_execute_fail() (gas: 21968) KernelECDSATest:test_external_call_execute_fail() (gas: 27862) KernelECDSATest:test_external_call_execute_success() (gas: 20070) KernelECDSATest:test_external_call_execute_success() (gas: 25987) -KernelECDSATest:test_external_call_execution() (gas: 497819) -KernelECDSATest:test_external_call_execution() (gas: 510696) +KernelECDSATest:test_external_call_execution() (gas: 498421) +KernelECDSATest:test_external_call_execution() (gas: 511004) KernelECDSATest:test_fail_validate_not_activate() (gas: 0) -KernelECDSATest:test_fail_validate_not_activate() (gas: 303491) -KernelECDSATest:test_fail_validate_wrongsignature() (gas: 24904) -KernelECDSATest:test_fail_validate_wrongsignature() (gas: 34133) +KernelECDSATest:test_fail_validate_not_activate() (gas: 303494) +KernelECDSATest:test_fail_validate_wrongsignature() (gas: 25013) +KernelECDSATest:test_fail_validate_wrongsignature() (gas: 34351) KernelECDSATest:test_get_nonce() (gas: 25179) KernelECDSATest:test_get_nonce() (gas: 25201) KernelECDSATest:test_get_nonce(uint192) (runs: 1024, μ: 19842, ~: 19842) KernelECDSATest:test_get_nonce(uint192) (runs: 1024, μ: 19842, ~: 19842) KernelECDSATest:test_ignore() (gas: 868) -KernelECDSATest:test_initialize() (gas: 126784) +KernelECDSATest:test_initialize() (gas: 126488) KernelECDSATest:test_initialize() (gas: 154121) KernelECDSATest:test_initialize_twice() (gas: 18555) -KernelECDSATest:test_initialize_twice() (gas: 18698) -KernelECDSATest:test_mode_2() (gas: 243052) -KernelECDSATest:test_mode_2() (gas: 250243) -KernelECDSATest:test_revert_when_mode_disabled() (gas: 199003) -KernelECDSATest:test_revert_when_mode_disabled() (gas: 208287) -KernelECDSATest:test_set_default_validator() (gas: 417145) -KernelECDSATest:test_set_default_validator() (gas: 423335) -KernelECDSATest:test_set_execution() (gas: 458142) -KernelECDSATest:test_set_execution() (gas: 468303) +KernelECDSATest:test_initialize_twice() (gas: 18599) +KernelECDSATest:test_mode_2() (gas: 243908) +KernelECDSATest:test_mode_2() (gas: 251079) +KernelECDSATest:test_revert_when_mode_disabled() (gas: 200091) +KernelECDSATest:test_revert_when_mode_disabled() (gas: 209732) +KernelECDSATest:test_set_default_validator() (gas: 417758) +KernelECDSATest:test_set_default_validator() (gas: 423646) +KernelECDSATest:test_set_execution() (gas: 458753) +KernelECDSATest:test_set_execution() (gas: 468620) KernelECDSATest:test_should_emit_event_on_receive() (gas: 23220) KernelECDSATest:test_should_emit_event_on_receive() (gas: 23220) -KernelECDSATest:test_should_receive_erc1155() (gas: 701145) -KernelECDSATest:test_should_receive_erc1155() (gas: 701171) -KernelECDSATest:test_should_receive_erc1155_batch() (gas: 728411) -KernelECDSATest:test_should_receive_erc1155_batch() (gas: 728411) -KernelECDSATest:test_should_receive_erc721() (gas: 597680) -KernelECDSATest:test_should_receive_erc721() (gas: 597702) +KernelECDSATest:test_should_receive_erc1155() (gas: 700299) +KernelECDSATest:test_should_receive_erc1155() (gas: 700325) +KernelECDSATest:test_should_receive_erc1155_batch() (gas: 727496) +KernelECDSATest:test_should_receive_erc1155_batch() (gas: 727496) +KernelECDSATest:test_should_receive_erc721() (gas: 597474) +KernelECDSATest:test_should_receive_erc721() (gas: 597496) KernelECDSATest:test_should_return_address_if_deployed() (gas: 21970) KernelECDSATest:test_should_return_address_if_deployed() (gas: 21976) -KernelECDSATest:test_sudo() (gas: 170002) -KernelECDSATest:test_sudo() (gas: 179450) -KernelECDSATest:test_sudo_wrongSig() (gas: 102566) -KernelECDSATest:test_sudo_wrongSig() (gas: 115709) -KernelECDSATest:test_transfer_ownership() (gas: 178398) +KernelECDSATest:test_sudo() (gas: 170601) +KernelECDSATest:test_sudo() (gas: 179755) +KernelECDSATest:test_sudo_wrongSig() (gas: 103132) +KernelECDSATest:test_sudo_wrongSig() (gas: 116321) +KernelECDSATest:test_transfer_ownership() (gas: 185003) KernelECDSATest:test_upgrade() (gas: 21292) KernelECDSATest:test_upgrade() (gas: 21292) -KernelECDSATest:test_validateUserOp_fail_invalid_mode() (gas: 26550) -KernelECDSATest:test_validateUserOp_fail_invalid_mode() (gas: 26550) -KernelECDSATest:test_validateUserOp_fail_not_entryPoint() (gas: 30591) -KernelECDSATest:test_validateUserOp_fail_not_entryPoint() (gas: 30634) -KernelECDSATest:test_validate_signature() (gas: 155714) -KernelECDSATest:test_validate_signature() (gas: 194502) -KernelHelperTest:testIntersect(uint48,uint48,uint48,uint48) (runs: 1024, μ: 871, ~: 869) -KillSwitchValidatorTest:test_default_validator_disable() (gas: 180432) -KillSwitchValidatorTest:test_default_validator_enable() (gas: 187921) -KillSwitchValidatorTest:test_disable_mode() (gas: 182916) +KernelECDSATest:test_validateUserOp_fail_invalid_mode() (gas: 26934) +KernelECDSATest:test_validateUserOp_fail_invalid_mode() (gas: 26997) +KernelECDSATest:test_validateUserOp_fail_not_entryPoint() (gas: 23364) +KernelECDSATest:test_validateUserOp_fail_not_entryPoint() (gas: 23427) +KernelECDSATest:test_validate_signature() (gas: 155636) +KernelECDSATest:test_validate_signature() (gas: 194938) +KernelECDSATypedTest:test_default_validator_disable() (gas: 185046) +KernelECDSATypedTest:test_default_validator_enable() (gas: 192011) +KernelECDSATypedTest:test_disable_mode() (gas: 187373) +KernelECDSATypedTest:test_eip712() (gas: 15684) +KernelECDSATypedTest:test_enable_then_mode_1() (gas: 291627) +KernelECDSATypedTest:test_external_call_batch_execute_fail() (gas: 29575) +KernelECDSATypedTest:test_external_call_batch_execute_success() (gas: 26577) +KernelECDSATypedTest:test_external_call_default() (gas: 29382) +KernelECDSATypedTest:test_external_call_execute_delegatecall_fail() (gas: 28425) +KernelECDSATypedTest:test_external_call_execute_delegatecall_option_fail() (gas: 26373) +KernelECDSATypedTest:test_external_call_execute_delegatecall_success() (gas: 25665) +KernelECDSATypedTest:test_external_call_execute_fail() (gas: 27906) +KernelECDSATypedTest:test_external_call_execute_success() (gas: 26031) +KernelECDSATypedTest:test_external_call_execution() (gas: 515344) +KernelECDSATypedTest:test_fail_validate_not_activate() (gas: 303494) +KernelECDSATypedTest:test_fail_validate_wrongsignature() (gas: 36953) +KernelECDSATypedTest:test_get_nonce() (gas: 25179) +KernelECDSATypedTest:test_get_nonce(uint192) (runs: 1024, μ: 19842, ~: 19842) +KernelECDSATypedTest:test_ignore() (gas: 868) +KernelECDSATypedTest:test_initialize() (gas: 153627) +KernelECDSATypedTest:test_initialize_twice() (gas: 18555) +KernelECDSATypedTest:test_mode_2() (gas: 253812) +KernelECDSATypedTest:test_revert_when_mode_disabled() (gas: 204271) +KernelECDSATypedTest:test_set_default_validator() (gas: 427897) +KernelECDSATypedTest:test_set_execution() (gas: 472872) +KernelECDSATypedTest:test_should_emit_event_on_receive() (gas: 23220) +KernelECDSATypedTest:test_should_receive_erc1155() (gas: 700299) +KernelECDSATypedTest:test_should_receive_erc1155_batch() (gas: 727496) +KernelECDSATypedTest:test_should_receive_erc721() (gas: 597496) +KernelECDSATypedTest:test_should_return_address_if_deployed() (gas: 21976) +KernelECDSATypedTest:test_sudo() (gas: 184006) +KernelECDSATypedTest:test_sudo_wrongSig() (gas: 116744) +KernelECDSATypedTest:test_upgrade() (gas: 21292) +KernelECDSATypedTest:test_validateUserOp_fail_invalid_mode() (gas: 26934) +KernelECDSATypedTest:test_validateUserOp_fail_not_entryPoint() (gas: 23364) +KernelECDSATypedTest:test_validate_signature() (gas: 191837) +KernelHelperTest:testIntersect(uint48,uint48,uint48,uint48) (runs: 1024, μ: 986, ~: 991) +KillSwitchValidatorTest:test_default_validator_disable() (gas: 180741) +KillSwitchValidatorTest:test_default_validator_enable() (gas: 188233) +KillSwitchValidatorTest:test_disable_mode() (gas: 183243) KillSwitchValidatorTest:test_eip712() (gas: 15820) -KillSwitchValidatorTest:test_enable_then_mode_1() (gas: 348586) -KillSwitchValidatorTest:test_external_call_batch_execute_fail() (gas: 29622) -KillSwitchValidatorTest:test_external_call_batch_execute_success() (gas: 26558) +KillSwitchValidatorTest:test_enable_then_mode_1() (gas: 349968) +KillSwitchValidatorTest:test_external_call_batch_execute_fail() (gas: 29619) +KillSwitchValidatorTest:test_external_call_batch_execute_success() (gas: 26555) KillSwitchValidatorTest:test_external_call_default() (gas: 29426) KillSwitchValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 28469) KillSwitchValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 26439) KillSwitchValidatorTest:test_external_call_execute_delegatecall_success() (gas: 25709) KillSwitchValidatorTest:test_external_call_execute_fail() (gas: 27906) KillSwitchValidatorTest:test_external_call_execute_success() (gas: 26075) -KillSwitchValidatorTest:test_external_call_execution() (gas: 510817) -KillSwitchValidatorTest:test_fail_validate_not_activate() (gas: 303601) -KillSwitchValidatorTest:test_fail_validate_wrongsignature() (gas: 34276) -KillSwitchValidatorTest:test_force_unblock() (gas: 391544) +KillSwitchValidatorTest:test_external_call_execution() (gas: 511125) +KillSwitchValidatorTest:test_fail_validate_not_activate() (gas: 303604) +KillSwitchValidatorTest:test_fail_validate_wrongsignature() (gas: 34494) +KillSwitchValidatorTest:test_force_unblock() (gas: 394736) KillSwitchValidatorTest:test_get_nonce() (gas: 25201) KillSwitchValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 19930, ~: 19930) KillSwitchValidatorTest:test_ignore() (gas: 956) KillSwitchValidatorTest:test_initialize() (gas: 154209) KillSwitchValidatorTest:test_initialize_twice() (gas: 18643) -KillSwitchValidatorTest:test_mode_2() (gas: 312761) -KillSwitchValidatorTest:test_revert_when_mode_disabled() (gas: 199157) -KillSwitchValidatorTest:test_set_default_validator() (gas: 423434) -KillSwitchValidatorTest:test_set_execution() (gas: 468424) +KillSwitchValidatorTest:test_mode_2() (gas: 313713) +KillSwitchValidatorTest:test_revert_when_mode_disabled() (gas: 200245) +KillSwitchValidatorTest:test_set_default_validator() (gas: 423745) +KillSwitchValidatorTest:test_set_execution() (gas: 468741) KillSwitchValidatorTest:test_should_emit_event_on_receive() (gas: 23330) KillSwitchValidatorTest:test_should_fail_with_not_implemented_isValidSignature() (gas: 9236) KillSwitchValidatorTest:test_should_fail_with_not_implemented_isValidSignature(bytes32,bytes) (runs: 1024, μ: 9601, ~: 9556) KillSwitchValidatorTest:test_should_fail_with_not_implemented_validCaller() (gas: 10157) KillSwitchValidatorTest:test_should_fail_with_not_implemented_validCaller(address,bytes) (runs: 1024, μ: 9749, ~: 9703) -KillSwitchValidatorTest:test_should_receive_erc1155() (gas: 701233) -KillSwitchValidatorTest:test_should_receive_erc1155_batch() (gas: 728499) -KillSwitchValidatorTest:test_should_receive_erc721() (gas: 597790) +KillSwitchValidatorTest:test_should_receive_erc1155() (gas: 700387) +KillSwitchValidatorTest:test_should_receive_erc1155_batch() (gas: 727584) +KillSwitchValidatorTest:test_should_receive_erc721() (gas: 597584) KillSwitchValidatorTest:test_should_return_address_if_deployed() (gas: 22086) -KillSwitchValidatorTest:test_sudo() (gas: 179549) -KillSwitchValidatorTest:test_sudo_wrongSig() (gas: 115830) +KillSwitchValidatorTest:test_sudo() (gas: 179854) +KillSwitchValidatorTest:test_sudo_wrongSig() (gas: 116442) KillSwitchValidatorTest:test_upgrade() (gas: 21314) -KillSwitchValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 26638) -KillSwitchValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 30708) -KillSwitchValidatorTest:test_validate_signature() (gas: 194579) -SessionKeyValidatorTest:test_default_validator_disable() (gas: 180311) -SessionKeyValidatorTest:test_default_validator_enable() (gas: 187800) -SessionKeyValidatorTest:test_disable_mode() (gas: 182795) +KillSwitchValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27022) +KillSwitchValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23391) +KillSwitchValidatorTest:test_validate_signature() (gas: 195015) +P256ValidatorTest:test_default_validator_disable() (gas: 876785) +P256ValidatorTest:test_default_validator_enable() (gas: 888633) +P256ValidatorTest:test_disable_mode() (gas: 886327) +P256ValidatorTest:test_eip712() (gas: 15887) +P256ValidatorTest:test_enable_then_mode_1() (gas: 1360868) +P256ValidatorTest:test_external_call_batch_execute_fail() (gas: 25023) +P256ValidatorTest:test_external_call_batch_execute_success() (gas: 0) +P256ValidatorTest:test_external_call_default() (gas: 0) +P256ValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 0) +P256ValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 21901) +P256ValidatorTest:test_external_call_execute_delegatecall_success() (gas: 0) +P256ValidatorTest:test_external_call_execute_fail() (gas: 21191) +P256ValidatorTest:test_external_call_execute_success() (gas: 0) +P256ValidatorTest:test_external_call_execution() (gas: 0) +P256ValidatorTest:test_fail_validate_not_activate() (gas: 304359) +P256ValidatorTest:test_fail_validate_wrongsignature() (gas: 744317) +P256ValidatorTest:test_get_nonce() (gas: 25621) +P256ValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 20090, ~: 20090) +P256ValidatorTest:test_initialize() (gas: 178621) +P256ValidatorTest:test_initialize_twice() (gas: 20756) +P256ValidatorTest:test_mode_2() (gas: 1303432) +P256ValidatorTest:test_revert_when_mode_disabled() (gas: 903399) +P256ValidatorTest:test_set_default_validator() (gas: 1117938) +P256ValidatorTest:test_set_execution() (gas: 1178075) +P256ValidatorTest:test_should_emit_event_on_receive() (gas: 23390) +P256ValidatorTest:test_should_receive_erc1155() (gas: 700421) +P256ValidatorTest:test_should_receive_erc1155_batch() (gas: 727681) +P256ValidatorTest:test_should_receive_erc721() (gas: 597618) +P256ValidatorTest:test_should_return_address_if_deployed() (gas: 24455) +P256ValidatorTest:test_sudo() (gas: 885393) +P256ValidatorTest:test_sudo_wrongSig() (gas: 819294) +P256ValidatorTest:test_upgrade() (gas: 21621) +P256ValidatorTest:test_utils(uint256,bytes32) (runs: 1024, μ: 1254189, ~: 1142801) +P256ValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27324) +P256ValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23656) +P256ValidatorTest:test_validate_signature() (gas: 1270000) +SessionKeyValidatorTest:test_default_validator_disable() (gas: 180670) +SessionKeyValidatorTest:test_default_validator_enable() (gas: 188140) +SessionKeyValidatorTest:test_disable_mode() (gas: 183150) SessionKeyValidatorTest:test_eip712() (gas: 15684) -SessionKeyValidatorTest:test_enable_then_mode_1() (gas: 286128) -SessionKeyValidatorTest:test_external_call_batch_execute_fail() (gas: 29534) -SessionKeyValidatorTest:test_external_call_batch_execute_success() (gas: 26536) -SessionKeyValidatorTest:test_external_call_default() (gas: 29338) +SessionKeyValidatorTest:test_enable_then_mode_1() (gas: 287446) +SessionKeyValidatorTest:test_external_call_batch_execute_fail() (gas: 29553) +SessionKeyValidatorTest:test_external_call_batch_execute_success() (gas: 26533) +SessionKeyValidatorTest:test_external_call_default() (gas: 29360) SessionKeyValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 28381) -SessionKeyValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 26351) +SessionKeyValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 26373) SessionKeyValidatorTest:test_external_call_execute_delegatecall_success() (gas: 25621) SessionKeyValidatorTest:test_external_call_execute_fail() (gas: 27862) -SessionKeyValidatorTest:test_external_call_execute_success() (gas: 26009) -SessionKeyValidatorTest:test_external_call_execution() (gas: 510718) -SessionKeyValidatorTest:test_fail_validate_not_activate() (gas: 303513) -SessionKeyValidatorTest:test_fail_validate_wrongsignature() (gas: 34165) +SessionKeyValidatorTest:test_external_call_execute_success() (gas: 26031) +SessionKeyValidatorTest:test_external_call_execution() (gas: 511076) +SessionKeyValidatorTest:test_fail_validate_not_activate() (gas: 303538) +SessionKeyValidatorTest:test_fail_validate_wrongsignature() (gas: 34395) SessionKeyValidatorTest:test_get_nonce() (gas: 25179) SessionKeyValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 19842, ~: 19842) -SessionKeyValidatorTest:test_ignore() (gas: 890) +SessionKeyValidatorTest:test_ignore() (gas: 912) SessionKeyValidatorTest:test_initialize() (gas: 154121) SessionKeyValidatorTest:test_initialize_twice() (gas: 18555) -SessionKeyValidatorTest:test_mode_2() (gas: 250298) -SessionKeyValidatorTest:test_revert_when_mode_disabled() (gas: 199003) -SessionKeyValidatorTest:test_scenario_batch((uint8,uint8,uint8,uint8,uint48,uint48,uint48,uint48,bool,bool,bool,bool),(uint8)) (runs: 1024, μ: 43997409, ~: 32002162) -SessionKeyValidatorTest:test_scenario_non_batch((uint8,uint8,uint8,uint8,uint48,uint48,uint48,uint48,bool,bool,bool,bool)) (runs: 1024, μ: 17511495, ~: 17372686) -SessionKeyValidatorTest:test_set_default_validator() (gas: 423335) -SessionKeyValidatorTest:test_set_execution() (gas: 468303) -SessionKeyValidatorTest:test_should_emit_event_on_receive() (gas: 23242) -SessionKeyValidatorTest:test_should_receive_erc1155() (gas: 701145) -SessionKeyValidatorTest:test_should_receive_erc1155_batch() (gas: 728411) -SessionKeyValidatorTest:test_should_receive_erc721() (gas: 597724) -SessionKeyValidatorTest:test_should_return_address_if_deployed() (gas: 22003) -SessionKeyValidatorTest:test_sudo() (gas: 179450) -SessionKeyValidatorTest:test_sudo_wrongSig() (gas: 115731) +SessionKeyValidatorTest:test_mode_2() (gas: 251156) +SessionKeyValidatorTest:test_revert_when_mode_disabled() (gas: 200119) +SessionKeyValidatorTest:test_scenario_batch((uint8,uint8,uint8,uint8,uint48,uint48,uint48,uint48,bool,bool,bool,bool,bool),(uint8)) (runs: 1024, μ: 56405623, ~: 51218259) +SessionKeyValidatorTest:test_scenario_non_batch((uint8,uint8,uint8,uint8,uint48,uint48,uint48,uint48,bool,bool,bool,bool,bool)) (runs: 1024, μ: 50726904, ~: 50878941) +SessionKeyValidatorTest:test_set_default_validator() (gas: 423674) +SessionKeyValidatorTest:test_set_execution() (gas: 468648) +SessionKeyValidatorTest:test_should_emit_event_on_receive() (gas: 23264) +SessionKeyValidatorTest:test_should_receive_erc1155() (gas: 700299) +SessionKeyValidatorTest:test_should_receive_erc1155_batch() (gas: 727496) +SessionKeyValidatorTest:test_should_receive_erc721() (gas: 597540) +SessionKeyValidatorTest:test_should_return_address_if_deployed() (gas: 22020) +SessionKeyValidatorTest:test_sudo() (gas: 179783) +SessionKeyValidatorTest:test_sudo_wrongSig() (gas: 116365) SessionKeyValidatorTest:test_upgrade() (gas: 21292) -SessionKeyValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 26574) -SessionKeyValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 30634) -SessionKeyValidatorTest:test_validate_signature() (gas: 194502) -TestCallee:test_ignore() (gas: 206) +SessionKeyValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 26958) +SessionKeyValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23364) +SessionKeyValidatorTest:test_validate_signature() (gas: 194938) +StealthAddressValidatorTest:test_default_validator_disable() (gas: 1784996) +StealthAddressValidatorTest:test_default_validator_enable() (gas: 3460838) +StealthAddressValidatorTest:test_disable_mode() (gas: 1784530) +StealthAddressValidatorTest:test_eip712() (gas: 15715) +StealthAddressValidatorTest:test_enable_then_mode_1() (gas: 1889579) +StealthAddressValidatorTest:test_external_call_batch_execute_fail() (gas: 29635) +StealthAddressValidatorTest:test_external_call_batch_execute_success() (gas: 26615) +StealthAddressValidatorTest:test_external_call_default() (gas: 29441) +StealthAddressValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 28484) +StealthAddressValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 26454) +StealthAddressValidatorTest:test_external_call_execute_delegatecall_success() (gas: 25724) +StealthAddressValidatorTest:test_external_call_execute_fail() (gas: 27965) +StealthAddressValidatorTest:test_external_call_execute_success() (gas: 26090) +StealthAddressValidatorTest:test_external_call_execution() (gas: 2112709) +StealthAddressValidatorTest:test_fail_validate_not_activate() (gas: 303548) +StealthAddressValidatorTest:test_fail_validate_wrongsignature() (gas: 1630406) +StealthAddressValidatorTest:test_get_nonce() (gas: 25188) +StealthAddressValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 19873, ~: 19873) +StealthAddressValidatorTest:test_initialize() (gas: 1817402) +StealthAddressValidatorTest:test_initialize_twice() (gas: 1614285) +StealthAddressValidatorTest:test_mode_2() (gas: 1848919) +StealthAddressValidatorTest:test_revert_when_mode_disabled() (gas: 1804567) +StealthAddressValidatorTest:test_set_default_validator() (gas: 2025016) +StealthAddressValidatorTest:test_set_execution() (gas: 2070181) +StealthAddressValidatorTest:test_should_emit_event_on_receive() (gas: 23273) +StealthAddressValidatorTest:test_should_receive_erc1155() (gas: 700331) +StealthAddressValidatorTest:test_should_receive_erc1155_batch() (gas: 727528) +StealthAddressValidatorTest:test_should_receive_erc721() (gas: 597506) +StealthAddressValidatorTest:test_should_return_address_if_deployed() (gas: 1618159) +StealthAddressValidatorTest:test_stealth_validate_sig_aggsig() (gas: 2997520) +StealthAddressValidatorTest:test_stealth_validate_userop_aggsig() (gas: 3018773) +StealthAddressValidatorTest:test_sudo() (gas: 1781012) +StealthAddressValidatorTest:test_sudo_wrongSig() (gas: 1713761) +StealthAddressValidatorTest:test_upgrade() (gas: 21301) +StealthAddressValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27019) +StealthAddressValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23428) +StealthAddressValidatorTest:test_validate_signature() (gas: 3517497) +TestCallee:test_ignore() (gas: 249) TestCounter:test_ignore() (gas: 164) -TestERC1155:test_ignore() (gas: 328) +TestERC1155:test_ignore() (gas: 313) TestERC20:test_ignore() (gas: 389) TestERC721:test_ignore() (gas: 399) TestExecutor:test_ignore() (gas: 130) TestPaymaster:test_ignore() (gas: 174) -TestValidator:test_ignore() (gas: 351) \ No newline at end of file +TestValidator:test_ignore() (gas: 351) +WebAuthnValidatorTest:test_default_validator_disable() (gas: 916823) +WebAuthnValidatorTest:test_default_validator_enable() (gas: 931392) +WebAuthnValidatorTest:test_disable_mode() (gas: 932340) +WebAuthnValidatorTest:test_eip712() (gas: 15909) +WebAuthnValidatorTest:test_enable_then_mode_1() (gas: 1376207) +WebAuthnValidatorTest:test_external_call_batch_execute_fail() (gas: 25023) +WebAuthnValidatorTest:test_external_call_batch_execute_success() (gas: 0) +WebAuthnValidatorTest:test_external_call_default() (gas: 0) +WebAuthnValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 0) +WebAuthnValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 21901) +WebAuthnValidatorTest:test_external_call_execute_delegatecall_success() (gas: 0) +WebAuthnValidatorTest:test_external_call_execute_fail() (gas: 21191) +WebAuthnValidatorTest:test_external_call_execute_success() (gas: 0) +WebAuthnValidatorTest:test_external_call_execution() (gas: 0) +WebAuthnValidatorTest:test_fail_validate_not_activate() (gas: 304359) +WebAuthnValidatorTest:test_fail_validate_wrongsignature() (gas: 712714) +WebAuthnValidatorTest:test_get_nonce() (gas: 25621) +WebAuthnValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 20112, ~: 20112) +WebAuthnValidatorTest:test_initialize() (gas: 178435) +WebAuthnValidatorTest:test_initialize_twice() (gas: 20756) +WebAuthnValidatorTest:test_mode_2() (gas: 1359325) +WebAuthnValidatorTest:test_revert_when_mode_disabled() (gas: 949359) +WebAuthnValidatorTest:test_set_default_validator() (gas: 1164365) +WebAuthnValidatorTest:test_set_execution() (gas: 1223050) +WebAuthnValidatorTest:test_should_emit_event_on_receive() (gas: 23390) +WebAuthnValidatorTest:test_should_receive_erc1155() (gas: 700443) +WebAuthnValidatorTest:test_should_receive_erc1155_batch() (gas: 727703) +WebAuthnValidatorTest:test_should_receive_erc721() (gas: 597618) +WebAuthnValidatorTest:test_should_return_address_if_deployed() (gas: 24455) +WebAuthnValidatorTest:test_sudo() (gas: 945312) +WebAuthnValidatorTest:test_sudo_wrongSig() (gas: 856703) +WebAuthnValidatorTest:test_upgrade() (gas: 21621) +WebAuthnValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27324) +WebAuthnValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23656) +WebAuthnValidatorTest:test_validate_signature() (gas: 1302014) +WebAuthnValidatorTest:test_webAuthnSignatureGeneration(bytes32,uint256) (runs: 1024, μ: 1301771, ~: 1192892) \ No newline at end of file diff --git a/src/utils/WebAuthnWrapper.sol b/src/utils/WebAuthnWrapper.sol index 6ea11347..614f18b8 100644 --- a/src/utils/WebAuthnWrapper.sol +++ b/src/utils/WebAuthnWrapper.sol @@ -32,7 +32,7 @@ library WebAuthnWrapper { ) external view returns (bool) { // Format the msg signed via the p256 curve bytes32 message = formatWebAuthNChallenge( - authenticatorData, authenticatorDataFlagMask, clientData, clientChallenge, clientChallengeDataOffset, rs + authenticatorData, authenticatorDataFlagMask, clientData, clientChallenge, clientChallengeDataOffset ); // Perform the verification @@ -45,9 +45,8 @@ library WebAuthnWrapper { bytes1 authenticatorDataFlagMask, bytes calldata clientData, bytes32 clientChallenge, - uint256 clientChallengeDataOffset, - uint256[2] calldata // rs - ) internal pure returns (bytes32) { + uint256 clientChallengeDataOffset + ) public pure returns (bytes32) { // Let the caller check if User Presence (0x01) or User Verification (0x04) are set { if ((authenticatorData[32] & authenticatorDataFlagMask) != authenticatorDataFlagMask) { diff --git a/test/foundry/validator/WebAuthnValidator.t.sol b/test/foundry/validator/WebAuthnValidator.t.sol new file mode 100644 index 00000000..c57bc2f8 --- /dev/null +++ b/test/foundry/validator/WebAuthnValidator.t.sol @@ -0,0 +1,288 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {IEntryPoint} from "I4337/interfaces/IEntryPoint.sol"; +import "src/Kernel.sol"; +import "forge-std/Test.sol"; +import {ERC4337Utils} from "../utils/ERC4337Utils.sol"; +import {KernelTestBase} from "../KernelTestBase.sol"; +import {TestExecutor} from "../mock/TestExecutor.sol"; +import {TestValidator} from "../mock/TestValidator.sol"; +import {P256Validator} from "src/validator/P256Validator.sol"; +import {WebAuthnWrapper} from "src/utils/WebAuthnWrapper.sol"; +import {WebAuthnValidator} from "src/validator/WebAuthnValidator.sol"; +import {P256} from "p256-verifier/P256.sol"; +import {FCL_ecdsa_utils} from "FreshCryptoLib/FCL_ecdsa_utils.sol"; +import {Base64Url} from "FreshCryptoLib/utils/Base64Url.sol"; +import {IKernel} from "src/interfaces/IKernel.sol"; + +using ERC4337Utils for IEntryPoint; + +contract WebAuthnValidatorTest is KernelTestBase { + WebAuthnValidator webAuthNValidator; + + // Curve order (number of points) + uint256 constant n = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551; + + // The public key of the owner + uint256 x; + uint256 y; + + function setUp() public { + webAuthNValidator = new WebAuthnValidator(); + + _initialize(); + (x, y) = _getPublicKey(ownerKey); + _setAddress(); + _setExecutionDetail(); + } + + function _setExecutionDetail() internal virtual override { + executionDetail.executor = address(new TestExecutor()); + executionSig = TestExecutor.doNothing.selector; + executionDetail.validator = new TestValidator(); + } + + function getValidatorSignature(UserOperation memory _op) internal view virtual override returns (bytes memory) { + bytes32 _hash = entryPoint.getUserOpHash(_op); + bytes memory signature = _generateWebAuthnSignature(ownerKey, _hash); + return abi.encodePacked(bytes4(0x00000000), signature); + } + + function getOwners() internal virtual override returns (address[] memory _owners) { + _owners = new address[](1); + _owners[0] = address(0); + return _owners; + } + + function getEnableData() internal view virtual override returns (bytes memory) { + return ""; + } + + function getInitializeData() internal view override returns (bytes memory) { + return abi.encodeWithSelector(KernelStorage.initialize.selector, webAuthNValidator, abi.encode(x, y)); + } + + function test_default_validator_enable() external override { + UserOperation memory op = buildUserOperation( + abi.encodeWithSelector( + IKernel.execute.selector, + address(webAuthNValidator), + 0, + abi.encodeWithSelector(webAuthNValidator.enable.selector, abi.encode(x, y)), + Operation.Call + ) + ); + performUserOperationWithSig(op); + (uint256 x2, uint256 y2) = WebAuthnValidator(address(webAuthNValidator)).getPublicKey(address(kernel)); + verifyPublicKey(x2, y2, x, y); + } + + function test_default_validator_disable() external override { + UserOperation memory op = buildUserOperation( + abi.encodeWithSelector( + IKernel.execute.selector, + address(webAuthNValidator), + 0, + abi.encodeWithSelector(P256Validator.disable.selector, ""), + Operation.Call + ) + ); + performUserOperationWithSig(op); + (uint256 x2, uint256 y2) = WebAuthnValidator(address(webAuthNValidator)).getPublicKey(address(kernel)); + verifyPublicKey(x2, y2, 0, 0); + } + + function test_external_call_batch_execute_success() external override { + vm.skip(true); + } + + function test_external_call_execute_success() external override { + vm.skip(true); + } + + function test_external_call_execute_delegatecall_success() external override { + vm.skip(true); + } + + function test_external_call_execute_delegatecall_fail() external override { + vm.skip(true); + } + + function test_external_call_default() external override { + vm.skip(true); + } + + function test_external_call_execution() external override { + vm.skip(true); + } + + function test_validate_signature() external override { + Kernel kernel2 = Kernel(payable(factory.createAccount(address(kernelImpl), getInitializeData(), 3))); + bytes32 _hash = keccak256(abi.encodePacked("hello world")); + + bytes32 digest = keccak256( + abi.encodePacked( + "\x19\x01", ERC4337Utils._buildDomainSeparator(KERNEL_NAME, KERNEL_VERSION, address(kernel)), _hash + ) + ); + + bytes memory signature = _generateWebAuthnSignature(ownerKey, digest); + + assertEq(kernel.isValidSignature(_hash, signature), Kernel.isValidSignature.selector); + assertEq(kernel2.isValidSignature(_hash, signature), bytes4(0xffffffff)); + } + + function test_fail_validate_wrongsignature() external override { + bytes32 hash = keccak256(abi.encodePacked("hello world")); + bytes memory sig = getWrongSignature(hash); + assertEq(kernel.isValidSignature(hash, sig), bytes4(0xffffffff)); + } + + function signUserOp(UserOperation memory op) internal view override returns (bytes memory) { + bytes32 _hash = entryPoint.getUserOpHash(op); + bytes memory signature = _generateWebAuthnSignature(ownerKey, _hash); + return abi.encodePacked(bytes4(0x00000000), signature); + } + + function getWrongSignature(UserOperation memory op) internal view override returns (bytes memory) { + bytes32 _hash = entryPoint.getUserOpHash(op); + bytes memory signature = _generateWebAuthnSignature(ownerKey + 1, _hash); + return abi.encodePacked(bytes4(0x00000000), signature); + } + + function signHash(bytes32 _hash) internal view override returns (bytes memory) { + return _generateWebAuthnSignature(ownerKey, _hash); + } + + function getWrongSignature(bytes32 _hash) internal view override returns (bytes memory) { + return _generateWebAuthnSignature(ownerKey + 1, _hash); + } + + function verifyPublicKey(uint256 actualX, uint256 actualY, uint256 expectedX, uint256 expectedY) internal { + assertEq(actualX, expectedX, "Public key X component mismatch"); + assertEq(actualY, expectedY, "Public key Y component mismatch"); + } + + /// @dev Ensure that our flow to generate a webauthn signature is working + function test_webAuthnSignatureGeneration(bytes32 _hash, uint256 _privateKey) public { + vm.assume(_privateKey > 0); + (uint256 pubX, uint256 pubY) = _getPublicKey(_privateKey); + + // The public key we will use + uint256[2] memory pubKey = [pubX, pubY]; + + // Build all the data required + ( + bytes32 msgToSign, + bytes memory authenticatorData, + bytes1 authenticatorDataFlagMask, + bytes memory clientData, + bytes32 clientChallenge, + uint256 clientChallengeDataOffset + ) = _prepapreWebAuthnMsg(_hash); + + // Then sign them + (uint256 r, uint256 s) = _getP256Signature(_privateKey, msgToSign); + uint256[2] memory rs = [r, s]; + + // Ensure the signature is valid + bool isValid = WebAuthnWrapper.checkSignature( + authenticatorData, + authenticatorDataFlagMask, + clientData, + clientChallenge, + clientChallengeDataOffset, + rs, + pubKey + ); + assertEq(isValid, true); + } + + /* -------------------------------------------------------------------------- */ + /* Signature & P256 helper functions */ + /* -------------------------------------------------------------------------- */ + + /// @dev Generate a webauthn signature for the given `_hash` using the given `_privateKey` + function _generateWebAuthnSignature(uint256 _privateKey, bytes32 _hash) + internal + view + returns (bytes memory signature) + { + ( + bytes32 msgToSign, + bytes memory authenticatorData, + , + bytes memory clientData, + , + uint256 clientChallengeDataOffset + ) = _prepapreWebAuthnMsg(_hash); + + // Get the signature + (uint256 r, uint256 s) = _getP256Signature(_privateKey, msgToSign); + uint256[2] memory rs = [r, s]; + + // Return the signature + return abi.encode(authenticatorData, clientData, clientChallengeDataOffset, rs); + } + + /// @dev Prepare all the base data needed to perform a webauthn signature o n the given `_hash` + function _prepapreWebAuthnMsg(bytes32 _hash) + internal + pure + returns ( + bytes32 msgToSign, + bytes memory authenticatorData, + bytes1 authenticatorDataFlagMask, + bytes memory clientData, + bytes32 clientChallenge, + uint256 clientChallengeDataOffset + ) + { + // Base Mapping of the message + clientChallenge = _hash; + bytes memory encodedChallenge = bytes(Base64Url.encode(abi.encodePacked(_hash))); + + // Prepare the authenticator data (from a real webauthn challenge) + authenticatorData = hex"49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000"; + + // Prepare the client data (starting from a real webauthn challenge, then replacing only the bytes needed for the challenge) + bytes memory clientDataStart = hex"7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22"; + bytes memory clientDataEnd = + hex"222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303032222c2263726f73734f726967696e223a66616c73657d"; + clientData = bytes.concat(clientDataStart, encodedChallenge, clientDataEnd); + clientChallengeDataOffset = 36; + + // Set the flag mask to 0x01 (User Presence) + authenticatorDataFlagMask = authenticatorData[32]; + + // Once we got all of our data, prepapre the msg to sign + msgToSign = WebAuthnWrapper.formatWebAuthNChallenge( + authenticatorData, authenticatorDataFlagMask, clientData, clientChallenge, clientChallengeDataOffset + ); + } + + /// @dev Get a public key for a p256 user, from the given `_privateKey` + function _getPublicKey(uint256 _privateKey) internal view returns (uint256, uint256) { + return FCL_ecdsa_utils.ecdsa_derivKpub(_privateKey); + } + + /// @dev Generate a p256 signature, from the given `_privateKey` on the given `_hash` + function _getP256Signature(uint256 _privateKey, bytes32 _hash) internal view returns (uint256 r, uint256 s) { + // Securely generate a random k value for each signature + uint256 k = uint256(keccak256(abi.encodePacked(_hash, block.timestamp, block.prevrandao, _privateKey))) % n; + while (k == 0) { + k = uint256(keccak256(abi.encodePacked(k))) % n; + } + + // Generate the signature using the k value and the private key + (r, s) = FCL_ecdsa_utils.ecdsa_sign(_hash, k, _privateKey); + + // Ensure that s is in the lower half of the range [1, n-1] + if (r == 0 || s == 0 || s > P256.P256_N_DIV_2) { + s = n - s; // If s is in the upper half, use n - s instead + } + + return (r, s); + } +} From 61224c1cdc892a1cbc9bf6e7b7fa7f569d313c99 Mon Sep 17 00:00:00 2001 From: KONFeature Date: Fri, 19 Jan 2024 14:59:05 +0100 Subject: [PATCH 05/12] =?UTF-8?q?=F0=9F=9A=9A=20rename=20WebAuthnValidator?= =?UTF-8?q?=20->=20WebAuthnFclValidator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nValidator.sol => WebAuthnFclValidator.sol} | 18 +++++++++--------- ...idator.t.sol => WebAuthnFclValidator.t.sol} | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) rename src/validator/{WebAuthnValidator.sol => WebAuthnFclValidator.sol} (87%) rename test/foundry/validator/{WebAuthnValidator.t.sol => WebAuthnFclValidator.t.sol} (95%) diff --git a/src/validator/WebAuthnValidator.sol b/src/validator/WebAuthnFclValidator.sol similarity index 87% rename from src/validator/WebAuthnValidator.sol rename to src/validator/WebAuthnFclValidator.sol index 8228231f..846978a1 100644 --- a/src/validator/WebAuthnValidator.sol +++ b/src/validator/WebAuthnFclValidator.sol @@ -9,7 +9,7 @@ import {SIG_VALIDATION_FAILED} from "../common/Constants.sol"; import {WebAuthnWrapper} from "../utils/WebAuthnWrapper.sol"; /// @dev Storage layout for a kernel in the WebAuthnValidator contract. -struct WebAuthnValidatorStorage { +struct WebAuthnFclValidatorStorage { /// @dev The `x` coord of the secp256r1 public key used to sign the user operation. uint256 x; /// @dev The `y` coord of the secp256r1 public key used to sign the user operation. @@ -17,16 +17,16 @@ struct WebAuthnValidatorStorage { } /// @author @KONFeature -/// @title WebAuthnValidator +/// @title WebAuthnFclValidator /// @notice Kernel validator used to validated user operations via WebAuthn signature (using P256 under the hood) /// @notice Using the awesome FreshCryptoLib: https://github.com/rdubois-crypto/FreshCryptoLib/ /// @notice Inspired by the cometh Gnosis Safe signer: https://github.com/cometh-game/p256-signer -contract WebAuthnValidator is IKernelValidator { +contract WebAuthnFclValidator is IKernelValidator { /// @dev Event emitted when the public key signing the WebAuthN user operation is changed for a given `kernel`. event WebAuthnPublicKeyChanged(address indexed kernel, uint256 x, uint256 y); /// @dev Mapping of kernel address to each webAuthn specific storage - mapping(address kernel => WebAuthnValidatorStorage webAuthnStorage) private webAuthnValidatorStorage; + mapping(address kernel => WebAuthnFclValidatorStorage webAuthnStorage) private webAuthnValidatorStorage; /// @dev Disable this validator for a given `kernel` (msg.sender) function disable(bytes calldata) external payable override { @@ -38,7 +38,7 @@ contract WebAuthnValidator is IKernelValidator { // Extract the x & y coordinates of the public key from the `_data` bytes (uint256 x, uint256 y) = abi.decode(_data, (uint256, uint256)); // Update the pub key data - WebAuthnValidatorStorage storage kernelValidatorStorage = webAuthnValidatorStorage[msg.sender]; + WebAuthnFclValidatorStorage storage kernelValidatorStorage = webAuthnValidatorStorage[msg.sender]; kernelValidatorStorage.x = x; kernelValidatorStorage.y = y; // Emit the update event @@ -52,7 +52,7 @@ contract WebAuthnValidator is IKernelValidator { override returns (ValidationData validationData) { - WebAuthnValidatorStorage memory kernelValidatorStorage = webAuthnValidatorStorage[_userOp.sender]; + WebAuthnFclValidatorStorage memory kernelValidatorStorage = webAuthnValidatorStorage[_userOp.sender]; // Perform a check against the direct userOpHash, if ok consider the user op as validated if (_checkSignature(kernelValidatorStorage, _userOpHash, _userOp.signature)) { @@ -69,7 +69,7 @@ contract WebAuthnValidator is IKernelValidator { override returns (ValidationData) { - WebAuthnValidatorStorage memory kernelValidatorStorage = webAuthnValidatorStorage[msg.sender]; + WebAuthnFclValidatorStorage memory kernelValidatorStorage = webAuthnValidatorStorage[msg.sender]; // Check the validity againt the hash directly if (_checkSignature(kernelValidatorStorage, _hash, _signature)) { @@ -85,7 +85,7 @@ contract WebAuthnValidator is IKernelValidator { /// @param _hash The hash signed /// @param _signature The signature function _checkSignature( - WebAuthnValidatorStorage memory _kernelValidatorStorage, + WebAuthnFclValidatorStorage memory _kernelValidatorStorage, bytes32 _hash, bytes memory _signature ) private view returns (bool isValid) { @@ -121,7 +121,7 @@ contract WebAuthnValidator is IKernelValidator { /// @dev Get the owner of a given `kernel` function getPublicKey(address _kernel) public view returns (uint256 x, uint256 y) { // Compute the storage slot - WebAuthnValidatorStorage storage kernelValidatorStorage = webAuthnValidatorStorage[_kernel]; + WebAuthnFclValidatorStorage storage kernelValidatorStorage = webAuthnValidatorStorage[_kernel]; // Access it for x and y x = kernelValidatorStorage.x; diff --git a/test/foundry/validator/WebAuthnValidator.t.sol b/test/foundry/validator/WebAuthnFclValidator.t.sol similarity index 95% rename from test/foundry/validator/WebAuthnValidator.t.sol rename to test/foundry/validator/WebAuthnFclValidator.t.sol index c57bc2f8..7780b70e 100644 --- a/test/foundry/validator/WebAuthnValidator.t.sol +++ b/test/foundry/validator/WebAuthnFclValidator.t.sol @@ -10,7 +10,7 @@ import {TestExecutor} from "../mock/TestExecutor.sol"; import {TestValidator} from "../mock/TestValidator.sol"; import {P256Validator} from "src/validator/P256Validator.sol"; import {WebAuthnWrapper} from "src/utils/WebAuthnWrapper.sol"; -import {WebAuthnValidator} from "src/validator/WebAuthnValidator.sol"; +import {WebAuthnFclValidator} from "src/validator/WebAuthnFclValidator.sol"; import {P256} from "p256-verifier/P256.sol"; import {FCL_ecdsa_utils} from "FreshCryptoLib/FCL_ecdsa_utils.sol"; import {Base64Url} from "FreshCryptoLib/utils/Base64Url.sol"; @@ -18,8 +18,8 @@ import {IKernel} from "src/interfaces/IKernel.sol"; using ERC4337Utils for IEntryPoint; -contract WebAuthnValidatorTest is KernelTestBase { - WebAuthnValidator webAuthNValidator; +contract WebAuthnFclValidatorTest is KernelTestBase { + WebAuthnFclValidator webAuthNValidator; // Curve order (number of points) uint256 constant n = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551; @@ -29,7 +29,7 @@ contract WebAuthnValidatorTest is KernelTestBase { uint256 y; function setUp() public { - webAuthNValidator = new WebAuthnValidator(); + webAuthNValidator = new WebAuthnFclValidator(); _initialize(); (x, y) = _getPublicKey(ownerKey); @@ -74,7 +74,7 @@ contract WebAuthnValidatorTest is KernelTestBase { ) ); performUserOperationWithSig(op); - (uint256 x2, uint256 y2) = WebAuthnValidator(address(webAuthNValidator)).getPublicKey(address(kernel)); + (uint256 x2, uint256 y2) = WebAuthnFclValidator(address(webAuthNValidator)).getPublicKey(address(kernel)); verifyPublicKey(x2, y2, x, y); } @@ -89,7 +89,7 @@ contract WebAuthnValidatorTest is KernelTestBase { ) ); performUserOperationWithSig(op); - (uint256 x2, uint256 y2) = WebAuthnValidator(address(webAuthNValidator)).getPublicKey(address(kernel)); + (uint256 x2, uint256 y2) = WebAuthnFclValidator(address(webAuthNValidator)).getPublicKey(address(kernel)); verifyPublicKey(x2, y2, 0, 0); } From e6721675b6a0e7939f270c06f6856b90f95d2669 Mon Sep 17 00:00:00 2001 From: KONFeature Date: Fri, 19 Jan 2024 18:20:08 +0100 Subject: [PATCH 06/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Lot=20of=20WebAuthN?= =?UTF-8?q?=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Stay in calldata for webauthn challenge formatting - Stay inside the WebAuthN validator contract for challenge preparation etc, only exit for p256 verification - Better SoC between validator / webauthn / p256 - Wrap the p256 verification logic inside a contract that can be easily replaced when RIP-7212 is deployed --- .gas-snapshot | 134 +++++++++--------- scripts/DeployWebAuthnValidator.s.sol | 6 +- src/utils/P256VerifierWrapper.sol | 45 ++++++ src/utils/WebAuthnFclVerifier.sol | 133 +++++++++++++++++ src/utils/WebAuthnWrapper.sol | 94 ------------ src/validator/WebAuthnFclValidator.sol | 35 +++-- .../validator/WebAuthnFclValidator.t.sol | 84 +++++++---- 7 files changed, 320 insertions(+), 211 deletions(-) create mode 100644 src/utils/P256VerifierWrapper.sol create mode 100644 src/utils/WebAuthnFclVerifier.sol delete mode 100644 src/utils/WebAuthnWrapper.sol diff --git a/.gas-snapshot b/.gas-snapshot index d0c974fc..c8fef026 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,13 +1,13 @@ KernelECDSATest:test_default_validator_disable() (gas: 0) -KernelECDSATest:test_default_validator_disable() (gas: 180620) +KernelECDSATest:test_default_validator_disable() (gas: 180648) KernelECDSATest:test_default_validator_enable() (gas: 0) -KernelECDSATest:test_default_validator_enable() (gas: 188112) -KernelECDSATest:test_disable_mode() (gas: 183122) +KernelECDSATest:test_default_validator_enable() (gas: 188140) +KernelECDSATest:test_disable_mode() (gas: 183150) KernelECDSATest:test_disable_mode() (gas: 192700) KernelECDSATest:test_eip712() (gas: 15684) KernelECDSATest:test_eip712() (gas: 15684) KernelECDSATest:test_enable_then_mode_1() (gas: 279619) -KernelECDSATest:test_enable_then_mode_1() (gas: 287374) +KernelECDSATest:test_enable_then_mode_1() (gas: 287402) KernelECDSATest:test_external_call_batch_execute_fail() (gas: 23625) KernelECDSATest:test_external_call_batch_execute_fail() (gas: 29531) KernelECDSATest:test_external_call_batch_execute_success() (gas: 20626) @@ -25,7 +25,7 @@ KernelECDSATest:test_external_call_execute_fail() (gas: 27862) KernelECDSATest:test_external_call_execute_success() (gas: 20070) KernelECDSATest:test_external_call_execute_success() (gas: 25987) KernelECDSATest:test_external_call_execution() (gas: 498421) -KernelECDSATest:test_external_call_execution() (gas: 511004) +KernelECDSATest:test_external_call_execution() (gas: 511032) KernelECDSATest:test_fail_validate_not_activate() (gas: 0) KernelECDSATest:test_fail_validate_not_activate() (gas: 303494) KernelECDSATest:test_fail_validate_wrongsignature() (gas: 25013) @@ -41,12 +41,12 @@ KernelECDSATest:test_initialize_twice() (gas: 18555) KernelECDSATest:test_initialize_twice() (gas: 18599) KernelECDSATest:test_mode_2() (gas: 243908) KernelECDSATest:test_mode_2() (gas: 251079) -KernelECDSATest:test_revert_when_mode_disabled() (gas: 200091) +KernelECDSATest:test_revert_when_mode_disabled() (gas: 200119) KernelECDSATest:test_revert_when_mode_disabled() (gas: 209732) KernelECDSATest:test_set_default_validator() (gas: 417758) -KernelECDSATest:test_set_default_validator() (gas: 423646) +KernelECDSATest:test_set_default_validator() (gas: 423674) KernelECDSATest:test_set_execution() (gas: 458753) -KernelECDSATest:test_set_execution() (gas: 468620) +KernelECDSATest:test_set_execution() (gas: 468648) KernelECDSATest:test_should_emit_event_on_receive() (gas: 23220) KernelECDSATest:test_should_emit_event_on_receive() (gas: 23220) KernelECDSATest:test_should_receive_erc1155() (gas: 700299) @@ -58,7 +58,7 @@ KernelECDSATest:test_should_receive_erc721() (gas: 597496) KernelECDSATest:test_should_return_address_if_deployed() (gas: 21970) KernelECDSATest:test_should_return_address_if_deployed() (gas: 21976) KernelECDSATest:test_sudo() (gas: 170601) -KernelECDSATest:test_sudo() (gas: 179755) +KernelECDSATest:test_sudo() (gas: 179783) KernelECDSATest:test_sudo_wrongSig() (gas: 103132) KernelECDSATest:test_sudo_wrongSig() (gas: 116321) KernelECDSATest:test_transfer_ownership() (gas: 185003) @@ -107,11 +107,11 @@ KernelECDSATypedTest:test_validateUserOp_fail_invalid_mode() (gas: 26934) KernelECDSATypedTest:test_validateUserOp_fail_not_entryPoint() (gas: 23364) KernelECDSATypedTest:test_validate_signature() (gas: 191837) KernelHelperTest:testIntersect(uint48,uint48,uint48,uint48) (runs: 1024, μ: 986, ~: 991) -KillSwitchValidatorTest:test_default_validator_disable() (gas: 180741) -KillSwitchValidatorTest:test_default_validator_enable() (gas: 188233) -KillSwitchValidatorTest:test_disable_mode() (gas: 183243) +KillSwitchValidatorTest:test_default_validator_disable() (gas: 180769) +KillSwitchValidatorTest:test_default_validator_enable() (gas: 188261) +KillSwitchValidatorTest:test_disable_mode() (gas: 183271) KillSwitchValidatorTest:test_eip712() (gas: 15820) -KillSwitchValidatorTest:test_enable_then_mode_1() (gas: 349968) +KillSwitchValidatorTest:test_enable_then_mode_1() (gas: 349996) KillSwitchValidatorTest:test_external_call_batch_execute_fail() (gas: 29619) KillSwitchValidatorTest:test_external_call_batch_execute_success() (gas: 26555) KillSwitchValidatorTest:test_external_call_default() (gas: 29426) @@ -120,7 +120,7 @@ KillSwitchValidatorTest:test_external_call_execute_delegatecall_option_fail() (g KillSwitchValidatorTest:test_external_call_execute_delegatecall_success() (gas: 25709) KillSwitchValidatorTest:test_external_call_execute_fail() (gas: 27906) KillSwitchValidatorTest:test_external_call_execute_success() (gas: 26075) -KillSwitchValidatorTest:test_external_call_execution() (gas: 511125) +KillSwitchValidatorTest:test_external_call_execution() (gas: 511153) KillSwitchValidatorTest:test_fail_validate_not_activate() (gas: 303604) KillSwitchValidatorTest:test_fail_validate_wrongsignature() (gas: 34494) KillSwitchValidatorTest:test_force_unblock() (gas: 394736) @@ -130,9 +130,9 @@ KillSwitchValidatorTest:test_ignore() (gas: 956) KillSwitchValidatorTest:test_initialize() (gas: 154209) KillSwitchValidatorTest:test_initialize_twice() (gas: 18643) KillSwitchValidatorTest:test_mode_2() (gas: 313713) -KillSwitchValidatorTest:test_revert_when_mode_disabled() (gas: 200245) -KillSwitchValidatorTest:test_set_default_validator() (gas: 423745) -KillSwitchValidatorTest:test_set_execution() (gas: 468741) +KillSwitchValidatorTest:test_revert_when_mode_disabled() (gas: 200273) +KillSwitchValidatorTest:test_set_default_validator() (gas: 423773) +KillSwitchValidatorTest:test_set_execution() (gas: 468769) KillSwitchValidatorTest:test_should_emit_event_on_receive() (gas: 23330) KillSwitchValidatorTest:test_should_fail_with_not_implemented_isValidSignature() (gas: 9236) KillSwitchValidatorTest:test_should_fail_with_not_implemented_isValidSignature(bytes32,bytes) (runs: 1024, μ: 9601, ~: 9556) @@ -142,17 +142,17 @@ KillSwitchValidatorTest:test_should_receive_erc1155() (gas: 700387) KillSwitchValidatorTest:test_should_receive_erc1155_batch() (gas: 727584) KillSwitchValidatorTest:test_should_receive_erc721() (gas: 597584) KillSwitchValidatorTest:test_should_return_address_if_deployed() (gas: 22086) -KillSwitchValidatorTest:test_sudo() (gas: 179854) +KillSwitchValidatorTest:test_sudo() (gas: 179882) KillSwitchValidatorTest:test_sudo_wrongSig() (gas: 116442) KillSwitchValidatorTest:test_upgrade() (gas: 21314) KillSwitchValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27022) KillSwitchValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23391) KillSwitchValidatorTest:test_validate_signature() (gas: 195015) -P256ValidatorTest:test_default_validator_disable() (gas: 876785) -P256ValidatorTest:test_default_validator_enable() (gas: 888633) -P256ValidatorTest:test_disable_mode() (gas: 886327) +P256ValidatorTest:test_default_validator_disable() (gas: 878460) +P256ValidatorTest:test_default_validator_enable() (gas: 890421) +P256ValidatorTest:test_disable_mode() (gas: 888100) P256ValidatorTest:test_eip712() (gas: 15887) -P256ValidatorTest:test_enable_then_mode_1() (gas: 1360868) +P256ValidatorTest:test_enable_then_mode_1() (gas: 1364924) P256ValidatorTest:test_external_call_batch_execute_fail() (gas: 25023) P256ValidatorTest:test_external_call_batch_execute_success() (gas: 0) P256ValidatorTest:test_external_call_default() (gas: 0) @@ -163,27 +163,27 @@ P256ValidatorTest:test_external_call_execute_fail() (gas: 21191) P256ValidatorTest:test_external_call_execute_success() (gas: 0) P256ValidatorTest:test_external_call_execution() (gas: 0) P256ValidatorTest:test_fail_validate_not_activate() (gas: 304359) -P256ValidatorTest:test_fail_validate_wrongsignature() (gas: 744317) +P256ValidatorTest:test_fail_validate_wrongsignature() (gas: 746185) P256ValidatorTest:test_get_nonce() (gas: 25621) P256ValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 20090, ~: 20090) P256ValidatorTest:test_initialize() (gas: 178621) P256ValidatorTest:test_initialize_twice() (gas: 20756) -P256ValidatorTest:test_mode_2() (gas: 1303432) -P256ValidatorTest:test_revert_when_mode_disabled() (gas: 903399) -P256ValidatorTest:test_set_default_validator() (gas: 1117938) -P256ValidatorTest:test_set_execution() (gas: 1178075) +P256ValidatorTest:test_mode_2() (gas: 1307169) +P256ValidatorTest:test_revert_when_mode_disabled() (gas: 905172) +P256ValidatorTest:test_set_default_validator() (gas: 1119469) +P256ValidatorTest:test_set_execution() (gas: 1179926) P256ValidatorTest:test_should_emit_event_on_receive() (gas: 23390) P256ValidatorTest:test_should_receive_erc1155() (gas: 700421) P256ValidatorTest:test_should_receive_erc1155_batch() (gas: 727681) P256ValidatorTest:test_should_receive_erc721() (gas: 597618) P256ValidatorTest:test_should_return_address_if_deployed() (gas: 24455) -P256ValidatorTest:test_sudo() (gas: 885393) -P256ValidatorTest:test_sudo_wrongSig() (gas: 819294) +P256ValidatorTest:test_sudo() (gas: 887230) +P256ValidatorTest:test_sudo_wrongSig() (gas: 821017) P256ValidatorTest:test_upgrade() (gas: 21621) -P256ValidatorTest:test_utils(uint256,bytes32) (runs: 1024, μ: 1254189, ~: 1142801) +P256ValidatorTest:test_utils(uint256,bytes32) (runs: 1024, μ: 1260644, ~: 1146785) P256ValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27324) P256ValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23656) -P256ValidatorTest:test_validate_signature() (gas: 1270000) +P256ValidatorTest:test_validate_signature() (gas: 1271501) SessionKeyValidatorTest:test_default_validator_disable() (gas: 180670) SessionKeyValidatorTest:test_default_validator_enable() (gas: 188140) SessionKeyValidatorTest:test_disable_mode() (gas: 183150) @@ -267,39 +267,39 @@ TestERC721:test_ignore() (gas: 399) TestExecutor:test_ignore() (gas: 130) TestPaymaster:test_ignore() (gas: 174) TestValidator:test_ignore() (gas: 351) -WebAuthnValidatorTest:test_default_validator_disable() (gas: 916823) -WebAuthnValidatorTest:test_default_validator_enable() (gas: 931392) -WebAuthnValidatorTest:test_disable_mode() (gas: 932340) -WebAuthnValidatorTest:test_eip712() (gas: 15909) -WebAuthnValidatorTest:test_enable_then_mode_1() (gas: 1376207) -WebAuthnValidatorTest:test_external_call_batch_execute_fail() (gas: 25023) -WebAuthnValidatorTest:test_external_call_batch_execute_success() (gas: 0) -WebAuthnValidatorTest:test_external_call_default() (gas: 0) -WebAuthnValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 0) -WebAuthnValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 21901) -WebAuthnValidatorTest:test_external_call_execute_delegatecall_success() (gas: 0) -WebAuthnValidatorTest:test_external_call_execute_fail() (gas: 21191) -WebAuthnValidatorTest:test_external_call_execute_success() (gas: 0) -WebAuthnValidatorTest:test_external_call_execution() (gas: 0) -WebAuthnValidatorTest:test_fail_validate_not_activate() (gas: 304359) -WebAuthnValidatorTest:test_fail_validate_wrongsignature() (gas: 712714) -WebAuthnValidatorTest:test_get_nonce() (gas: 25621) -WebAuthnValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 20112, ~: 20112) -WebAuthnValidatorTest:test_initialize() (gas: 178435) -WebAuthnValidatorTest:test_initialize_twice() (gas: 20756) -WebAuthnValidatorTest:test_mode_2() (gas: 1359325) -WebAuthnValidatorTest:test_revert_when_mode_disabled() (gas: 949359) -WebAuthnValidatorTest:test_set_default_validator() (gas: 1164365) -WebAuthnValidatorTest:test_set_execution() (gas: 1223050) -WebAuthnValidatorTest:test_should_emit_event_on_receive() (gas: 23390) -WebAuthnValidatorTest:test_should_receive_erc1155() (gas: 700443) -WebAuthnValidatorTest:test_should_receive_erc1155_batch() (gas: 727703) -WebAuthnValidatorTest:test_should_receive_erc721() (gas: 597618) -WebAuthnValidatorTest:test_should_return_address_if_deployed() (gas: 24455) -WebAuthnValidatorTest:test_sudo() (gas: 945312) -WebAuthnValidatorTest:test_sudo_wrongSig() (gas: 856703) -WebAuthnValidatorTest:test_upgrade() (gas: 21621) -WebAuthnValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27324) -WebAuthnValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23656) -WebAuthnValidatorTest:test_validate_signature() (gas: 1302014) -WebAuthnValidatorTest:test_webAuthnSignatureGeneration(bytes32,uint256) (runs: 1024, μ: 1301771, ~: 1192892) \ No newline at end of file +WebAuthnFclValidatorTest:test_default_validator_disable() (gas: 922050) +WebAuthnFclValidatorTest:test_default_validator_enable() (gas: 948429) +WebAuthnFclValidatorTest:test_disable_mode() (gas: 936646) +WebAuthnFclValidatorTest:test_eip712() (gas: 15909) +WebAuthnFclValidatorTest:test_enable_then_mode_1() (gas: 1395135) +WebAuthnFclValidatorTest:test_external_call_batch_execute_fail() (gas: 25038) +WebAuthnFclValidatorTest:test_external_call_batch_execute_success() (gas: 0) +WebAuthnFclValidatorTest:test_external_call_default() (gas: 0) +WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 0) +WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 21916) +WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_success() (gas: 0) +WebAuthnFclValidatorTest:test_external_call_execute_fail() (gas: 21206) +WebAuthnFclValidatorTest:test_external_call_execute_success() (gas: 0) +WebAuthnFclValidatorTest:test_external_call_execution() (gas: 0) +WebAuthnFclValidatorTest:test_fail_validate_not_activate() (gas: 304359) +WebAuthnFclValidatorTest:test_fail_validate_wrongsignature() (gas: 0) +WebAuthnFclValidatorTest:test_get_nonce() (gas: 25621) +WebAuthnFclValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 20112, ~: 20112) +WebAuthnFclValidatorTest:test_initialize() (gas: 178470) +WebAuthnFclValidatorTest:test_initialize_twice() (gas: 20756) +WebAuthnFclValidatorTest:test_mode_2() (gas: 1355456) +WebAuthnFclValidatorTest:test_revert_when_mode_disabled() (gas: 953667) +WebAuthnFclValidatorTest:test_set_default_validator() (gas: 1168608) +WebAuthnFclValidatorTest:test_set_execution() (gas: 1237051) +WebAuthnFclValidatorTest:test_should_emit_event_on_receive() (gas: 23390) +WebAuthnFclValidatorTest:test_should_receive_erc1155() (gas: 700443) +WebAuthnFclValidatorTest:test_should_receive_erc1155_batch() (gas: 727703) +WebAuthnFclValidatorTest:test_should_receive_erc721() (gas: 597618) +WebAuthnFclValidatorTest:test_should_return_address_if_deployed() (gas: 24455) +WebAuthnFclValidatorTest:test_sudo() (gas: 937269) +WebAuthnFclValidatorTest:test_sudo_wrongSig() (gas: 872306) +WebAuthnFclValidatorTest:test_upgrade() (gas: 21621) +WebAuthnFclValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27324) +WebAuthnFclValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23656) +WebAuthnFclValidatorTest:test_validate_signature() (gas: 0) +WebAuthnFclValidatorTest:test_webAuthnSignatureGeneration(bytes32,uint256) (runs: 1024, μ: 1328833, ~: 1245541) \ No newline at end of file diff --git a/scripts/DeployWebAuthnValidator.s.sol b/scripts/DeployWebAuthnValidator.s.sol index e1f590b4..63a3173a 100644 --- a/scripts/DeployWebAuthnValidator.s.sol +++ b/scripts/DeployWebAuthnValidator.s.sol @@ -1,6 +1,7 @@ pragma solidity ^0.8.0; import "src/factory/KernelFactory.sol"; +import "src/utils/P256VerifierWrapper.sol"; import "src/validator/WebAuthnValidator.sol"; import "forge-std/Script.sol"; import "forge-std/console.sol"; @@ -9,8 +10,11 @@ contract DeployWebAuthnValidator is Script { function run() public { uint256 key = vm.envUint("DEPLOYER_PRIVATE_KEY"); vm.startBroadcast(key); + + P256VerifierWrapper p256VerifierWrapper = new P256VerifierWrapper{salt:0}(); + console.log("p256 wrapper address: %s", address(p256VerifierWrapper)); - WebAuthnValidator validator = new WebAuthnValidator{salt:0}(); + WebAuthnValidator validator = new WebAuthnValidator{salt:0}(address(p256VerifierWrapper)); console.log("validator address: %s", address(validator)); vm.stopBroadcast(); diff --git a/src/utils/P256VerifierWrapper.sol b/src/utils/P256VerifierWrapper.sol new file mode 100644 index 00000000..bc6340ac --- /dev/null +++ b/src/utils/P256VerifierWrapper.sol @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {FCL_ecdsa} from "FreshCryptoLib/FCL_ecdsa.sol"; + +/// @title P256VerifierWrapper +/// @author rdubois-crypto +/// @author KONFeature +/// @notice Wrapper arround the P256Verifier contract of @rdubois-crypto, using it to accept EIP-7212 compliant verification (p256 pre-compiled curve) +/// @dev This lib is only a wrapper around the P256Verifier contract. +/// It will call the verifySignature function of the P256Verifier contract. +/// Once the RIP-7212 will be deployed and effective, this contract will be useless. +/// Tracker on polygon: PR: https://github.com/maticnetwork/bor/pull/1069 +/// Now waiting on the Napoli hardfork to be deployed +contract P256VerifierWrapper { + /** + * Precompiles don't use a function signature. The first byte of callldata + * is the first byte of an input argument. In this case: + * + * input[ 0: 32] = signed data hash + * input[ 32: 64] = signature r + * input[ 64: 96] = signature s + * input[ 96:128] = public key x + * input[128:160] = public key y + * + * result[ 0: 32] = 0x00..00 (invalid) or 0x00..01 (valid) + * + * For details, see https://eips.ethereum.org/EIPS/eip-7212 + */ + fallback(bytes calldata input) external returns (bytes memory) { + if (input.length != 160) { + return abi.encodePacked(uint256(0)); + } + + bytes32 hash = bytes32(input[0:32]); + uint256 r = uint256(bytes32(input[32:64])); + uint256 s = uint256(bytes32(input[64:96])); + uint256 x = uint256(bytes32(input[96:128])); + uint256 y = uint256(bytes32(input[128:160])); + + uint256 ret = FCL_ecdsa.ecdsa_verify(hash, r, s, x, y) ? 1 : 0; + + return abi.encodePacked(ret); + } +} diff --git a/src/utils/WebAuthnFclVerifier.sol b/src/utils/WebAuthnFclVerifier.sol new file mode 100644 index 00000000..e6d1bd90 --- /dev/null +++ b/src/utils/WebAuthnFclVerifier.sol @@ -0,0 +1,133 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {Base64Url} from "FreshCryptoLib/utils/Base64Url.sol"; + +/// @title WebAuthnFclVerifier +/// @author rdubois-crypto +/// @author obatirou +/// @author KONFeature +/// @notice A library used to format webauthn stuff into verifiable p256 messages msg +/// From https://github.com/cometh-hq/p256-signer/blob/09319213276da69aad6d96fa75cd339726f78bb9/contracts/P256Signer.sol +/// And https://github.com/rdubois-crypto/FreshCryptoLib/blob/master/solidity/src/FCL_Webauthn.sol +library WebAuthnFclVerifier { + /// @dev Error thrown when the webauthn data is invalid + error InvalidWebAuthNData(); + + /// @dev the data flag mask we will use to verify the signature + /// @dev Always 0x01 for user presence flag -> https://www.w3.org/TR/webauthn-2/#concept-user-present + bytes1 private constant AUTHENTICATOR_DATA_FLAG_MASK = 0x01; + + /// @dev layout of a signature (used to extract the reauired payload from the initial calldata) + struct FclSignatureLayout { + bytes authenticatorData; + bytes clientData; + uint256 challengeOffset; + uint256[2] rs; + } + + /// @dev Extract the signature from the calldata + function _extractWebAuthnSignature(bytes calldata _signature) internal pure returns (FclSignatureLayout calldata) { + FclSignatureLayout calldata signaturePointer; + // This code should precalculate the offsets of variables as defined in the layout + // From: https://twitter.com/k06a/status/1706934230779883656 + assembly { + signaturePointer := _signature.offset + } + return signaturePointer; + } + + /// @dev Format the webauthn challenge into a p256 message + /// @dev return the raw message that has been signed by the user on the p256 curve + /// @dev Logic from https://github.com/rdubois-crypto/FreshCryptoLib/blob/master/solidity/src/FCL_Webauthn.sol + /// @param _hash The hash that has been signed via WebAuthN + /// @param _signature The signature that has been provided with the userOp + /// @return p256Message The message that has been signed on the p256 curve + function _formatWebAuthNChallenge(bytes32 _hash, FclSignatureLayout calldata _signature) + internal + pure + returns (bytes32 p256Message) + { + // Extract a few calldata pointer we will use to format / verify our msg + bytes calldata authenticatorData = _signature.authenticatorData; + bytes calldata clientData = _signature.clientData; + uint256 challengeOffset = _signature.challengeOffset; + + // If the challenge offset is uint256 max, it's mean that we are in the case of a dummy sig, so we can skip the check and just return the hash + if (challengeOffset == type(uint256).max) { + return _hash; + } + + // Otherwise, perform the complete format and checks of the data + { + // Let the caller check if User Presence (0x01) or User Verification (0x04) are set + if ((authenticatorData[32] & AUTHENTICATOR_DATA_FLAG_MASK) != AUTHENTICATOR_DATA_FLAG_MASK) { + revert InvalidWebAuthNData(); + } + // Verify that clientData commits to the expected client challenge + // Use the Base64Url encoding which omits padding characters to match WebAuthn Specification + string memory challengeEncoded = Base64Url.encode(abi.encodePacked(_hash)); + bytes memory challengeExtracted = new bytes(bytes(challengeEncoded).length); + + assembly { + calldatacopy( + add(challengeExtracted, 32), add(clientData.offset, challengeOffset), mload(challengeExtracted) + ) + } + + bytes32 moreData; //=keccak256(abi.encodePacked(challengeExtracted)); + assembly { + moreData := keccak256(add(challengeExtracted, 32), mload(challengeExtracted)) + } + + if (keccak256(abi.encodePacked(bytes(challengeEncoded))) != moreData) { + revert InvalidWebAuthNData(); + } + } //avoid stack full + + // Verify the signature over sha256(authenticatorData || sha256(clientData)) + bytes memory verifyData = new bytes(authenticatorData.length + 32); + + assembly { + calldatacopy(add(verifyData, 32), authenticatorData.offset, authenticatorData.length) + } + + bytes32 more = sha256(clientData); + assembly { + mstore(add(verifyData, add(authenticatorData.length, 32)), more) + } + + return sha256(verifyData); + } + + /// @dev Proceed to the full webauth verification + /// @param _p256Verifier The p256 verifier contract + /// @param _hash The hash that has been signed via WebAuthN + /// @param _signature The signature that has been provided with the userOp + /// @param _x The X point of the public key + /// @param _y The Y point of the public key + /// @return isValid True if the signature is valid, false otherwise + function _verifyWebAuthNSignature( + address _p256Verifier, + bytes32 _hash, + bytes calldata _signature, + uint256 _x, + uint256 _y + ) internal view returns (bool isValid) { + // Extract the signature + FclSignatureLayout calldata signature = _extractWebAuthnSignature(_signature); + + // Format the webauthn challenge into a p256 message + bytes32 challenge = _formatWebAuthNChallenge(_hash, signature); + + // Prepare the argument we will use to verify the signature + bytes memory args = abi.encode(challenge, signature.rs[0], signature.rs[1], _x, _y); + + // Send the call the the p256 verifier + (bool success, bytes memory ret) = _p256Verifier.staticcall(args); + assert(success); // never reverts, always returns 0 or 1 + + // Ensure that it has returned 1 + return abi.decode(ret, (uint256)) == 1; + } +} diff --git a/src/utils/WebAuthnWrapper.sol b/src/utils/WebAuthnWrapper.sol deleted file mode 100644 index 614f18b8..00000000 --- a/src/utils/WebAuthnWrapper.sol +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {FCL_ecdsa_utils} from "FreshCryptoLib/FCL_ecdsa_utils.sol"; -import {Base64Url} from "FreshCryptoLib/utils/Base64Url.sol"; - -/// @title WebAuthnWrapper -/// @author rdubois-crypto -/// @author obatirou -/// @author KONFeature -/// @notice A library used to verify ECDSA signatures over secp256r1 through -/// EIP-1271 of Webauthn payloads. -/// From https://github.com/cometh-game/p256-signer/blob/main/contracts/FCL/WrapperFCLWebAuthn.sol -/// And https://github.com/rdubois-crypto/FreshCryptoLib/blob/master/solidity/src/FCL_Webauthn.sol -/// @dev This lib is only a wrapper around the FCL_WebAuthn library. -/// It is meant to be used with 1271 signatures. -/// The wrapping is necessary because the FCL_WebAuthn has only internal -/// functions and use calldata. This makes it impossible to use it with -/// isValidSignature that use memory. -/// It's also needed to prevent all the early exit, and so making it -/// impossible to have a precise gas estimation for the verification phase. -library WebAuthnWrapper { - /// @dev Check the validity of a signature - function checkSignature( - bytes calldata authenticatorData, - bytes1 authenticatorDataFlagMask, - bytes calldata clientData, - bytes32 clientChallenge, - uint256 clientChallengeDataOffset, - uint256[2] calldata rs, - uint256[2] calldata xy - ) external view returns (bool) { - // Format the msg signed via the p256 curve - bytes32 message = formatWebAuthNChallenge( - authenticatorData, authenticatorDataFlagMask, clientData, clientChallenge, clientChallengeDataOffset - ); - - // Perform the verification - return FCL_ecdsa_utils.ecdsa_verify(message, rs, xy); - } - - /// @dev Format a web auth n message, return the challenge that has been signed by the user - function formatWebAuthNChallenge( - bytes calldata authenticatorData, - bytes1 authenticatorDataFlagMask, - bytes calldata clientData, - bytes32 clientChallenge, - uint256 clientChallengeDataOffset - ) public pure returns (bytes32) { - // Let the caller check if User Presence (0x01) or User Verification (0x04) are set - { - if ((authenticatorData[32] & authenticatorDataFlagMask) != authenticatorDataFlagMask) { - // TODO: Cleanup that stuff until we are aable to generate offchain dummy sig that pass that verification - return 0; - } - // Verify that clientData commits to the expected client challenge - // Use the Base64Url encoding which omits padding characters to match WebAuthn Specification - string memory challengeEncoded = Base64Url.encode(abi.encodePacked(clientChallenge)); - bytes memory challengeExtracted = new bytes(bytes(challengeEncoded).length); - - assembly { - calldatacopy( - add(challengeExtracted, 32), - add(clientData.offset, clientChallengeDataOffset), - mload(challengeExtracted) - ) - } - - bytes32 moreData; //=keccak256(abi.encodePacked(challengeExtracted)); - assembly { - moreData := keccak256(add(challengeExtracted, 32), mload(challengeExtracted)) - } - - if (keccak256(abi.encodePacked(bytes(challengeEncoded))) != moreData) { - // TODO: Cleanup that stuff until we are aable to generate offchain dummy sig that pass that verification - return 0; - } - } //avoid stack full - - // Verify the signature over sha256(authenticatorData || sha256(clientData)) - bytes memory verifyData = new bytes(authenticatorData.length + 32); - - assembly { - calldatacopy(add(verifyData, 32), authenticatorData.offset, authenticatorData.length) - } - - bytes32 more = sha256(clientData); - assembly { - mstore(add(verifyData, add(authenticatorData.length, 32)), more) - } - - return sha256(verifyData); - } -} diff --git a/src/validator/WebAuthnFclValidator.sol b/src/validator/WebAuthnFclValidator.sol index 846978a1..2e50a348 100644 --- a/src/validator/WebAuthnFclValidator.sol +++ b/src/validator/WebAuthnFclValidator.sol @@ -6,7 +6,7 @@ import {ECDSA} from "solady/utils/ECDSA.sol"; import {IKernelValidator} from "../interfaces/IKernelValidator.sol"; import {ValidationData} from "../common/Types.sol"; import {SIG_VALIDATION_FAILED} from "../common/Constants.sol"; -import {WebAuthnWrapper} from "../utils/WebAuthnWrapper.sol"; +import {WebAuthnFclVerifier} from "../utils/WebAuthnFclVerifier.sol"; /// @dev Storage layout for a kernel in the WebAuthnValidator contract. struct WebAuthnFclValidatorStorage { @@ -28,6 +28,14 @@ contract WebAuthnFclValidator is IKernelValidator { /// @dev Mapping of kernel address to each webAuthn specific storage mapping(address kernel => WebAuthnFclValidatorStorage webAuthnStorage) private webAuthnValidatorStorage; + /// @dev The address of the p256 verifier contract (should be 0x100 on the RIP-7212 compliant chains) + address public immutable P256_VERIFIER; + + /// @dev Simple constructor, setting the P256 verifier address + constructor(address _p256Verifier) { + P256_VERIFIER = _p256Verifier; + } + /// @dev Disable this validator for a given `kernel` (msg.sender) function disable(bytes calldata) external payable override { delete webAuthnValidatorStorage[msg.sender]; @@ -87,26 +95,15 @@ contract WebAuthnFclValidator is IKernelValidator { function _checkSignature( WebAuthnFclValidatorStorage memory _kernelValidatorStorage, bytes32 _hash, - bytes memory _signature + bytes calldata _signature ) private view returns (bool isValid) { - // Decode the signature - (bytes memory authenticatorData, bytes memory clientData, uint256 challengeOffset, uint256[2] memory rs) = - abi.decode(_signature, (bytes, bytes, uint256, uint256[2])); - - // Verify the signature - try WebAuthnWrapper.checkSignature( - authenticatorData, - 0x01, - clientData, + return WebAuthnFclVerifier._verifyWebAuthNSignature( + P256_VERIFIER, _hash, - challengeOffset, - rs, - [_kernelValidatorStorage.x, _kernelValidatorStorage.y] - ) returns (bool _result) { - isValid = _result; - } catch { - isValid = false; - } + _signature, + _kernelValidatorStorage.x, + _kernelValidatorStorage.y + ); } /// @dev Check if the caller is a valid signer, this don't apply to the WebAuthN validator, since it's using a public key diff --git a/test/foundry/validator/WebAuthnFclValidator.t.sol b/test/foundry/validator/WebAuthnFclValidator.t.sol index 7780b70e..024a0297 100644 --- a/test/foundry/validator/WebAuthnFclValidator.t.sol +++ b/test/foundry/validator/WebAuthnFclValidator.t.sol @@ -9,7 +9,8 @@ import {KernelTestBase} from "../KernelTestBase.sol"; import {TestExecutor} from "../mock/TestExecutor.sol"; import {TestValidator} from "../mock/TestValidator.sol"; import {P256Validator} from "src/validator/P256Validator.sol"; -import {WebAuthnWrapper} from "src/utils/WebAuthnWrapper.sol"; +import {WebAuthnFclVerifier} from "src/utils/WebAuthnFclVerifier.sol"; +import {P256VerifierWrapper} from "src/utils/P256VerifierWrapper.sol"; import {WebAuthnFclValidator} from "src/validator/WebAuthnFclValidator.sol"; import {P256} from "p256-verifier/P256.sol"; import {FCL_ecdsa_utils} from "FreshCryptoLib/FCL_ecdsa_utils.sol"; @@ -18,8 +19,16 @@ import {IKernel} from "src/interfaces/IKernel.sol"; using ERC4337Utils for IEntryPoint; +/* +TODO: + - Figure out why the msg signature fail? Maybe pre hashing stuff missed out? + - Add a test case arround the dummy signature bypass + +*/ contract WebAuthnFclValidatorTest is KernelTestBase { WebAuthnFclValidator webAuthNValidator; + WebAuthNTester webAuthNTester; + P256VerifierWrapper p256VerifierWrapper; // Curve order (number of points) uint256 constant n = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551; @@ -29,7 +38,13 @@ contract WebAuthnFclValidatorTest is KernelTestBase { uint256 y; function setUp() public { - webAuthNValidator = new WebAuthnFclValidator(); + // Deploy a RIP-7212 compliant P256Verifier contract + p256VerifierWrapper = new P256VerifierWrapper(); + // Deploy a WebAuthnFclValidator contract using that RIP-7212 compliant P256Verifier contract + webAuthNValidator = new WebAuthnFclValidator(address(p256VerifierWrapper)); + + // Deploy a webAuthNTester that will be used to format the signature during test + webAuthNTester = new WebAuthNTester(); _initialize(); (x, y) = _getPublicKey(ownerKey); @@ -118,6 +133,9 @@ contract WebAuthnFclValidatorTest is KernelTestBase { } function test_validate_signature() external override { + vm.skip(true); + // TODO: Find out why it's bugy + Kernel kernel2 = Kernel(payable(factory.createAccount(address(kernelImpl), getInitializeData(), 3))); bytes32 _hash = keccak256(abi.encodePacked("hello world")); @@ -134,6 +152,8 @@ contract WebAuthnFclValidatorTest is KernelTestBase { } function test_fail_validate_wrongsignature() external override { + vm.skip(true); + // TODO: Find out why it's bugy bytes32 hash = keccak256(abi.encodePacked("hello world")); bytes memory sig = getWrongSignature(hash); assertEq(kernel.isValidSignature(hash, sig), bytes4(0xffffffff)); @@ -169,16 +189,11 @@ contract WebAuthnFclValidatorTest is KernelTestBase { vm.assume(_privateKey > 0); (uint256 pubX, uint256 pubY) = _getPublicKey(_privateKey); - // The public key we will use - uint256[2] memory pubKey = [pubX, pubY]; - // Build all the data required ( bytes32 msgToSign, bytes memory authenticatorData, - bytes1 authenticatorDataFlagMask, bytes memory clientData, - bytes32 clientChallenge, uint256 clientChallengeDataOffset ) = _prepapreWebAuthnMsg(_hash); @@ -186,16 +201,12 @@ contract WebAuthnFclValidatorTest is KernelTestBase { (uint256 r, uint256 s) = _getP256Signature(_privateKey, msgToSign); uint256[2] memory rs = [r, s]; + // Encode all of that into a signature + bytes memory signature = abi.encode(authenticatorData, clientData, clientChallengeDataOffset, rs); + // Ensure the signature is valid - bool isValid = WebAuthnWrapper.checkSignature( - authenticatorData, - authenticatorDataFlagMask, - clientData, - clientChallenge, - clientChallengeDataOffset, - rs, - pubKey - ); + bool isValid = webAuthNTester.verifySignature(address(p256VerifierWrapper), _hash, signature, pubX, pubY); + assertEq(isValid, true); } @@ -212,9 +223,7 @@ contract WebAuthnFclValidatorTest is KernelTestBase { ( bytes32 msgToSign, bytes memory authenticatorData, - , bytes memory clientData, - , uint256 clientChallengeDataOffset ) = _prepapreWebAuthnMsg(_hash); @@ -229,18 +238,16 @@ contract WebAuthnFclValidatorTest is KernelTestBase { /// @dev Prepare all the base data needed to perform a webauthn signature o n the given `_hash` function _prepapreWebAuthnMsg(bytes32 _hash) internal - pure + view returns ( bytes32 msgToSign, bytes memory authenticatorData, - bytes1 authenticatorDataFlagMask, bytes memory clientData, - bytes32 clientChallenge, uint256 clientChallengeDataOffset ) { + // Base Mapping of the message - clientChallenge = _hash; bytes memory encodedChallenge = bytes(Base64Url.encode(abi.encodePacked(_hash))); // Prepare the authenticator data (from a real webauthn challenge) @@ -252,14 +259,18 @@ contract WebAuthnFclValidatorTest is KernelTestBase { hex"222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303032222c2263726f73734f726967696e223a66616c73657d"; clientData = bytes.concat(clientDataStart, encodedChallenge, clientDataEnd); clientChallengeDataOffset = 36; - - // Set the flag mask to 0x01 (User Presence) - authenticatorDataFlagMask = authenticatorData[32]; - - // Once we got all of our data, prepapre the msg to sign - msgToSign = WebAuthnWrapper.formatWebAuthNChallenge( - authenticatorData, authenticatorDataFlagMask, clientData, clientChallenge, clientChallengeDataOffset - ); + + // Build the signature layout + WebAuthnFclVerifier.FclSignatureLayout memory sigLayout = WebAuthnFclVerifier.FclSignatureLayout({ + authenticatorData: authenticatorData, + clientData: clientData, + challengeOffset: clientChallengeDataOffset, + // R/S not needed since the formatter will only use the other data + rs: [uint256(0), uint256(0)] + }); + + // Format it + msgToSign = webAuthNTester.formatSigLayout(_hash, sigLayout); } /// @dev Get a public key for a p256 user, from the given `_privateKey` @@ -286,3 +297,16 @@ contract WebAuthnFclValidatorTest is KernelTestBase { return (r, s); } } + +/// @dev simple contract to format a webauthn challenge (using to convert stuff in memory during test to calldata) +contract WebAuthNTester { + + function formatSigLayout(bytes32 _hash, WebAuthnFclVerifier.FclSignatureLayout calldata signatureLayout) public view returns (bytes32) { + console.log("hash: %d", uint256(_hash)); + return WebAuthnFclVerifier._formatWebAuthNChallenge(_hash, signatureLayout); + } + + function verifySignature(address _p256Verifier, bytes32 _hash, bytes calldata _signature, uint256 _x, uint256 _y) public view returns (bool) { + return WebAuthnFclVerifier._verifyWebAuthNSignature(_p256Verifier, _hash, _signature, _x, _y); + } +} \ No newline at end of file From fa469723e949352e9d92ba9fafd5a088ac3f263b Mon Sep 17 00:00:00 2001 From: KONFeature Date: Sat, 20 Jan 2024 21:21:58 +0100 Subject: [PATCH 07/12] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Minor=20gas=20optimi?= =?UTF-8?q?sation=20(switching=20to=20solady=20base64=20lib)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gas-snapshot | 22 ++++++------ src/utils/WebAuthnFclVerifier.sol | 26 ++++++-------- src/validator/WebAuthnFclValidator.sol | 7 ++-- .../validator/WebAuthnFclValidator.t.sol | 34 +++++++++---------- 4 files changed, 39 insertions(+), 50 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index c8fef026..84258bed 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -267,11 +267,11 @@ TestERC721:test_ignore() (gas: 399) TestExecutor:test_ignore() (gas: 130) TestPaymaster:test_ignore() (gas: 174) TestValidator:test_ignore() (gas: 351) -WebAuthnFclValidatorTest:test_default_validator_disable() (gas: 922050) -WebAuthnFclValidatorTest:test_default_validator_enable() (gas: 948429) -WebAuthnFclValidatorTest:test_disable_mode() (gas: 936646) +WebAuthnFclValidatorTest:test_default_validator_disable() (gas: 919270) +WebAuthnFclValidatorTest:test_default_validator_enable() (gas: 945649) +WebAuthnFclValidatorTest:test_disable_mode() (gas: 933866) WebAuthnFclValidatorTest:test_eip712() (gas: 15909) -WebAuthnFclValidatorTest:test_enable_then_mode_1() (gas: 1395135) +WebAuthnFclValidatorTest:test_enable_then_mode_1() (gas: 1390964) WebAuthnFclValidatorTest:test_external_call_batch_execute_fail() (gas: 25038) WebAuthnFclValidatorTest:test_external_call_batch_execute_success() (gas: 0) WebAuthnFclValidatorTest:test_external_call_default() (gas: 0) @@ -287,19 +287,19 @@ WebAuthnFclValidatorTest:test_get_nonce() (gas: 25621) WebAuthnFclValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 20112, ~: 20112) WebAuthnFclValidatorTest:test_initialize() (gas: 178470) WebAuthnFclValidatorTest:test_initialize_twice() (gas: 20756) -WebAuthnFclValidatorTest:test_mode_2() (gas: 1355456) -WebAuthnFclValidatorTest:test_revert_when_mode_disabled() (gas: 953667) -WebAuthnFclValidatorTest:test_set_default_validator() (gas: 1168608) -WebAuthnFclValidatorTest:test_set_execution() (gas: 1237051) +WebAuthnFclValidatorTest:test_mode_2() (gas: 1351285) +WebAuthnFclValidatorTest:test_revert_when_mode_disabled() (gas: 950887) +WebAuthnFclValidatorTest:test_set_default_validator() (gas: 1165828) +WebAuthnFclValidatorTest:test_set_execution() (gas: 1234271) WebAuthnFclValidatorTest:test_should_emit_event_on_receive() (gas: 23390) WebAuthnFclValidatorTest:test_should_receive_erc1155() (gas: 700443) WebAuthnFclValidatorTest:test_should_receive_erc1155_batch() (gas: 727703) WebAuthnFclValidatorTest:test_should_receive_erc721() (gas: 597618) WebAuthnFclValidatorTest:test_should_return_address_if_deployed() (gas: 24455) -WebAuthnFclValidatorTest:test_sudo() (gas: 937269) -WebAuthnFclValidatorTest:test_sudo_wrongSig() (gas: 872306) +WebAuthnFclValidatorTest:test_sudo() (gas: 934489) +WebAuthnFclValidatorTest:test_sudo_wrongSig() (gas: 869526) WebAuthnFclValidatorTest:test_upgrade() (gas: 21621) WebAuthnFclValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27324) WebAuthnFclValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23656) WebAuthnFclValidatorTest:test_validate_signature() (gas: 0) -WebAuthnFclValidatorTest:test_webAuthnSignatureGeneration(bytes32,uint256) (runs: 1024, μ: 1328833, ~: 1245541) \ No newline at end of file +WebAuthnFclValidatorTest:test_webAuthnSignatureGeneration(bytes32,uint256) (runs: 1024, μ: 1332004, ~: 1257557) \ No newline at end of file diff --git a/src/utils/WebAuthnFclVerifier.sol b/src/utils/WebAuthnFclVerifier.sol index e6d1bd90..ee59800d 100644 --- a/src/utils/WebAuthnFclVerifier.sol +++ b/src/utils/WebAuthnFclVerifier.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {Base64Url} from "FreshCryptoLib/utils/Base64Url.sol"; +import {Base64} from "solady/utils/Base64.sol"; /// @title WebAuthnFclVerifier /// @author rdubois-crypto @@ -26,17 +26,6 @@ library WebAuthnFclVerifier { uint256[2] rs; } - /// @dev Extract the signature from the calldata - function _extractWebAuthnSignature(bytes calldata _signature) internal pure returns (FclSignatureLayout calldata) { - FclSignatureLayout calldata signaturePointer; - // This code should precalculate the offsets of variables as defined in the layout - // From: https://twitter.com/k06a/status/1706934230779883656 - assembly { - signaturePointer := _signature.offset - } - return signaturePointer; - } - /// @dev Format the webauthn challenge into a p256 message /// @dev return the raw message that has been signed by the user on the p256 curve /// @dev Logic from https://github.com/rdubois-crypto/FreshCryptoLib/blob/master/solidity/src/FCL_Webauthn.sol @@ -66,8 +55,8 @@ library WebAuthnFclVerifier { } // Verify that clientData commits to the expected client challenge // Use the Base64Url encoding which omits padding characters to match WebAuthn Specification - string memory challengeEncoded = Base64Url.encode(abi.encodePacked(_hash)); - bytes memory challengeExtracted = new bytes(bytes(challengeEncoded).length); + bytes memory challengeEncoded = bytes(Base64.encode(abi.encodePacked(_hash), true, true)); + bytes memory challengeExtracted = new bytes(challengeEncoded.length); assembly { calldatacopy( @@ -80,7 +69,7 @@ library WebAuthnFclVerifier { moreData := keccak256(add(challengeExtracted, 32), mload(challengeExtracted)) } - if (keccak256(abi.encodePacked(bytes(challengeEncoded))) != moreData) { + if (keccak256(abi.encodePacked(challengeEncoded)) != moreData) { revert InvalidWebAuthNData(); } } //avoid stack full @@ -115,7 +104,12 @@ library WebAuthnFclVerifier { uint256 _y ) internal view returns (bool isValid) { // Extract the signature - FclSignatureLayout calldata signature = _extractWebAuthnSignature(_signature); + FclSignatureLayout calldata signature; + // This code should precalculate the offsets of variables as defined in the layout + // From: https://twitter.com/k06a/status/1706934230779883656 + assembly { + signature := _signature.offset + } // Format the webauthn challenge into a p256 message bytes32 challenge = _formatWebAuthNChallenge(_hash, signature); diff --git a/src/validator/WebAuthnFclValidator.sol b/src/validator/WebAuthnFclValidator.sol index 2e50a348..e360f222 100644 --- a/src/validator/WebAuthnFclValidator.sol +++ b/src/validator/WebAuthnFclValidator.sol @@ -29,6 +29,7 @@ contract WebAuthnFclValidator is IKernelValidator { mapping(address kernel => WebAuthnFclValidatorStorage webAuthnStorage) private webAuthnValidatorStorage; /// @dev The address of the p256 verifier contract (should be 0x100 on the RIP-7212 compliant chains) + /// @dev To follow up for the deployment: https://forum.polygon.technology/t/pip-27-precompiled-for-secp256r1-curve-support/13049 address public immutable P256_VERIFIER; /// @dev Simple constructor, setting the P256 verifier address @@ -98,11 +99,7 @@ contract WebAuthnFclValidator is IKernelValidator { bytes calldata _signature ) private view returns (bool isValid) { return WebAuthnFclVerifier._verifyWebAuthNSignature( - P256_VERIFIER, - _hash, - _signature, - _kernelValidatorStorage.x, - _kernelValidatorStorage.y + P256_VERIFIER, _hash, _signature, _kernelValidatorStorage.x, _kernelValidatorStorage.y ); } diff --git a/test/foundry/validator/WebAuthnFclValidator.t.sol b/test/foundry/validator/WebAuthnFclValidator.t.sol index 024a0297..218dbb46 100644 --- a/test/foundry/validator/WebAuthnFclValidator.t.sol +++ b/test/foundry/validator/WebAuthnFclValidator.t.sol @@ -190,12 +190,8 @@ contract WebAuthnFclValidatorTest is KernelTestBase { (uint256 pubX, uint256 pubY) = _getPublicKey(_privateKey); // Build all the data required - ( - bytes32 msgToSign, - bytes memory authenticatorData, - bytes memory clientData, - uint256 clientChallengeDataOffset - ) = _prepapreWebAuthnMsg(_hash); + (bytes32 msgToSign, bytes memory authenticatorData, bytes memory clientData, uint256 clientChallengeDataOffset) + = _prepapreWebAuthnMsg(_hash); // Then sign them (uint256 r, uint256 s) = _getP256Signature(_privateKey, msgToSign); @@ -220,12 +216,8 @@ contract WebAuthnFclValidatorTest is KernelTestBase { view returns (bytes memory signature) { - ( - bytes32 msgToSign, - bytes memory authenticatorData, - bytes memory clientData, - uint256 clientChallengeDataOffset - ) = _prepapreWebAuthnMsg(_hash); + (bytes32 msgToSign, bytes memory authenticatorData, bytes memory clientData, uint256 clientChallengeDataOffset) + = _prepapreWebAuthnMsg(_hash); // Get the signature (uint256 r, uint256 s) = _getP256Signature(_privateKey, msgToSign); @@ -246,7 +238,6 @@ contract WebAuthnFclValidatorTest is KernelTestBase { uint256 clientChallengeDataOffset ) { - // Base Mapping of the message bytes memory encodedChallenge = bytes(Base64Url.encode(abi.encodePacked(_hash))); @@ -259,7 +250,7 @@ contract WebAuthnFclValidatorTest is KernelTestBase { hex"222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303032222c2263726f73734f726967696e223a66616c73657d"; clientData = bytes.concat(clientDataStart, encodedChallenge, clientDataEnd); clientChallengeDataOffset = 36; - + // Build the signature layout WebAuthnFclVerifier.FclSignatureLayout memory sigLayout = WebAuthnFclVerifier.FclSignatureLayout({ authenticatorData: authenticatorData, @@ -300,13 +291,20 @@ contract WebAuthnFclValidatorTest is KernelTestBase { /// @dev simple contract to format a webauthn challenge (using to convert stuff in memory during test to calldata) contract WebAuthNTester { - - function formatSigLayout(bytes32 _hash, WebAuthnFclVerifier.FclSignatureLayout calldata signatureLayout) public view returns (bytes32) { + function formatSigLayout(bytes32 _hash, WebAuthnFclVerifier.FclSignatureLayout calldata signatureLayout) + public + view + returns (bytes32) + { console.log("hash: %d", uint256(_hash)); return WebAuthnFclVerifier._formatWebAuthNChallenge(_hash, signatureLayout); } - function verifySignature(address _p256Verifier, bytes32 _hash, bytes calldata _signature, uint256 _x, uint256 _y) public view returns (bool) { + function verifySignature(address _p256Verifier, bytes32 _hash, bytes calldata _signature, uint256 _x, uint256 _y) + public + view + returns (bool) + { return WebAuthnFclVerifier._verifyWebAuthNSignature(_p256Verifier, _hash, _signature, _x, _y); } -} \ No newline at end of file +} From 8886a16fbde9ca361c121aaaa4d5b1fe10103e83 Mon Sep 17 00:00:00 2001 From: KONFeature Date: Sat, 20 Jan 2024 23:02:58 +0100 Subject: [PATCH 08/12] =?UTF-8?q?=E2=9C=85=20Add=20more=20tests=20on=20sig?= =?UTF-8?q?=20validation,=20dummy=20sig=20bypass=20etc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gas-snapshot | 54 ++++++------ .../validator/WebAuthnFclValidator.t.sol | 84 +++++++++++++------ 2 files changed, 88 insertions(+), 50 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 84258bed..21bb9181 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -267,39 +267,41 @@ TestERC721:test_ignore() (gas: 399) TestExecutor:test_ignore() (gas: 130) TestPaymaster:test_ignore() (gas: 174) TestValidator:test_ignore() (gas: 351) -WebAuthnFclValidatorTest:test_default_validator_disable() (gas: 919270) -WebAuthnFclValidatorTest:test_default_validator_enable() (gas: 945649) -WebAuthnFclValidatorTest:test_disable_mode() (gas: 933866) -WebAuthnFclValidatorTest:test_eip712() (gas: 15909) -WebAuthnFclValidatorTest:test_enable_then_mode_1() (gas: 1390964) -WebAuthnFclValidatorTest:test_external_call_batch_execute_fail() (gas: 25038) +WebAuthnFclValidatorTest:test_default_validator_disable() (gas: 920694) +WebAuthnFclValidatorTest:test_default_validator_enable() (gas: 947073) +WebAuthnFclValidatorTest:test_disable_mode() (gas: 935320) +WebAuthnFclValidatorTest:test_dontRevertForDummySig() (gas: 32678) +WebAuthnFclValidatorTest:test_eip712() (gas: 15931) +WebAuthnFclValidatorTest:test_enable_then_mode_1() (gas: 1393815) +WebAuthnFclValidatorTest:test_external_call_batch_execute_fail() (gas: 25060) WebAuthnFclValidatorTest:test_external_call_batch_execute_success() (gas: 0) WebAuthnFclValidatorTest:test_external_call_default() (gas: 0) WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 0) -WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 21916) +WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 21960) WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_success() (gas: 0) WebAuthnFclValidatorTest:test_external_call_execute_fail() (gas: 21206) WebAuthnFclValidatorTest:test_external_call_execute_success() (gas: 0) WebAuthnFclValidatorTest:test_external_call_execution() (gas: 0) -WebAuthnFclValidatorTest:test_fail_validate_not_activate() (gas: 304359) -WebAuthnFclValidatorTest:test_fail_validate_wrongsignature() (gas: 0) +WebAuthnFclValidatorTest:test_fail_validate_InvalidWebAuthnData() (gas: 399162) +WebAuthnFclValidatorTest:test_fail_validate_not_activate() (gas: 304402) +WebAuthnFclValidatorTest:test_fail_validate_wrongsignature() (gas: 794693) WebAuthnFclValidatorTest:test_get_nonce() (gas: 25621) -WebAuthnFclValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 20112, ~: 20112) -WebAuthnFclValidatorTest:test_initialize() (gas: 178470) -WebAuthnFclValidatorTest:test_initialize_twice() (gas: 20756) -WebAuthnFclValidatorTest:test_mode_2() (gas: 1351285) -WebAuthnFclValidatorTest:test_revert_when_mode_disabled() (gas: 950887) -WebAuthnFclValidatorTest:test_set_default_validator() (gas: 1165828) -WebAuthnFclValidatorTest:test_set_execution() (gas: 1234271) -WebAuthnFclValidatorTest:test_should_emit_event_on_receive() (gas: 23390) -WebAuthnFclValidatorTest:test_should_receive_erc1155() (gas: 700443) -WebAuthnFclValidatorTest:test_should_receive_erc1155_batch() (gas: 727703) -WebAuthnFclValidatorTest:test_should_receive_erc721() (gas: 597618) -WebAuthnFclValidatorTest:test_should_return_address_if_deployed() (gas: 24455) -WebAuthnFclValidatorTest:test_sudo() (gas: 934489) -WebAuthnFclValidatorTest:test_sudo_wrongSig() (gas: 869526) +WebAuthnFclValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 20134, ~: 20134) +WebAuthnFclValidatorTest:test_initialize() (gas: 178492) +WebAuthnFclValidatorTest:test_initialize_twice() (gas: 20805) +WebAuthnFclValidatorTest:test_mode_2() (gas: 1354171) +WebAuthnFclValidatorTest:test_revert_when_mode_disabled() (gas: 952319) +WebAuthnFclValidatorTest:test_set_default_validator() (gas: 1167256) +WebAuthnFclValidatorTest:test_set_execution() (gas: 1235698) +WebAuthnFclValidatorTest:test_should_emit_event_on_receive() (gas: 23434) +WebAuthnFclValidatorTest:test_should_receive_erc1155() (gas: 700465) +WebAuthnFclValidatorTest:test_should_receive_erc1155_batch() (gas: 727725) +WebAuthnFclValidatorTest:test_should_receive_erc721() (gas: 597640) +WebAuthnFclValidatorTest:test_should_return_address_if_deployed() (gas: 24499) +WebAuthnFclValidatorTest:test_sudo() (gas: 935921) +WebAuthnFclValidatorTest:test_sudo_wrongSig() (gas: 870972) WebAuthnFclValidatorTest:test_upgrade() (gas: 21621) -WebAuthnFclValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27324) +WebAuthnFclValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27346) WebAuthnFclValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23656) -WebAuthnFclValidatorTest:test_validate_signature() (gas: 0) -WebAuthnFclValidatorTest:test_webAuthnSignatureGeneration(bytes32,uint256) (runs: 1024, μ: 1332004, ~: 1257557) \ No newline at end of file +WebAuthnFclValidatorTest:test_validate_signature() (gas: 781686) +WebAuthnFclValidatorTest:test_webAuthnSignatureGeneration(bytes32,uint256) (runs: 1024, μ: 1334983, ~: 1254906) \ No newline at end of file diff --git a/test/foundry/validator/WebAuthnFclValidator.t.sol b/test/foundry/validator/WebAuthnFclValidator.t.sol index 218dbb46..bf163a6f 100644 --- a/test/foundry/validator/WebAuthnFclValidator.t.sol +++ b/test/foundry/validator/WebAuthnFclValidator.t.sol @@ -19,16 +19,10 @@ import {IKernel} from "src/interfaces/IKernel.sol"; using ERC4337Utils for IEntryPoint; -/* -TODO: - - Figure out why the msg signature fail? Maybe pre hashing stuff missed out? - - Add a test case arround the dummy signature bypass - -*/ contract WebAuthnFclValidatorTest is KernelTestBase { - WebAuthnFclValidator webAuthNValidator; - WebAuthNTester webAuthNTester; - P256VerifierWrapper p256VerifierWrapper; + WebAuthnFclValidator private webAuthNValidator; + WebAuthNTester private webAuthNTester; + P256VerifierWrapper private p256VerifierWrapper; // Curve order (number of points) uint256 constant n = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551; @@ -90,7 +84,7 @@ contract WebAuthnFclValidatorTest is KernelTestBase { ); performUserOperationWithSig(op); (uint256 x2, uint256 y2) = WebAuthnFclValidator(address(webAuthNValidator)).getPublicKey(address(kernel)); - verifyPublicKey(x2, y2, x, y); + _assertPublicKey(x2, y2, x, y); } function test_default_validator_disable() external override { @@ -105,7 +99,7 @@ contract WebAuthnFclValidatorTest is KernelTestBase { ); performUserOperationWithSig(op); (uint256 x2, uint256 y2) = WebAuthnFclValidator(address(webAuthNValidator)).getPublicKey(address(kernel)); - verifyPublicKey(x2, y2, 0, 0); + _assertPublicKey(x2, y2, 0, 0); } function test_external_call_batch_execute_success() external override { @@ -133,10 +127,6 @@ contract WebAuthnFclValidatorTest is KernelTestBase { } function test_validate_signature() external override { - vm.skip(true); - // TODO: Find out why it's bugy - - Kernel kernel2 = Kernel(payable(factory.createAccount(address(kernelImpl), getInitializeData(), 3))); bytes32 _hash = keccak256(abi.encodePacked("hello world")); bytes32 digest = keccak256( @@ -145,18 +135,42 @@ contract WebAuthnFclValidatorTest is KernelTestBase { ) ); - bytes memory signature = _generateWebAuthnSignature(ownerKey, digest); + bytes memory signature = signHash(digest); assertEq(kernel.isValidSignature(_hash, signature), Kernel.isValidSignature.selector); - assertEq(kernel2.isValidSignature(_hash, signature), bytes4(0xffffffff)); } function test_fail_validate_wrongsignature() external override { - vm.skip(true); - // TODO: Find out why it's bugy - bytes32 hash = keccak256(abi.encodePacked("hello world")); - bytes memory sig = getWrongSignature(hash); - assertEq(kernel.isValidSignature(hash, sig), bytes4(0xffffffff)); + // Prepare the hash to sign + bytes32 _hash = keccak256(abi.encodePacked("hello world")); + bytes32 digest = keccak256( + abi.encodePacked( + "\x19\x01", ERC4337Utils._buildDomainSeparator(KERNEL_NAME, KERNEL_VERSION, address(kernel)), _hash + ) + ); + + // Sign it (via a wrong signer) + bytes memory sig = getWrongSignature(digest); + assertEq(kernel.isValidSignature(_hash, sig), bytes4(0xffffffff)); + } + + function test_fail_validate_InvalidWebAuthnData() external { + // Prepare the data to sign + bytes32 _hash = keccak256(abi.encodePacked("hello world")); + bytes32 digest = keccak256( + abi.encodePacked( + "\x19\x01", ERC4337Utils._buildDomainSeparator(KERNEL_NAME, KERNEL_VERSION, address(kernel)), _hash + ) + ); + + bytes32 _wrongHash = keccak256(abi.encodePacked("bye world")); + + // Sign it + bytes memory sig = signHash(digest); + + // Ensure it's reverting + vm.expectRevert(WebAuthnFclVerifier.InvalidWebAuthNData.selector); + kernel.isValidSignature(_wrongHash, sig); } function signUserOp(UserOperation memory op) internal view override returns (bytes memory) { @@ -179,11 +193,34 @@ contract WebAuthnFclValidatorTest is KernelTestBase { return _generateWebAuthnSignature(ownerKey + 1, _hash); } - function verifyPublicKey(uint256 actualX, uint256 actualY, uint256 expectedX, uint256 expectedY) internal { + function _assertPublicKey(uint256 actualX, uint256 actualY, uint256 expectedX, uint256 expectedY) internal { assertEq(actualX, expectedX, "Public key X component mismatch"); assertEq(actualY, expectedY, "Public key Y component mismatch"); } + /// @dev Ensure that the validation won't revert when using the dummy signature bypass (challenge offset to uint256.max) + function test_dontRevertForDummySig() public { + // Build rly dummy data for authenticator data and client data + bytes memory authenticatorData = hex"1312"; + bytes memory clientData = hex"1312"; + // Set the client challenge data offset to the max value + uint256 clientChallengeDataOffset = type(uint256).max; + + // Build an incoherent signature + uint256[2] memory rs = [type(uint256).max, type(uint256).max]; + + // Encode all of that into a signature + bytes memory signature = abi.encode(authenticatorData, clientData, clientChallengeDataOffset, rs); + + // Check the sig (and ensure we didn't revert here) + bool isValid = webAuthNTester.verifySignature(address(p256VerifierWrapper), bytes32(0), signature, x, y); + assertEq(isValid, false); + + // Ensure we can go through the validator with that signature + ValidationData validationData = webAuthNValidator.validateSignature(bytes32(0), signature); + assertEq(ValidationData.unwrap(validationData), 1); + } + /// @dev Ensure that our flow to generate a webauthn signature is working function test_webAuthnSignatureGeneration(bytes32 _hash, uint256 _privateKey) public { vm.assume(_privateKey > 0); @@ -202,7 +239,6 @@ contract WebAuthnFclValidatorTest is KernelTestBase { // Ensure the signature is valid bool isValid = webAuthNTester.verifySignature(address(p256VerifierWrapper), _hash, signature, pubX, pubY); - assertEq(isValid, true); } From dfe4f72d926efcf13f6eced4a69c80d7ea87965e Mon Sep 17 00:00:00 2001 From: KONFeature Date: Sun, 21 Jan 2024 00:02:06 +0100 Subject: [PATCH 09/12] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Gas=20optimisation?= =?UTF-8?q?=20during=20webauthn=20msg=20check=20/=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gas-snapshot | 83 ++++++++++--------- src/utils/WebAuthnFclVerifier.sol | 33 +++++--- .../validator/WebAuthnFclValidator.t.sol | 31 ++++++- 3 files changed, 91 insertions(+), 56 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 21bb9181..4be58f52 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,13 +1,13 @@ KernelECDSATest:test_default_validator_disable() (gas: 0) -KernelECDSATest:test_default_validator_disable() (gas: 180648) +KernelECDSATest:test_default_validator_disable() (gas: 180620) KernelECDSATest:test_default_validator_enable() (gas: 0) -KernelECDSATest:test_default_validator_enable() (gas: 188140) -KernelECDSATest:test_disable_mode() (gas: 183150) +KernelECDSATest:test_default_validator_enable() (gas: 188112) +KernelECDSATest:test_disable_mode() (gas: 183122) KernelECDSATest:test_disable_mode() (gas: 192700) KernelECDSATest:test_eip712() (gas: 15684) KernelECDSATest:test_eip712() (gas: 15684) KernelECDSATest:test_enable_then_mode_1() (gas: 279619) -KernelECDSATest:test_enable_then_mode_1() (gas: 287402) +KernelECDSATest:test_enable_then_mode_1() (gas: 287374) KernelECDSATest:test_external_call_batch_execute_fail() (gas: 23625) KernelECDSATest:test_external_call_batch_execute_fail() (gas: 29531) KernelECDSATest:test_external_call_batch_execute_success() (gas: 20626) @@ -25,7 +25,7 @@ KernelECDSATest:test_external_call_execute_fail() (gas: 27862) KernelECDSATest:test_external_call_execute_success() (gas: 20070) KernelECDSATest:test_external_call_execute_success() (gas: 25987) KernelECDSATest:test_external_call_execution() (gas: 498421) -KernelECDSATest:test_external_call_execution() (gas: 511032) +KernelECDSATest:test_external_call_execution() (gas: 511004) KernelECDSATest:test_fail_validate_not_activate() (gas: 0) KernelECDSATest:test_fail_validate_not_activate() (gas: 303494) KernelECDSATest:test_fail_validate_wrongsignature() (gas: 25013) @@ -41,12 +41,12 @@ KernelECDSATest:test_initialize_twice() (gas: 18555) KernelECDSATest:test_initialize_twice() (gas: 18599) KernelECDSATest:test_mode_2() (gas: 243908) KernelECDSATest:test_mode_2() (gas: 251079) -KernelECDSATest:test_revert_when_mode_disabled() (gas: 200119) +KernelECDSATest:test_revert_when_mode_disabled() (gas: 200091) KernelECDSATest:test_revert_when_mode_disabled() (gas: 209732) KernelECDSATest:test_set_default_validator() (gas: 417758) -KernelECDSATest:test_set_default_validator() (gas: 423674) +KernelECDSATest:test_set_default_validator() (gas: 423646) KernelECDSATest:test_set_execution() (gas: 458753) -KernelECDSATest:test_set_execution() (gas: 468648) +KernelECDSATest:test_set_execution() (gas: 468620) KernelECDSATest:test_should_emit_event_on_receive() (gas: 23220) KernelECDSATest:test_should_emit_event_on_receive() (gas: 23220) KernelECDSATest:test_should_receive_erc1155() (gas: 700299) @@ -58,7 +58,7 @@ KernelECDSATest:test_should_receive_erc721() (gas: 597496) KernelECDSATest:test_should_return_address_if_deployed() (gas: 21970) KernelECDSATest:test_should_return_address_if_deployed() (gas: 21976) KernelECDSATest:test_sudo() (gas: 170601) -KernelECDSATest:test_sudo() (gas: 179783) +KernelECDSATest:test_sudo() (gas: 179755) KernelECDSATest:test_sudo_wrongSig() (gas: 103132) KernelECDSATest:test_sudo_wrongSig() (gas: 116321) KernelECDSATest:test_transfer_ownership() (gas: 185003) @@ -251,8 +251,8 @@ StealthAddressValidatorTest:test_should_receive_erc1155() (gas: 700331) StealthAddressValidatorTest:test_should_receive_erc1155_batch() (gas: 727528) StealthAddressValidatorTest:test_should_receive_erc721() (gas: 597506) StealthAddressValidatorTest:test_should_return_address_if_deployed() (gas: 1618159) -StealthAddressValidatorTest:test_stealth_validate_sig_aggsig() (gas: 2997520) -StealthAddressValidatorTest:test_stealth_validate_userop_aggsig() (gas: 3018773) +StealthAddressValidatorTest:test_stealth_validate_sig_aggsig() (gas: 2994026) +StealthAddressValidatorTest:test_stealth_validate_userop_aggsig() (gas: 3015023) StealthAddressValidatorTest:test_sudo() (gas: 1781012) StealthAddressValidatorTest:test_sudo_wrongSig() (gas: 1713761) StealthAddressValidatorTest:test_upgrade() (gas: 21301) @@ -267,41 +267,42 @@ TestERC721:test_ignore() (gas: 399) TestExecutor:test_ignore() (gas: 130) TestPaymaster:test_ignore() (gas: 174) TestValidator:test_ignore() (gas: 351) -WebAuthnFclValidatorTest:test_default_validator_disable() (gas: 920694) -WebAuthnFclValidatorTest:test_default_validator_enable() (gas: 947073) -WebAuthnFclValidatorTest:test_disable_mode() (gas: 935320) -WebAuthnFclValidatorTest:test_dontRevertForDummySig() (gas: 32678) -WebAuthnFclValidatorTest:test_eip712() (gas: 15931) -WebAuthnFclValidatorTest:test_enable_then_mode_1() (gas: 1393815) -WebAuthnFclValidatorTest:test_external_call_batch_execute_fail() (gas: 25060) +WebAuthnFclValidatorTest:test_default_validator_disable() (gas: 918686) +WebAuthnFclValidatorTest:test_default_validator_enable() (gas: 945065) +WebAuthnFclValidatorTest:test_disable_mode() (gas: 933312) +WebAuthnFclValidatorTest:test_dontRevertForDummySig() (gas: 32708) +WebAuthnFclValidatorTest:test_eip712() (gas: 15953) +WebAuthnFclValidatorTest:test_enable_then_mode_1() (gas: 1390147) +WebAuthnFclValidatorTest:test_external_call_batch_execute_fail() (gas: 25082) WebAuthnFclValidatorTest:test_external_call_batch_execute_success() (gas: 0) WebAuthnFclValidatorTest:test_external_call_default() (gas: 0) WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 0) -WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 21960) +WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 21982) WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_success() (gas: 0) -WebAuthnFclValidatorTest:test_external_call_execute_fail() (gas: 21206) +WebAuthnFclValidatorTest:test_external_call_execute_fail() (gas: 21228) WebAuthnFclValidatorTest:test_external_call_execute_success() (gas: 0) WebAuthnFclValidatorTest:test_external_call_execution() (gas: 0) -WebAuthnFclValidatorTest:test_fail_validate_InvalidWebAuthnData() (gas: 399162) -WebAuthnFclValidatorTest:test_fail_validate_not_activate() (gas: 304402) -WebAuthnFclValidatorTest:test_fail_validate_wrongsignature() (gas: 794693) +WebAuthnFclValidatorTest:test_fail_validate_InvalidWebAuthnData() (gas: 397146) +WebAuthnFclValidatorTest:test_fail_validate_not_activate() (gas: 304424) +WebAuthnFclValidatorTest:test_fail_validate_wrongsignature() (gas: 792685) WebAuthnFclValidatorTest:test_get_nonce() (gas: 25621) -WebAuthnFclValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 20134, ~: 20134) -WebAuthnFclValidatorTest:test_initialize() (gas: 178492) -WebAuthnFclValidatorTest:test_initialize_twice() (gas: 20805) -WebAuthnFclValidatorTest:test_mode_2() (gas: 1354171) -WebAuthnFclValidatorTest:test_revert_when_mode_disabled() (gas: 952319) -WebAuthnFclValidatorTest:test_set_default_validator() (gas: 1167256) -WebAuthnFclValidatorTest:test_set_execution() (gas: 1235698) -WebAuthnFclValidatorTest:test_should_emit_event_on_receive() (gas: 23434) -WebAuthnFclValidatorTest:test_should_receive_erc1155() (gas: 700465) -WebAuthnFclValidatorTest:test_should_receive_erc1155_batch() (gas: 727725) -WebAuthnFclValidatorTest:test_should_receive_erc721() (gas: 597640) -WebAuthnFclValidatorTest:test_should_return_address_if_deployed() (gas: 24499) -WebAuthnFclValidatorTest:test_sudo() (gas: 935921) -WebAuthnFclValidatorTest:test_sudo_wrongSig() (gas: 870972) -WebAuthnFclValidatorTest:test_upgrade() (gas: 21621) -WebAuthnFclValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27346) +WebAuthnFclValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 20156, ~: 20156) +WebAuthnFclValidatorTest:test_initialize() (gas: 178514) +WebAuthnFclValidatorTest:test_initialize_twice() (gas: 20827) +WebAuthnFclValidatorTest:test_mode_2() (gas: 1350498) +WebAuthnFclValidatorTest:test_revert_when_mode_disabled() (gas: 950311) +WebAuthnFclValidatorTest:test_set_default_validator() (gas: 1165253) +WebAuthnFclValidatorTest:test_set_execution() (gas: 1233695) +WebAuthnFclValidatorTest:test_should_emit_event_on_receive() (gas: 23456) +WebAuthnFclValidatorTest:test_should_receive_erc1155() (gas: 700487) +WebAuthnFclValidatorTest:test_should_receive_erc1155_batch() (gas: 727747) +WebAuthnFclValidatorTest:test_should_receive_erc721() (gas: 597662) +WebAuthnFclValidatorTest:test_should_return_address_if_deployed() (gas: 24521) +WebAuthnFclValidatorTest:test_sudo() (gas: 933913) +WebAuthnFclValidatorTest:test_sudo_wrongSig() (gas: 868964) +WebAuthnFclValidatorTest:test_upgrade() (gas: 21643) +WebAuthnFclValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27368) WebAuthnFclValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23656) -WebAuthnFclValidatorTest:test_validate_signature() (gas: 781686) -WebAuthnFclValidatorTest:test_webAuthnSignatureGeneration(bytes32,uint256) (runs: 1024, μ: 1334983, ~: 1254906) \ No newline at end of file +WebAuthnFclValidatorTest:test_validate_signature() (gas: 779688) +WebAuthnFclValidatorTest:test_webAuthnSignatureGeneration(bytes32,uint256) (runs: 1024, μ: 1330494, ~: 1250861) +WebAuthnFclValidatorTest:test_webAuthnSignatureGeneration_solo() (gas: 1162420) \ No newline at end of file diff --git a/src/utils/WebAuthnFclVerifier.sol b/src/utils/WebAuthnFclVerifier.sol index ee59800d..1e1f3ebb 100644 --- a/src/utils/WebAuthnFclVerifier.sol +++ b/src/utils/WebAuthnFclVerifier.sol @@ -14,6 +14,9 @@ library WebAuthnFclVerifier { /// @dev Error thrown when the webauthn data is invalid error InvalidWebAuthNData(); + /// @dev 'bytes4(keccak256("InvalidWebAuthNData()"))' + uint256 private constant _INVALID_WEBAUTHN_DATA_SELECTOR = 0x81177746; + /// @dev the data flag mask we will use to verify the signature /// @dev Always 0x01 for user presence flag -> https://www.w3.org/TR/webauthn-2/#concept-user-present bytes1 private constant AUTHENTICATOR_DATA_FLAG_MASK = 0x01; @@ -56,36 +59,44 @@ library WebAuthnFclVerifier { // Verify that clientData commits to the expected client challenge // Use the Base64Url encoding which omits padding characters to match WebAuthn Specification bytes memory challengeEncoded = bytes(Base64.encode(abi.encodePacked(_hash), true, true)); + + // The part that will old the challenge extracted from the clientData bytes memory challengeExtracted = new bytes(challengeEncoded.length); assembly { + // Extract the challenge from the clientData calldatacopy( add(challengeExtracted, 32), add(clientData.offset, challengeOffset), mload(challengeExtracted) ) - } - - bytes32 moreData; //=keccak256(abi.encodePacked(challengeExtracted)); - assembly { - moreData := keccak256(add(challengeExtracted, 32), mload(challengeExtracted)) - } - if (keccak256(abi.encodePacked(challengeEncoded)) != moreData) { - revert InvalidWebAuthNData(); + // Check that the challenge extracted from the clientData is the same as the one provided in the userOp + if iszero(eq( + // Hash of the challenge exracted from the `clientData` + keccak256(add(challengeExtracted, 32), mload(challengeExtracted)), + // Hash of the provided challenge, encoded in Base64Url (to match the clientData encoding) + keccak256(add(challengeEncoded, 32), mload(challengeEncoded)) + )) { + mstore(0x00, _INVALID_WEBAUTHN_DATA_SELECTOR) + revert(0x1c, 0x04) + } } - } //avoid stack full + } // Verify the signature over sha256(authenticatorData || sha256(clientData)) bytes memory verifyData = new bytes(authenticatorData.length + 32); assembly { + // Add the authenticator data at the start of the verifyData calldatacopy(add(verifyData, 32), authenticatorData.offset, authenticatorData.length) } - bytes32 more = sha256(clientData); + bytes32 clientDataHashed = sha256(clientData); assembly { - mstore(add(verifyData, add(authenticatorData.length, 32)), more) + // Add the client data hash at the end of the verifyData + mstore(add(verifyData, add(authenticatorData.length, 32)), clientDataHashed) } + // Return the sha256 of the verifyData return sha256(verifyData); } diff --git a/test/foundry/validator/WebAuthnFclValidator.t.sol b/test/foundry/validator/WebAuthnFclValidator.t.sol index bf163a6f..a8e2cb13 100644 --- a/test/foundry/validator/WebAuthnFclValidator.t.sol +++ b/test/foundry/validator/WebAuthnFclValidator.t.sol @@ -8,11 +8,9 @@ import {ERC4337Utils} from "../utils/ERC4337Utils.sol"; import {KernelTestBase} from "../KernelTestBase.sol"; import {TestExecutor} from "../mock/TestExecutor.sol"; import {TestValidator} from "../mock/TestValidator.sol"; -import {P256Validator} from "src/validator/P256Validator.sol"; import {WebAuthnFclVerifier} from "src/utils/WebAuthnFclVerifier.sol"; import {P256VerifierWrapper} from "src/utils/P256VerifierWrapper.sol"; import {WebAuthnFclValidator} from "src/validator/WebAuthnFclValidator.sol"; -import {P256} from "p256-verifier/P256.sol"; import {FCL_ecdsa_utils} from "FreshCryptoLib/FCL_ecdsa_utils.sol"; import {Base64Url} from "FreshCryptoLib/utils/Base64Url.sol"; import {IKernel} from "src/interfaces/IKernel.sol"; @@ -93,7 +91,7 @@ contract WebAuthnFclValidatorTest is KernelTestBase { IKernel.execute.selector, address(webAuthNValidator), 0, - abi.encodeWithSelector(P256Validator.disable.selector, ""), + abi.encodeWithSelector(webAuthNValidator.disable.selector, ""), Operation.Call ) ); @@ -242,6 +240,28 @@ contract WebAuthnFclValidatorTest is KernelTestBase { assertEq(isValid, true); } + /// @dev Ensure that our flow to generate a webauthn signature is working + function test_webAuthnSignatureGeneration_solo() public { + uint256 _privateKey = 0x1; + bytes32 _hash = keccak256(abi.encodePacked("hello world")); + (uint256 pubX, uint256 pubY) = _getPublicKey(_privateKey); + + // Build all the data required + (bytes32 msgToSign, bytes memory authenticatorData, bytes memory clientData, uint256 clientChallengeDataOffset) + = _prepapreWebAuthnMsg(_hash); + + // Then sign them + (uint256 r, uint256 s) = _getP256Signature(_privateKey, msgToSign); + uint256[2] memory rs = [r, s]; + + // Encode all of that into a signature + bytes memory signature = abi.encode(authenticatorData, clientData, clientChallengeDataOffset, rs); + + // Ensure the signature is valid + bool isValid = webAuthNTester.verifySignature(address(p256VerifierWrapper), _hash, signature, pubX, pubY); + assertEq(isValid, true); + } + /* -------------------------------------------------------------------------- */ /* Signature & P256 helper functions */ /* -------------------------------------------------------------------------- */ @@ -305,6 +325,9 @@ contract WebAuthnFclValidatorTest is KernelTestBase { return FCL_ecdsa_utils.ecdsa_derivKpub(_privateKey); } + /// P256 curve order n/2 for malleability check + uint256 constant P256_N_DIV_2 = 57896044605178124381348723474703786764998477612067880171211129530534256022184; + /// @dev Generate a p256 signature, from the given `_privateKey` on the given `_hash` function _getP256Signature(uint256 _privateKey, bytes32 _hash) internal view returns (uint256 r, uint256 s) { // Securely generate a random k value for each signature @@ -317,7 +340,7 @@ contract WebAuthnFclValidatorTest is KernelTestBase { (r, s) = FCL_ecdsa_utils.ecdsa_sign(_hash, k, _privateKey); // Ensure that s is in the lower half of the range [1, n-1] - if (r == 0 || s == 0 || s > P256.P256_N_DIV_2) { + if (r == 0 || s == 0 || s > P256_N_DIV_2) { s = n - s; // If s is in the upper half, use n - s instead } From 59b2afa739fb6c8226fbbe458e7c9723a31e7d05 Mon Sep 17 00:00:00 2001 From: KONFeature Date: Mon, 22 Jan 2024 13:46:37 +0100 Subject: [PATCH 10/12] =?UTF-8?q?=F0=9F=90=9B=20Post=20rebase=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gas-snapshot | 523 ++++++++---------- .gitmodules | 3 + .../80001/run-1704722702.json | 52 -- .../80001/run-1704722737.json | 55 -- .../80001/run-1704722750.json | 119 ---- .../80001/run-latest.json | 119 ---- lib/FreshCryptoLib | 1 + remappings.txt | 1 - .../validator/WebAuthnFclValidator.t.sol | 8 +- 9 files changed, 233 insertions(+), 648 deletions(-) delete mode 100644 broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722702.json delete mode 100644 broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722737.json delete mode 100644 broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722750.json delete mode 100644 broadcast/DeployWebAuthnValidator.s.sol/80001/run-latest.json create mode 160000 lib/FreshCryptoLib diff --git a/.gas-snapshot b/.gas-snapshot index 4be58f52..09164ee6 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,308 +1,235 @@ KernelECDSATest:test_default_validator_disable() (gas: 0) -KernelECDSATest:test_default_validator_disable() (gas: 180620) +KernelECDSATest:test_default_validator_disable() (gas: 180903) KernelECDSATest:test_default_validator_enable() (gas: 0) -KernelECDSATest:test_default_validator_enable() (gas: 188112) -KernelECDSATest:test_disable_mode() (gas: 183122) -KernelECDSATest:test_disable_mode() (gas: 192700) -KernelECDSATest:test_eip712() (gas: 15684) -KernelECDSATest:test_eip712() (gas: 15684) -KernelECDSATest:test_enable_then_mode_1() (gas: 279619) -KernelECDSATest:test_enable_then_mode_1() (gas: 287374) -KernelECDSATest:test_external_call_batch_execute_fail() (gas: 23625) -KernelECDSATest:test_external_call_batch_execute_fail() (gas: 29531) -KernelECDSATest:test_external_call_batch_execute_success() (gas: 20626) -KernelECDSATest:test_external_call_batch_execute_success() (gas: 26533) -KernelECDSATest:test_external_call_default() (gas: 23511) -KernelECDSATest:test_external_call_default() (gas: 29338) -KernelECDSATest:test_external_call_execute_delegatecall_fail() (gas: 22499) -KernelECDSATest:test_external_call_execute_delegatecall_fail() (gas: 28381) -KernelECDSATest:test_external_call_execute_delegatecall_option_fail() (gas: 20434) -KernelECDSATest:test_external_call_execute_delegatecall_option_fail() (gas: 26329) -KernelECDSATest:test_external_call_execute_delegatecall_success() (gas: 19738) -KernelECDSATest:test_external_call_execute_delegatecall_success() (gas: 25621) -KernelECDSATest:test_external_call_execute_fail() (gas: 21968) -KernelECDSATest:test_external_call_execute_fail() (gas: 27862) -KernelECDSATest:test_external_call_execute_success() (gas: 20070) -KernelECDSATest:test_external_call_execute_success() (gas: 25987) -KernelECDSATest:test_external_call_execution() (gas: 498421) -KernelECDSATest:test_external_call_execution() (gas: 511004) +KernelECDSATest:test_default_validator_enable() (gas: 188628) +KernelECDSATest:test_disable_mode() (gas: 182553) +KernelECDSATest:test_disable_mode() (gas: 191433) +KernelECDSATest:test_eip712() (gas: 15037) +KernelECDSATest:test_eip712() (gas: 15059) +KernelECDSATest:test_enable_then_mode_1() (gas: 279181) +KernelECDSATest:test_enable_then_mode_1() (gas: 287578) +KernelECDSATest:test_external_call_batch_execute_fail() (gas: 22756) +KernelECDSATest:test_external_call_batch_execute_fail() (gas: 28852) +KernelECDSATest:test_external_call_batch_execute_success() (gas: 20270) +KernelECDSATest:test_external_call_batch_execute_success() (gas: 26366) +KernelECDSATest:test_external_call_default() (gas: 22692) +KernelECDSATest:test_external_call_default() (gas: 28797) +KernelECDSATest:test_external_call_execute_delegatecall_fail() (gas: 21787) +KernelECDSATest:test_external_call_execute_delegatecall_fail() (gas: 27771) +KernelECDSATest:test_external_call_execute_delegatecall_option_fail() (gas: 19427) +KernelECDSATest:test_external_call_execute_delegatecall_option_fail() (gas: 25605) +KernelECDSATest:test_external_call_execute_delegatecall_success() (gas: 18939) +KernelECDSATest:test_external_call_execute_delegatecall_success() (gas: 24923) +KernelECDSATest:test_external_call_execute_fail() (gas: 21852) +KernelECDSATest:test_external_call_execute_fail() (gas: 28030) +KernelECDSATest:test_external_call_execute_success() (gas: 19187) +KernelECDSATest:test_external_call_execute_success() (gas: 25387) +KernelECDSATest:test_external_call_execution() (gas: 569078) +KernelECDSATest:test_external_call_execution() (gas: 582722) KernelECDSATest:test_fail_validate_not_activate() (gas: 0) -KernelECDSATest:test_fail_validate_not_activate() (gas: 303494) -KernelECDSATest:test_fail_validate_wrongsignature() (gas: 25013) -KernelECDSATest:test_fail_validate_wrongsignature() (gas: 34351) -KernelECDSATest:test_get_nonce() (gas: 25179) -KernelECDSATest:test_get_nonce() (gas: 25201) -KernelECDSATest:test_get_nonce(uint192) (runs: 1024, μ: 19842, ~: 19842) -KernelECDSATest:test_get_nonce(uint192) (runs: 1024, μ: 19842, ~: 19842) -KernelECDSATest:test_ignore() (gas: 868) -KernelECDSATest:test_initialize() (gas: 126488) -KernelECDSATest:test_initialize() (gas: 154121) -KernelECDSATest:test_initialize_twice() (gas: 18555) -KernelECDSATest:test_initialize_twice() (gas: 18599) -KernelECDSATest:test_mode_2() (gas: 243908) -KernelECDSATest:test_mode_2() (gas: 251079) +KernelECDSATest:test_fail_validate_not_activate() (gas: 374629) +KernelECDSATest:test_fail_validate_wrongsignature() (gas: 23961) +KernelECDSATest:test_fail_validate_wrongsignature() (gas: 33419) +KernelECDSATest:test_get_nonce() (gas: 24893) +KernelECDSATest:test_get_nonce() (gas: 24914) +KernelECDSATest:test_get_nonce(uint192) (runs: 1024, μ: 19517, ~: 19517) +KernelECDSATest:test_get_nonce(uint192) (runs: 1024, μ: 19561, ~: 19561) +KernelECDSATest:test_ignore() (gas: 231) +KernelECDSATest:test_initialize() (gas: 126587) +KernelECDSATest:test_initialize() (gas: 154222) +KernelECDSATest:test_initialize_twice() (gas: 18215) +KernelECDSATest:test_initialize_twice() (gas: 18218) +KernelECDSATest:test_mode_2() (gas: 243855) +KernelECDSATest:test_mode_2() (gas: 251191) KernelECDSATest:test_revert_when_mode_disabled() (gas: 200091) -KernelECDSATest:test_revert_when_mode_disabled() (gas: 209732) -KernelECDSATest:test_set_default_validator() (gas: 417758) -KernelECDSATest:test_set_default_validator() (gas: 423646) -KernelECDSATest:test_set_execution() (gas: 458753) -KernelECDSATest:test_set_execution() (gas: 468620) -KernelECDSATest:test_should_emit_event_on_receive() (gas: 23220) -KernelECDSATest:test_should_emit_event_on_receive() (gas: 23220) -KernelECDSATest:test_should_receive_erc1155() (gas: 700299) -KernelECDSATest:test_should_receive_erc1155() (gas: 700325) -KernelECDSATest:test_should_receive_erc1155_batch() (gas: 727496) -KernelECDSATest:test_should_receive_erc1155_batch() (gas: 727496) -KernelECDSATest:test_should_receive_erc721() (gas: 597474) -KernelECDSATest:test_should_receive_erc721() (gas: 597496) -KernelECDSATest:test_should_return_address_if_deployed() (gas: 21970) -KernelECDSATest:test_should_return_address_if_deployed() (gas: 21976) -KernelECDSATest:test_sudo() (gas: 170601) -KernelECDSATest:test_sudo() (gas: 179755) -KernelECDSATest:test_sudo_wrongSig() (gas: 103132) -KernelECDSATest:test_sudo_wrongSig() (gas: 116321) -KernelECDSATest:test_transfer_ownership() (gas: 185003) -KernelECDSATest:test_upgrade() (gas: 21292) -KernelECDSATest:test_upgrade() (gas: 21292) -KernelECDSATest:test_validateUserOp_fail_invalid_mode() (gas: 26934) -KernelECDSATest:test_validateUserOp_fail_invalid_mode() (gas: 26997) -KernelECDSATest:test_validateUserOp_fail_not_entryPoint() (gas: 23364) -KernelECDSATest:test_validateUserOp_fail_not_entryPoint() (gas: 23427) -KernelECDSATest:test_validate_signature() (gas: 155636) -KernelECDSATest:test_validate_signature() (gas: 194938) -KernelECDSATypedTest:test_default_validator_disable() (gas: 185046) -KernelECDSATypedTest:test_default_validator_enable() (gas: 192011) -KernelECDSATypedTest:test_disable_mode() (gas: 187373) -KernelECDSATypedTest:test_eip712() (gas: 15684) -KernelECDSATypedTest:test_enable_then_mode_1() (gas: 291627) -KernelECDSATypedTest:test_external_call_batch_execute_fail() (gas: 29575) -KernelECDSATypedTest:test_external_call_batch_execute_success() (gas: 26577) -KernelECDSATypedTest:test_external_call_default() (gas: 29382) -KernelECDSATypedTest:test_external_call_execute_delegatecall_fail() (gas: 28425) -KernelECDSATypedTest:test_external_call_execute_delegatecall_option_fail() (gas: 26373) -KernelECDSATypedTest:test_external_call_execute_delegatecall_success() (gas: 25665) -KernelECDSATypedTest:test_external_call_execute_fail() (gas: 27906) -KernelECDSATypedTest:test_external_call_execute_success() (gas: 26031) -KernelECDSATypedTest:test_external_call_execution() (gas: 515344) -KernelECDSATypedTest:test_fail_validate_not_activate() (gas: 303494) -KernelECDSATypedTest:test_fail_validate_wrongsignature() (gas: 36953) -KernelECDSATypedTest:test_get_nonce() (gas: 25179) -KernelECDSATypedTest:test_get_nonce(uint192) (runs: 1024, μ: 19842, ~: 19842) -KernelECDSATypedTest:test_ignore() (gas: 868) -KernelECDSATypedTest:test_initialize() (gas: 153627) -KernelECDSATypedTest:test_initialize_twice() (gas: 18555) -KernelECDSATypedTest:test_mode_2() (gas: 253812) -KernelECDSATypedTest:test_revert_when_mode_disabled() (gas: 204271) -KernelECDSATypedTest:test_set_default_validator() (gas: 427897) -KernelECDSATypedTest:test_set_execution() (gas: 472872) -KernelECDSATypedTest:test_should_emit_event_on_receive() (gas: 23220) -KernelECDSATypedTest:test_should_receive_erc1155() (gas: 700299) -KernelECDSATypedTest:test_should_receive_erc1155_batch() (gas: 727496) -KernelECDSATypedTest:test_should_receive_erc721() (gas: 597496) -KernelECDSATypedTest:test_should_return_address_if_deployed() (gas: 21976) -KernelECDSATypedTest:test_sudo() (gas: 184006) -KernelECDSATypedTest:test_sudo_wrongSig() (gas: 116744) -KernelECDSATypedTest:test_upgrade() (gas: 21292) -KernelECDSATypedTest:test_validateUserOp_fail_invalid_mode() (gas: 26934) -KernelECDSATypedTest:test_validateUserOp_fail_not_entryPoint() (gas: 23364) -KernelECDSATypedTest:test_validate_signature() (gas: 191837) -KernelHelperTest:testIntersect(uint48,uint48,uint48,uint48) (runs: 1024, μ: 986, ~: 991) -KillSwitchValidatorTest:test_default_validator_disable() (gas: 180769) -KillSwitchValidatorTest:test_default_validator_enable() (gas: 188261) -KillSwitchValidatorTest:test_disable_mode() (gas: 183271) -KillSwitchValidatorTest:test_eip712() (gas: 15820) -KillSwitchValidatorTest:test_enable_then_mode_1() (gas: 349996) -KillSwitchValidatorTest:test_external_call_batch_execute_fail() (gas: 29619) -KillSwitchValidatorTest:test_external_call_batch_execute_success() (gas: 26555) -KillSwitchValidatorTest:test_external_call_default() (gas: 29426) -KillSwitchValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 28469) -KillSwitchValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 26439) -KillSwitchValidatorTest:test_external_call_execute_delegatecall_success() (gas: 25709) -KillSwitchValidatorTest:test_external_call_execute_fail() (gas: 27906) -KillSwitchValidatorTest:test_external_call_execute_success() (gas: 26075) -KillSwitchValidatorTest:test_external_call_execution() (gas: 511153) -KillSwitchValidatorTest:test_fail_validate_not_activate() (gas: 303604) -KillSwitchValidatorTest:test_fail_validate_wrongsignature() (gas: 34494) -KillSwitchValidatorTest:test_force_unblock() (gas: 394736) -KillSwitchValidatorTest:test_get_nonce() (gas: 25201) -KillSwitchValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 19930, ~: 19930) -KillSwitchValidatorTest:test_ignore() (gas: 956) -KillSwitchValidatorTest:test_initialize() (gas: 154209) -KillSwitchValidatorTest:test_initialize_twice() (gas: 18643) -KillSwitchValidatorTest:test_mode_2() (gas: 313713) -KillSwitchValidatorTest:test_revert_when_mode_disabled() (gas: 200273) -KillSwitchValidatorTest:test_set_default_validator() (gas: 423773) -KillSwitchValidatorTest:test_set_execution() (gas: 468769) -KillSwitchValidatorTest:test_should_emit_event_on_receive() (gas: 23330) -KillSwitchValidatorTest:test_should_fail_with_not_implemented_isValidSignature() (gas: 9236) -KillSwitchValidatorTest:test_should_fail_with_not_implemented_isValidSignature(bytes32,bytes) (runs: 1024, μ: 9601, ~: 9556) -KillSwitchValidatorTest:test_should_fail_with_not_implemented_validCaller() (gas: 10157) -KillSwitchValidatorTest:test_should_fail_with_not_implemented_validCaller(address,bytes) (runs: 1024, μ: 9749, ~: 9703) -KillSwitchValidatorTest:test_should_receive_erc1155() (gas: 700387) -KillSwitchValidatorTest:test_should_receive_erc1155_batch() (gas: 727584) -KillSwitchValidatorTest:test_should_receive_erc721() (gas: 597584) -KillSwitchValidatorTest:test_should_return_address_if_deployed() (gas: 22086) -KillSwitchValidatorTest:test_sudo() (gas: 179882) -KillSwitchValidatorTest:test_sudo_wrongSig() (gas: 116442) -KillSwitchValidatorTest:test_upgrade() (gas: 21314) -KillSwitchValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27022) -KillSwitchValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23391) -KillSwitchValidatorTest:test_validate_signature() (gas: 195015) -P256ValidatorTest:test_default_validator_disable() (gas: 878460) -P256ValidatorTest:test_default_validator_enable() (gas: 890421) -P256ValidatorTest:test_disable_mode() (gas: 888100) -P256ValidatorTest:test_eip712() (gas: 15887) -P256ValidatorTest:test_enable_then_mode_1() (gas: 1364924) -P256ValidatorTest:test_external_call_batch_execute_fail() (gas: 25023) -P256ValidatorTest:test_external_call_batch_execute_success() (gas: 0) -P256ValidatorTest:test_external_call_default() (gas: 0) -P256ValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 0) -P256ValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 21901) -P256ValidatorTest:test_external_call_execute_delegatecall_success() (gas: 0) -P256ValidatorTest:test_external_call_execute_fail() (gas: 21191) -P256ValidatorTest:test_external_call_execute_success() (gas: 0) -P256ValidatorTest:test_external_call_execution() (gas: 0) -P256ValidatorTest:test_fail_validate_not_activate() (gas: 304359) -P256ValidatorTest:test_fail_validate_wrongsignature() (gas: 746185) -P256ValidatorTest:test_get_nonce() (gas: 25621) -P256ValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 20090, ~: 20090) -P256ValidatorTest:test_initialize() (gas: 178621) -P256ValidatorTest:test_initialize_twice() (gas: 20756) -P256ValidatorTest:test_mode_2() (gas: 1307169) -P256ValidatorTest:test_revert_when_mode_disabled() (gas: 905172) -P256ValidatorTest:test_set_default_validator() (gas: 1119469) -P256ValidatorTest:test_set_execution() (gas: 1179926) -P256ValidatorTest:test_should_emit_event_on_receive() (gas: 23390) -P256ValidatorTest:test_should_receive_erc1155() (gas: 700421) -P256ValidatorTest:test_should_receive_erc1155_batch() (gas: 727681) -P256ValidatorTest:test_should_receive_erc721() (gas: 597618) -P256ValidatorTest:test_should_return_address_if_deployed() (gas: 24455) -P256ValidatorTest:test_sudo() (gas: 887230) -P256ValidatorTest:test_sudo_wrongSig() (gas: 821017) -P256ValidatorTest:test_upgrade() (gas: 21621) -P256ValidatorTest:test_utils(uint256,bytes32) (runs: 1024, μ: 1260644, ~: 1146785) -P256ValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27324) -P256ValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23656) -P256ValidatorTest:test_validate_signature() (gas: 1271501) -SessionKeyValidatorTest:test_default_validator_disable() (gas: 180670) -SessionKeyValidatorTest:test_default_validator_enable() (gas: 188140) -SessionKeyValidatorTest:test_disable_mode() (gas: 183150) -SessionKeyValidatorTest:test_eip712() (gas: 15684) -SessionKeyValidatorTest:test_enable_then_mode_1() (gas: 287446) -SessionKeyValidatorTest:test_external_call_batch_execute_fail() (gas: 29553) -SessionKeyValidatorTest:test_external_call_batch_execute_success() (gas: 26533) -SessionKeyValidatorTest:test_external_call_default() (gas: 29360) -SessionKeyValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 28381) -SessionKeyValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 26373) -SessionKeyValidatorTest:test_external_call_execute_delegatecall_success() (gas: 25621) -SessionKeyValidatorTest:test_external_call_execute_fail() (gas: 27862) -SessionKeyValidatorTest:test_external_call_execute_success() (gas: 26031) -SessionKeyValidatorTest:test_external_call_execution() (gas: 511076) -SessionKeyValidatorTest:test_fail_validate_not_activate() (gas: 303538) -SessionKeyValidatorTest:test_fail_validate_wrongsignature() (gas: 34395) -SessionKeyValidatorTest:test_get_nonce() (gas: 25179) -SessionKeyValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 19842, ~: 19842) -SessionKeyValidatorTest:test_ignore() (gas: 912) -SessionKeyValidatorTest:test_initialize() (gas: 154121) -SessionKeyValidatorTest:test_initialize_twice() (gas: 18555) -SessionKeyValidatorTest:test_mode_2() (gas: 251156) -SessionKeyValidatorTest:test_revert_when_mode_disabled() (gas: 200119) -SessionKeyValidatorTest:test_scenario_batch((uint8,uint8,uint8,uint8,uint48,uint48,uint48,uint48,bool,bool,bool,bool,bool),(uint8)) (runs: 1024, μ: 56405623, ~: 51218259) -SessionKeyValidatorTest:test_scenario_non_batch((uint8,uint8,uint8,uint8,uint48,uint48,uint48,uint48,bool,bool,bool,bool,bool)) (runs: 1024, μ: 50726904, ~: 50878941) -SessionKeyValidatorTest:test_set_default_validator() (gas: 423674) -SessionKeyValidatorTest:test_set_execution() (gas: 468648) -SessionKeyValidatorTest:test_should_emit_event_on_receive() (gas: 23264) -SessionKeyValidatorTest:test_should_receive_erc1155() (gas: 700299) -SessionKeyValidatorTest:test_should_receive_erc1155_batch() (gas: 727496) -SessionKeyValidatorTest:test_should_receive_erc721() (gas: 597540) -SessionKeyValidatorTest:test_should_return_address_if_deployed() (gas: 22020) -SessionKeyValidatorTest:test_sudo() (gas: 179783) -SessionKeyValidatorTest:test_sudo_wrongSig() (gas: 116365) -SessionKeyValidatorTest:test_upgrade() (gas: 21292) -SessionKeyValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 26958) -SessionKeyValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23364) -SessionKeyValidatorTest:test_validate_signature() (gas: 194938) -StealthAddressValidatorTest:test_default_validator_disable() (gas: 1784996) -StealthAddressValidatorTest:test_default_validator_enable() (gas: 3460838) -StealthAddressValidatorTest:test_disable_mode() (gas: 1784530) -StealthAddressValidatorTest:test_eip712() (gas: 15715) -StealthAddressValidatorTest:test_enable_then_mode_1() (gas: 1889579) -StealthAddressValidatorTest:test_external_call_batch_execute_fail() (gas: 29635) -StealthAddressValidatorTest:test_external_call_batch_execute_success() (gas: 26615) -StealthAddressValidatorTest:test_external_call_default() (gas: 29441) -StealthAddressValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 28484) -StealthAddressValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 26454) -StealthAddressValidatorTest:test_external_call_execute_delegatecall_success() (gas: 25724) -StealthAddressValidatorTest:test_external_call_execute_fail() (gas: 27965) -StealthAddressValidatorTest:test_external_call_execute_success() (gas: 26090) -StealthAddressValidatorTest:test_external_call_execution() (gas: 2112709) -StealthAddressValidatorTest:test_fail_validate_not_activate() (gas: 303548) -StealthAddressValidatorTest:test_fail_validate_wrongsignature() (gas: 1630406) -StealthAddressValidatorTest:test_get_nonce() (gas: 25188) -StealthAddressValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 19873, ~: 19873) -StealthAddressValidatorTest:test_initialize() (gas: 1817402) -StealthAddressValidatorTest:test_initialize_twice() (gas: 1614285) -StealthAddressValidatorTest:test_mode_2() (gas: 1848919) -StealthAddressValidatorTest:test_revert_when_mode_disabled() (gas: 1804567) -StealthAddressValidatorTest:test_set_default_validator() (gas: 2025016) -StealthAddressValidatorTest:test_set_execution() (gas: 2070181) -StealthAddressValidatorTest:test_should_emit_event_on_receive() (gas: 23273) -StealthAddressValidatorTest:test_should_receive_erc1155() (gas: 700331) -StealthAddressValidatorTest:test_should_receive_erc1155_batch() (gas: 727528) -StealthAddressValidatorTest:test_should_receive_erc721() (gas: 597506) -StealthAddressValidatorTest:test_should_return_address_if_deployed() (gas: 1618159) -StealthAddressValidatorTest:test_stealth_validate_sig_aggsig() (gas: 2994026) -StealthAddressValidatorTest:test_stealth_validate_userop_aggsig() (gas: 3015023) -StealthAddressValidatorTest:test_sudo() (gas: 1781012) -StealthAddressValidatorTest:test_sudo_wrongSig() (gas: 1713761) -StealthAddressValidatorTest:test_upgrade() (gas: 21301) -StealthAddressValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27019) -StealthAddressValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23428) -StealthAddressValidatorTest:test_validate_signature() (gas: 3517497) -TestCallee:test_ignore() (gas: 249) -TestCounter:test_ignore() (gas: 164) -TestERC1155:test_ignore() (gas: 313) -TestERC20:test_ignore() (gas: 389) -TestERC721:test_ignore() (gas: 399) -TestExecutor:test_ignore() (gas: 130) -TestPaymaster:test_ignore() (gas: 174) -TestValidator:test_ignore() (gas: 351) -WebAuthnFclValidatorTest:test_default_validator_disable() (gas: 918686) -WebAuthnFclValidatorTest:test_default_validator_enable() (gas: 945065) -WebAuthnFclValidatorTest:test_disable_mode() (gas: 933312) -WebAuthnFclValidatorTest:test_dontRevertForDummySig() (gas: 32708) -WebAuthnFclValidatorTest:test_eip712() (gas: 15953) -WebAuthnFclValidatorTest:test_enable_then_mode_1() (gas: 1390147) -WebAuthnFclValidatorTest:test_external_call_batch_execute_fail() (gas: 25082) +KernelECDSATest:test_revert_when_mode_disabled() (gas: 209038) +KernelECDSATest:test_set_default_validator() (gas: 488911) +KernelECDSATest:test_set_default_validator() (gas: 495350) +KernelECDSATest:test_set_execution() (gas: 530141) +KernelECDSATest:test_set_execution() (gas: 540583) +KernelECDSATest:test_should_emit_event_on_receive() (gas: 22287) +KernelECDSATest:test_should_emit_event_on_receive() (gas: 22287) +KernelECDSATest:test_should_receive_erc1155() (gas: 859668) +KernelECDSATest:test_should_receive_erc1155() (gas: 859712) +KernelECDSATest:test_should_receive_erc1155_batch() (gas: 887339) +KernelECDSATest:test_should_receive_erc1155_batch() (gas: 887340) +KernelECDSATest:test_should_receive_erc721() (gas: 625633) +KernelECDSATest:test_should_receive_erc721() (gas: 625655) +KernelECDSATest:test_should_return_address_if_deployed() (gas: 21491) +KernelECDSATest:test_should_return_address_if_deployed() (gas: 21494) +KernelECDSATest:test_sudo() (gas: 169895) +KernelECDSATest:test_sudo() (gas: 179673) +KernelECDSATest:test_sudo_wrongSig() (gas: 102225) +KernelECDSATest:test_sudo_wrongSig() (gas: 115727) +KernelECDSATest:test_transfer_ownership() (gas: 183729) +KernelECDSATest:test_upgrade() (gas: 21204) +KernelECDSATest:test_upgrade() (gas: 21311) +KernelECDSATest:test_validateUserOp_fail_invalid_mode() (gas: 26572) +KernelECDSATest:test_validateUserOp_fail_invalid_mode() (gas: 26595) +KernelECDSATest:test_validateUserOp_fail_not_entryPoint() (gas: 23483) +KernelECDSATest:test_validateUserOp_fail_not_entryPoint() (gas: 23506) +KernelECDSATest:test_validate_signature() (gas: 155498) +KernelECDSATest:test_validate_signature() (gas: 195025) +KernelECDSATypedTest:test_default_validator_disable() (gas: 185197) +KernelECDSATypedTest:test_default_validator_enable() (gas: 192490) +KernelECDSATypedTest:test_disable_mode() (gas: 186804) +KernelECDSATypedTest:test_eip712() (gas: 15059) +KernelECDSATypedTest:test_enable_then_mode_1() (gas: 291831) +KernelECDSATypedTest:test_external_call_batch_execute_fail() (gas: 28808) +KernelECDSATypedTest:test_external_call_batch_execute_success() (gas: 26322) +KernelECDSATypedTest:test_external_call_default() (gas: 28753) +KernelECDSATypedTest:test_external_call_execute_delegatecall_fail() (gas: 27727) +KernelECDSATypedTest:test_external_call_execute_delegatecall_option_fail() (gas: 25561) +KernelECDSATypedTest:test_external_call_execute_delegatecall_success() (gas: 24879) +KernelECDSATypedTest:test_external_call_execute_fail() (gas: 27986) +KernelECDSATypedTest:test_external_call_execute_success() (gas: 25343) +KernelECDSATypedTest:test_external_call_execution() (gas: 586886) +KernelECDSATypedTest:test_fail_validate_not_activate() (gas: 374629) +KernelECDSATypedTest:test_fail_validate_wrongsignature() (gas: 35730) +KernelECDSATypedTest:test_get_nonce() (gas: 24914) +KernelECDSATypedTest:test_get_nonce(uint192) (runs: 1024, μ: 19561, ~: 19561) +KernelECDSATypedTest:test_ignore() (gas: 231) +KernelECDSATypedTest:test_initialize() (gas: 153746) +KernelECDSATypedTest:test_initialize_twice() (gas: 18215) +KernelECDSATypedTest:test_mode_2() (gas: 253563) +KernelECDSATypedTest:test_revert_when_mode_disabled() (gas: 204387) +KernelECDSATypedTest:test_set_default_validator() (gas: 499602) +KernelECDSATypedTest:test_set_execution() (gas: 544835) +KernelECDSATypedTest:test_should_emit_event_on_receive() (gas: 22287) +KernelECDSATypedTest:test_should_receive_erc1155() (gas: 859712) +KernelECDSATypedTest:test_should_receive_erc1155_batch() (gas: 887339) +KernelECDSATypedTest:test_should_receive_erc721() (gas: 625655) +KernelECDSATypedTest:test_should_return_address_if_deployed() (gas: 21494) +KernelECDSATypedTest:test_sudo() (gas: 183925) +KernelECDSATypedTest:test_sudo_wrongSig() (gas: 116245) +KernelECDSATypedTest:test_upgrade() (gas: 21204) +KernelECDSATypedTest:test_validateUserOp_fail_invalid_mode() (gas: 26572) +KernelECDSATypedTest:test_validateUserOp_fail_not_entryPoint() (gas: 23483) +KernelECDSATypedTest:test_validate_signature() (gas: 191688) +KernelHelperTest:testIntersect(uint48,uint48,uint48,uint48) (runs: 1024, μ: 1415, ~: 1419) +KillSwitchValidatorTest:test_default_validator_disable() (gas: 180990) +KillSwitchValidatorTest:test_default_validator_enable() (gas: 188633) +KillSwitchValidatorTest:test_disable_mode() (gas: 182486) +KillSwitchValidatorTest:test_eip712() (gas: 15126) +KillSwitchValidatorTest:test_enable_then_mode_1() (gas: 351532) +KillSwitchValidatorTest:test_external_call_batch_execute_fail() (gas: 28897) +KillSwitchValidatorTest:test_external_call_batch_execute_success() (gas: 26278) +KillSwitchValidatorTest:test_external_call_default() (gas: 28775) +KillSwitchValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 27793) +KillSwitchValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 25605) +KillSwitchValidatorTest:test_external_call_execute_delegatecall_success() (gas: 24945) +KillSwitchValidatorTest:test_external_call_execute_fail() (gas: 28030) +KillSwitchValidatorTest:test_external_call_execute_success() (gas: 25343) +KillSwitchValidatorTest:test_external_call_execution() (gas: 582720) +KillSwitchValidatorTest:test_fail_validate_not_activate() (gas: 374629) +KillSwitchValidatorTest:test_fail_validate_wrongsignature() (gas: 33461) +KillSwitchValidatorTest:test_force_unblock() (gas: 398854) +KillSwitchValidatorTest:test_get_nonce() (gas: 24936) +KillSwitchValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 19561, ~: 19561) +KillSwitchValidatorTest:test_ignore() (gas: 209) +KillSwitchValidatorTest:test_initialize() (gas: 154273) +KillSwitchValidatorTest:test_initialize_twice() (gas: 18288) +KillSwitchValidatorTest:test_mode_2() (gas: 315241) +KillSwitchValidatorTest:test_revert_when_mode_disabled() (gas: 200109) +KillSwitchValidatorTest:test_set_default_validator() (gas: 495459) +KillSwitchValidatorTest:test_set_execution() (gas: 540647) +KillSwitchValidatorTest:test_should_emit_event_on_receive() (gas: 22287) +KillSwitchValidatorTest:test_should_fail_with_not_implemented_isValidSignature() (gas: 9199) +KillSwitchValidatorTest:test_should_fail_with_not_implemented_isValidSignature(bytes32,bytes) (runs: 1024, μ: 9503, ~: 9456) +KillSwitchValidatorTest:test_should_fail_with_not_implemented_validCaller() (gas: 9290) +KillSwitchValidatorTest:test_should_fail_with_not_implemented_validCaller(address,bytes) (runs: 1024, μ: 9793, ~: 9745) +KillSwitchValidatorTest:test_should_receive_erc1155() (gas: 859712) +KillSwitchValidatorTest:test_should_receive_erc1155_batch() (gas: 887273) +KillSwitchValidatorTest:test_should_receive_erc721() (gas: 625678) +KillSwitchValidatorTest:test_should_return_address_if_deployed() (gas: 21545) +KillSwitchValidatorTest:test_sudo() (gas: 179715) +KillSwitchValidatorTest:test_sudo_wrongSig() (gas: 115725) +KillSwitchValidatorTest:test_upgrade() (gas: 21226) +KillSwitchValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 26594) +KillSwitchValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23505) +KillSwitchValidatorTest:test_validate_signature() (gas: 195118) +SessionKeyValidatorTest:test_default_validator_disable() (gas: 180955) +SessionKeyValidatorTest:test_default_validator_enable() (gas: 188686) +SessionKeyValidatorTest:test_disable_mode() (gas: 182538) +SessionKeyValidatorTest:test_eip712() (gas: 15166) +SessionKeyValidatorTest:test_enable_then_mode_1() (gas: 287585) +SessionKeyValidatorTest:test_external_call_batch_execute_fail() (gas: 28913) +SessionKeyValidatorTest:test_external_call_batch_execute_success() (gas: 26404) +SessionKeyValidatorTest:test_external_call_default() (gas: 28820) +SessionKeyValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 27749) +SessionKeyValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 25605) +SessionKeyValidatorTest:test_external_call_execute_delegatecall_success() (gas: 25010) +SessionKeyValidatorTest:test_external_call_execute_fail() (gas: 28030) +SessionKeyValidatorTest:test_external_call_execute_success() (gas: 25387) +SessionKeyValidatorTest:test_external_call_execution() (gas: 582763) +SessionKeyValidatorTest:test_fail_validate_not_activate() (gas: 374629) +SessionKeyValidatorTest:test_fail_validate_wrongsignature() (gas: 33448) +SessionKeyValidatorTest:test_get_nonce() (gas: 24914) +SessionKeyValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 19584, ~: 19584) +SessionKeyValidatorTest:test_ignore() (gas: 209) +SessionKeyValidatorTest:test_initialize() (gas: 154229) +SessionKeyValidatorTest:test_initialize_twice() (gas: 18244) +SessionKeyValidatorTest:test_mode_2() (gas: 251232) +SessionKeyValidatorTest:test_revert_when_mode_disabled() (gas: 200149) +SessionKeyValidatorTest:test_scenario_batch((uint8,uint8,uint8,uint8,uint48,uint48,uint48,uint48,bool,bool,bool,bool,bool),(uint8)) (runs: 1024, μ: 58166090, ~: 56971973) +SessionKeyValidatorTest:test_scenario_non_batch((uint8,uint8,uint8,uint8,uint48,uint48,uint48,uint48,bool,bool,bool,bool,bool)) (runs: 1024, μ: 54097883, ~: 56753303) +SessionKeyValidatorTest:test_set_default_validator() (gas: 495379) +SessionKeyValidatorTest:test_set_execution() (gas: 540624) +SessionKeyValidatorTest:test_should_emit_event_on_receive() (gas: 22287) +SessionKeyValidatorTest:test_should_receive_erc1155() (gas: 859735) +SessionKeyValidatorTest:test_should_receive_erc1155_batch() (gas: 887339) +SessionKeyValidatorTest:test_should_receive_erc721() (gas: 625655) +SessionKeyValidatorTest:test_should_return_address_if_deployed() (gas: 21545) +SessionKeyValidatorTest:test_sudo() (gas: 179702) +SessionKeyValidatorTest:test_sudo_wrongSig() (gas: 115756) +SessionKeyValidatorTest:test_upgrade() (gas: 21204) +SessionKeyValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 26550) +SessionKeyValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23483) +SessionKeyValidatorTest:test_validate_signature() (gas: 195105) +TestCallee:test_ignore() (gas: 184) +TestCounter:test_ignore() (gas: 120) +TestERC1155:test_ignore() (gas: 186) +TestERC20:test_ignore() (gas: 164) +TestERC721:test_ignore() (gas: 140) +TestExecutor:test_ignore() (gas: 120) +TestPaymaster:test_ignore() (gas: 120) +TestValidator:test_ignore() (gas: 206) +WebAuthnFclValidatorTest:test_default_validator_disable() (gas: 892468) +WebAuthnFclValidatorTest:test_default_validator_enable() (gas: 917513) +WebAuthnFclValidatorTest:test_disable_mode() (gas: 906453) +WebAuthnFclValidatorTest:test_dontRevertForDummySig() (gas: 33996) +WebAuthnFclValidatorTest:test_eip712() (gas: 15126) +WebAuthnFclValidatorTest:test_enable_then_mode_1() (gas: 1350842) +WebAuthnFclValidatorTest:test_external_call_batch_execute_fail() (gas: 23988) WebAuthnFclValidatorTest:test_external_call_batch_execute_success() (gas: 0) WebAuthnFclValidatorTest:test_external_call_default() (gas: 0) WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_fail() (gas: 0) -WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 21982) +WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_option_fail() (gas: 20913) WebAuthnFclValidatorTest:test_external_call_execute_delegatecall_success() (gas: 0) -WebAuthnFclValidatorTest:test_external_call_execute_fail() (gas: 21228) +WebAuthnFclValidatorTest:test_external_call_execute_fail() (gas: 21042) WebAuthnFclValidatorTest:test_external_call_execute_success() (gas: 0) WebAuthnFclValidatorTest:test_external_call_execution() (gas: 0) -WebAuthnFclValidatorTest:test_fail_validate_InvalidWebAuthnData() (gas: 397146) -WebAuthnFclValidatorTest:test_fail_validate_not_activate() (gas: 304424) -WebAuthnFclValidatorTest:test_fail_validate_wrongsignature() (gas: 792685) -WebAuthnFclValidatorTest:test_get_nonce() (gas: 25621) -WebAuthnFclValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 20156, ~: 20156) -WebAuthnFclValidatorTest:test_initialize() (gas: 178514) -WebAuthnFclValidatorTest:test_initialize_twice() (gas: 20827) -WebAuthnFclValidatorTest:test_mode_2() (gas: 1350498) -WebAuthnFclValidatorTest:test_revert_when_mode_disabled() (gas: 950311) -WebAuthnFclValidatorTest:test_set_default_validator() (gas: 1165253) -WebAuthnFclValidatorTest:test_set_execution() (gas: 1233695) -WebAuthnFclValidatorTest:test_should_emit_event_on_receive() (gas: 23456) -WebAuthnFclValidatorTest:test_should_receive_erc1155() (gas: 700487) -WebAuthnFclValidatorTest:test_should_receive_erc1155_batch() (gas: 727747) -WebAuthnFclValidatorTest:test_should_receive_erc721() (gas: 597662) -WebAuthnFclValidatorTest:test_should_return_address_if_deployed() (gas: 24521) -WebAuthnFclValidatorTest:test_sudo() (gas: 933913) -WebAuthnFclValidatorTest:test_sudo_wrongSig() (gas: 868964) -WebAuthnFclValidatorTest:test_upgrade() (gas: 21643) -WebAuthnFclValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 27368) -WebAuthnFclValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23656) -WebAuthnFclValidatorTest:test_validate_signature() (gas: 779688) -WebAuthnFclValidatorTest:test_webAuthnSignatureGeneration(bytes32,uint256) (runs: 1024, μ: 1330494, ~: 1250861) -WebAuthnFclValidatorTest:test_webAuthnSignatureGeneration_solo() (gas: 1162420) \ No newline at end of file +WebAuthnFclValidatorTest:test_fail_validate_InvalidWebAuthnData() (gas: 381009) +WebAuthnFclValidatorTest:test_fail_validate_not_activate() (gas: 374618) +WebAuthnFclValidatorTest:test_fail_validate_wrongsignature() (gas: 763214) +WebAuthnFclValidatorTest:test_get_nonce() (gas: 24914) +WebAuthnFclValidatorTest:test_get_nonce(uint192) (runs: 1024, μ: 19561, ~: 19561) +WebAuthnFclValidatorTest:test_initialize() (gas: 178292) +WebAuthnFclValidatorTest:test_initialize_twice() (gas: 20501) +WebAuthnFclValidatorTest:test_mode_2() (gas: 1311901) +WebAuthnFclValidatorTest:test_revert_when_mode_disabled() (gas: 924091) +WebAuthnFclValidatorTest:test_set_default_validator() (gas: 1211266) +WebAuthnFclValidatorTest:test_set_execution() (gas: 1276676) +WebAuthnFclValidatorTest:test_should_emit_event_on_receive() (gas: 22287) +WebAuthnFclValidatorTest:test_should_receive_erc1155() (gas: 859701) +WebAuthnFclValidatorTest:test_should_receive_erc1155_batch() (gas: 887273) +WebAuthnFclValidatorTest:test_should_receive_erc721() (gas: 625633) +WebAuthnFclValidatorTest:test_should_return_address_if_deployed() (gas: 23765) +WebAuthnFclValidatorTest:test_sudo() (gas: 906016) +WebAuthnFclValidatorTest:test_sudo_wrongSig() (gas: 841531) +WebAuthnFclValidatorTest:test_upgrade() (gas: 21226) +WebAuthnFclValidatorTest:test_validateUserOp_fail_invalid_mode() (gas: 26594) +WebAuthnFclValidatorTest:test_validateUserOp_fail_not_entryPoint() (gas: 23483) +WebAuthnFclValidatorTest:test_validate_signature() (gas: 751849) +WebAuthnFclValidatorTest:test_webAuthnSignatureGeneration(bytes32,uint256) (runs: 1024, μ: 1277845, ~: 1199457) +WebAuthnFclValidatorTest:test_webAuthnSignatureGeneration_solo() (gas: 1116434) \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 744ac54b..df6cfb84 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "lib/I4337"] path = lib/I4337 url = https://github.com/leekt/I4337 +[submodule "lib/FreshCryptoLib"] + path = lib/FreshCryptoLib + url = https://github.com/rdubois-crypto/FreshCryptoLib diff --git a/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722702.json b/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722702.json deleted file mode 100644 index 63025e8e..00000000 --- a/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722702.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "transactions": [ - { - "hash": null, - "transactionType": "CREATE", - "contractName": "WebAuthnWrapper", - "contractAddress": "0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519", - "function": null, - "arguments": null, - "transaction": { - "type": "0x02", - "from": "0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38", - "gas": "0x12e329", - "data": "0x6080806040523461001a576110449081610020823930815050f35b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c630d5efec91461002857600080fd5b6101203660031901126100c35767ffffffffffffffff6004358181116100c6576100569036906004016100ca565b90916024359360ff60f81b851685036100c3576044359182116100c3576100bf6100ad86868661008936600489016100ca565b610095939193366100fd565b9361009f3661010a565b956084359460643594610118565b60405190151581529081906020820190565b0390f35b80fd5b8280fd5b9181601f840112156100f85782359167ffffffffffffffff83116100f857602083818601950101116100f857565b600080fd5b9060a49160e4116100f857565b9060e491610124116100f857565b939291979695949094602098806101406101328989610258565b356001600160f81b03191690565b169060ff60f81b8091169116036102465760405189810192835291829003808352601f199261017b916101769060200182610293565b610f0f565b9061018682516102fa565b80518b82019286018337519020916101b560405191826101a98d8201809661032c565b03908101835282610293565b51902003610234578691600091856101d46101cf8261036d565b6102fa565b95858701376101e86040518093819361038e565b039060025afa1561022f5761020f600091869384845191830101526040519182809261032c565b039060025afa1561022f5761022c928201359135906000516103c4565b90565b61039c565b60405163ebab5d2960e01b8152600490fd5b604051637e49a3c960e11b8152600490fd5b90602010156102675760200190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102b557604052565b61027d565b67ffffffffffffffff81116102b557601f01601f191660200190565b604051906020820182811067ffffffffffffffff8211176102b55760405260008252565b90610304826102ba565b6103116040519182610293565b8281528092610322601f19916102ba565b0190602036910137565b9081519160005b838110610344575050016000815290565b8060208092840101518185015201610333565b634e487b7160e01b600052601160045260246000fd5b906020820180921161037b57565b610357565b906002820180921161037b57565b908092918237016000815290565b6040513d6000823e3d90fd5b9060008051602061100483398151915291820391821161037b57565b60209382359390928501359190841580156104aa575b80156104a2575b801561048a575b61047f576103f684826104c2565b1561047f5760405192868452868085015286604085015260608401527fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f6080840152600080516020611004833981519152958660a08501528360c0816005600019fa156100f8576104799386610473945181818909940991610583565b916103a8565b90081590565b505050505050600090565b506000805160206110048339815191528310156103e8565b5082156103e1565b506000805160206110048339815191528510156103da565b80158061057b575b8015610564575b801561054d575b61054657600160601b63ffffffff60c01b03199081907f5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b90829081807fffffffff00000001000000000000000000000000fffffffffffffffffffffffc830991818180090908089180091490565b5050600090565b50600160601b63ffffffff60c01b031982146104d8565b50600160601b63ffffffff60c01b031981146104d1565b5081156104ca565b60009260ff92849291801580610c67575b610c5b576105a28284610c6f565b9095861580610c53575b610c33575b82811c60028a60fe1c16015b15610c1957600183821c1660028a831c60011b160160018114610be0575b60028114610bcf575b600314610bc2575b600198600019919091019692959493928992915b8a896000191161066f575050505050505050505060405191606083015260208252602080830152602060408301526000805160206110248339815191526080830152600163ffffffff60601b0360601b19918260a082015260208160c0816005600019fa156100f85751900990565b90919293949596979899600163ffffffff60601b0360601b198960020998600160601b63ffffffff60c01b03198a800999600160601b63ffffffff60c01b03198b840990600160601b63ffffffff60c01b0319908c900993849390600160601b63ffffffff60c01b03199081908181850890600160601b63ffffffff60c01b031990810385080960030998600160601b63ffffffff60c01b03199085099e600160601b63ffffffff60c01b0319908d099b600160601b63ffffffff60c01b031991829182910960008051602061102483398151915209600160601b63ffffffff60c01b03198a80090897600160601b63ffffffff60c01b031991829081038a08900992600160601b63ffffffff60c01b03199184918391900908918a8c1c600116848d1c60011b6002160115610ba35760018c600286838f841c16921c831b160114610b6c575b838c8c6002600182841c168185851c60011b160114610b59575b6003926001600292841c16921c60011b160114610b50575b8915610b3d57600160601b63ffffffff60c01b031990839082908f90090890600160601b63ffffffff60c01b0319908782039082908c900908988115610909575b600160601b63ffffffff60c01b031990818b800990099b600160601b63ffffffff60c01b031990818b8181800909900995600160601b63ffffffff60c01b031990818b80099009600160601b63ffffffff60c01b0319808260008051602061102483398151915209600160601b63ffffffff60c01b0319808d8181800909600160601b63ffffffff60c01b031990810390868009080899600160601b63ffffffff60c01b031993849182908181800909900991600160601b63ffffffff60c01b03199182908c82039008090896985b600019019796959493929190610600565b8961082957959b9a9850600160601b63ffffffff60c01b0319905080808360008051602061102483398151915209600160601b63ffffffff60c01b03198460008051602061102483398151915209098c0999600160601b63ffffffff60c01b0319808781038e08600160601b63ffffffff60c01b0319888f0809600160601b63ffffffff60c01b03199060030990600160601b63ffffffff60c01b0319908180808660008051602061102483398151915209600160601b63ffffffff60c01b0319876000805160206110248339815191520909600160601b63ffffffff60c01b03198660008051602061102483398151915209090995600160601b63ffffffff60c01b03199081808560008051602061102483398151915209600160601b63ffffffff60c01b0319866000805160206110248339815191520909099b600160601b63ffffffff60c01b0319908190819081808760008051602061102483398151915209600160601b63ffffffff60c01b0319886000805160206110248339815191520909900960008051602061102483398151915209600160601b63ffffffff60c01b0319838009089a600160601b63ffffffff60c01b03199283908180808360008051602061102483398151915209600160601b63ffffffff60c01b0319846000805160206110248339815191520909600160601b63ffffffff60c01b03198360008051602061102483398151915209090991600160601b63ffffffff60c01b03199182908e82039008900908966108f8565b60019c50909a9098508b955090506108f8565b505082846107e8565b508a93508992508591508d90508c6107d0565b5050600080516020610fe48339815191527f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f56107b6565b50979a9499600160601b63ffffffff60c01b03199190910397506108f8565b94509550849580946105ec565b9550965083966003849690506105e4565b600080516020610fe483398151915298507f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f596506105db565b60001901600160028185841c16918b841c901b16016105bd565b9790916000805160206110048339815191529182039008906000976105b1565b5081156105ac565b50505050505050600090565b508615610594565b7f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f59291600080516020610fe4833981519152918115610dc75780831480610dbe575b15610da75750600160601b63ffffffff60c01b03199190508184600209918083800992818080808781818909950995817fffffffff00000001000000000000000000000000fffffffffffffffffffffffe816001840892080960030981808080866000805160206110248339815191520981858009089981600181818b099a099709810393898203900890090893915b60405190602082526020808301526020604083015260608201526000805160206110248339815191526080820152600163ffffffff60601b0360601b19928360a083015260208260c0816005600019fa156100f857838080935180950980099009930990565b909150610db5929350610dcd565b91939291610d41565b50818514610cb1565b50509190565b60019283927f94e82e0c1ed3bdb90743191a9c5bbf0d88fc827fd214cc5f0b5ec6ba27673d69600163ffffffff60601b0360601b198095818094817fb01cbd1c01e58065711814b583f061e9d431cca994cea1313449bf97c840ae0a9a8b920908950908928080808087800996870994818088600080516020610fe483398151915209918180808560008051602061102483398151915209818b810381868009080893818a869d0994820390080908946001099260010990565b604051906060820182811067ffffffffffffffff8211176102b557604052604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b600281901b91906001600160fe1b0381160361037b57565b805115610fda57610f1e610e87565b610f3d6101cf610f38610f318551610380565b6003900490565b610ef7565b9160208301918182518301915b828210610f8857505050600390510680600114610f7e57600214610f75575b819003601f1901815290565b60001901610f69565b5060011901610f69565b9091936004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c1688010151600286015316850101519082015301939190610f4a565b5061022c6102d656fe6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551ffffffff00000001000000000000000000000000fffffffffffffffffffffffd", - "nonce": "0x0", - "accessList": [] - }, - "additionalContracts": [], - "isFixedGasLimit": false - }, - { - "hash": null, - "transactionType": "CREATE2", - "contractName": "WebAuthnValidator", - "contractAddress": "0x4Ab13AE00422a94AA9F187f8d7EBBF75dAfc0f3b", - "function": null, - "arguments": null, - "transaction": { - "type": "0x02", - "from": "0x7caf754c934710d7c73bc453654552beca38223f", - "to": "0x4e59b44847b379578588920ca78fbf26c0b4956c", - "gas": "0x92893", - "value": "0x0", - "data": "0x00000000000000000000000000000000000000000000000000000000000000006080806040523461001657610671908161001c8239f35b600080fdfe608060408181526004918236101561001657600080fd5b600090813560e01c9081630c959556146101c957508063333daf921461018a5780633a871cdd14610143578063857cdbb8146100fe5780638fc925aa146100b257639ea9bd591461006657600080fd5b346100af57816003193601126100af5761007e610288565b506024359067ffffffffffffffff82116100af57506100a09036908401610255565b50505163d623472560e01b8152fd5b80fd5b5091829160203660031901126100fa57813567ffffffffffffffff81116100f5576001926100e291369101610255565b5050338352826020528220828155015580f35b505050fd5b5050fd5b50903461013f57602036600319011261013f579081906001600160a01b03610124610288565b16815280602052206001815491015482519182526020820152f35b5080fd5b50600319906060368301126100af5783359167ffffffffffffffff831161013f576101609083360301126100af5750602092610183916024359101610345565b9051908152f35b50346100af57816003193601126100af576024359067ffffffffffffffff82116100af57506020926101c26101839236908301610255565b91356103dc565b90508284602036600319011261024d57803567ffffffffffffffff81116102515782916101f891369101610255565b908093918101031261024d578160207f09b72addb8ad094c9a8a8a968606cc44820134a10b0c58144a18cce1b43e2b20933591013590338652856020528160018488208381550155845260208401523392a280f35b8380fd5b8480fd5b9181601f840112156102835782359167ffffffffffffffff8311610283576020838186019501011161028357565b600080fd5b600435906001600160a01b038216820361028357565b6040810190811067ffffffffffffffff8211176102ba57604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102ba57604052565b67ffffffffffffffff81116102ba57601f01601f191660200190565b92919261031a826102f2565b9161032860405193846102d0565b829481845281830111610283578281602093846000960137010152565b80356001600160a01b03811692908390036102835760009283528260205260408320916001604051936103778561029e565b805485520154602084015261014081013590601e1981360301821215610251570180359067ffffffffffffffff821161025157602001908036038213610251576103ce9392916103c891369161030e565b916104d4565b156103d95750600190565b90565b6103c861041493923360005260006020526040600020936001604051956104028761029e565b8054875201546020860152369161030e565b61041d57600190565b600090565b60005b8381106104355750506000910152565b8181015183820152602001610425565b81601f8201121561028357805161045b816102f2565b9261046960405194856102d0565b81845260208284010111610283576103d99160208085019101610422565b906020916104a081518092818552858086019101610422565b601f01601f1916010190565b6000915b600283106104bd57505050565b6001908251815260208091019201920191906104b0565b909180519260209382019260a08386860195031261028357848301519267ffffffffffffffff9384811161028357858761051092840101610445565b93604082015190811161028357858761052b92840101610445565b9460608201519080609f84011215610283576040519261054a8461029e565b839060c08101928311610283579060808a9795989694939201905b82821061066157505050906105ed85966105f7936105bc976040519461058a8661029e565b805186520151898501526105d86040519a8b998a99630d5efec960e01b8b5261012060048c01526101248b0190610487565b600160f81b60248b01528981036003190160448b015290610487565b956064880152608487015260a48601906104ac565b60e48401906104ac565b0381735b73c5498c1e3b4dba84de0f1833c4a029d905195af49182156106555760009261062357505090565b81813d831161064e575b61063781836102d0565b8101031261013f57519081151582036100af575090565b503d61062d565b6040513d6000823e3d90fd5b815181528a97918201910161056556", - "nonce": "0x2554", - "accessList": [] - }, - "additionalContracts": [], - "isFixedGasLimit": false - } - ], - "receipts": [], - "libraries": [ - "src/utils/WebAuthnWrapper.sol:WebAuthnWrapper:0x5b73c5498c1e3b4dba84de0f1833c4a029d90519" - ], - "pending": [], - "returns": {}, - "timestamp": 1704722702, - "chain": 80001, - "multi": false, - "commit": "a611cec" -} \ No newline at end of file diff --git a/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722737.json b/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722737.json deleted file mode 100644 index f3a73f41..00000000 --- a/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722737.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "transactions": [ - { - "hash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", - "transactionType": "CREATE", - "contractName": "WebAuthnWrapper", - "contractAddress": "0x9C4538396993166b7F7ec93552C8763d4742DEDB", - "function": null, - "arguments": null, - "transaction": { - "type": "0x02", - "from": "0x7caf754c934710d7c73bc453654552beca38223f", - "gas": "0x12e329", - "data": "0x6080806040523461001a576110449081610020823930815050f35b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c630d5efec91461002857600080fd5b6101203660031901126100c35767ffffffffffffffff6004358181116100c6576100569036906004016100ca565b90916024359360ff60f81b851685036100c3576044359182116100c3576100bf6100ad86868661008936600489016100ca565b610095939193366100fd565b9361009f3661010a565b956084359460643594610118565b60405190151581529081906020820190565b0390f35b80fd5b8280fd5b9181601f840112156100f85782359167ffffffffffffffff83116100f857602083818601950101116100f857565b600080fd5b9060a49160e4116100f857565b9060e491610124116100f857565b939291979695949094602098806101406101328989610258565b356001600160f81b03191690565b169060ff60f81b8091169116036102465760405189810192835291829003808352601f199261017b916101769060200182610293565b610f0f565b9061018682516102fa565b80518b82019286018337519020916101b560405191826101a98d8201809661032c565b03908101835282610293565b51902003610234578691600091856101d46101cf8261036d565b6102fa565b95858701376101e86040518093819361038e565b039060025afa1561022f5761020f600091869384845191830101526040519182809261032c565b039060025afa1561022f5761022c928201359135906000516103c4565b90565b61039c565b60405163ebab5d2960e01b8152600490fd5b604051637e49a3c960e11b8152600490fd5b90602010156102675760200190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102b557604052565b61027d565b67ffffffffffffffff81116102b557601f01601f191660200190565b604051906020820182811067ffffffffffffffff8211176102b55760405260008252565b90610304826102ba565b6103116040519182610293565b8281528092610322601f19916102ba565b0190602036910137565b9081519160005b838110610344575050016000815290565b8060208092840101518185015201610333565b634e487b7160e01b600052601160045260246000fd5b906020820180921161037b57565b610357565b906002820180921161037b57565b908092918237016000815290565b6040513d6000823e3d90fd5b9060008051602061100483398151915291820391821161037b57565b60209382359390928501359190841580156104aa575b80156104a2575b801561048a575b61047f576103f684826104c2565b1561047f5760405192868452868085015286604085015260608401527fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f6080840152600080516020611004833981519152958660a08501528360c0816005600019fa156100f8576104799386610473945181818909940991610583565b916103a8565b90081590565b505050505050600090565b506000805160206110048339815191528310156103e8565b5082156103e1565b506000805160206110048339815191528510156103da565b80158061057b575b8015610564575b801561054d575b61054657600160601b63ffffffff60c01b03199081907f5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b90829081807fffffffff00000001000000000000000000000000fffffffffffffffffffffffc830991818180090908089180091490565b5050600090565b50600160601b63ffffffff60c01b031982146104d8565b50600160601b63ffffffff60c01b031981146104d1565b5081156104ca565b60009260ff92849291801580610c67575b610c5b576105a28284610c6f565b9095861580610c53575b610c33575b82811c60028a60fe1c16015b15610c1957600183821c1660028a831c60011b160160018114610be0575b60028114610bcf575b600314610bc2575b600198600019919091019692959493928992915b8a896000191161066f575050505050505050505060405191606083015260208252602080830152602060408301526000805160206110248339815191526080830152600163ffffffff60601b0360601b19918260a082015260208160c0816005600019fa156100f85751900990565b90919293949596979899600163ffffffff60601b0360601b198960020998600160601b63ffffffff60c01b03198a800999600160601b63ffffffff60c01b03198b840990600160601b63ffffffff60c01b0319908c900993849390600160601b63ffffffff60c01b03199081908181850890600160601b63ffffffff60c01b031990810385080960030998600160601b63ffffffff60c01b03199085099e600160601b63ffffffff60c01b0319908d099b600160601b63ffffffff60c01b031991829182910960008051602061102483398151915209600160601b63ffffffff60c01b03198a80090897600160601b63ffffffff60c01b031991829081038a08900992600160601b63ffffffff60c01b03199184918391900908918a8c1c600116848d1c60011b6002160115610ba35760018c600286838f841c16921c831b160114610b6c575b838c8c6002600182841c168185851c60011b160114610b59575b6003926001600292841c16921c60011b160114610b50575b8915610b3d57600160601b63ffffffff60c01b031990839082908f90090890600160601b63ffffffff60c01b0319908782039082908c900908988115610909575b600160601b63ffffffff60c01b031990818b800990099b600160601b63ffffffff60c01b031990818b8181800909900995600160601b63ffffffff60c01b031990818b80099009600160601b63ffffffff60c01b0319808260008051602061102483398151915209600160601b63ffffffff60c01b0319808d8181800909600160601b63ffffffff60c01b031990810390868009080899600160601b63ffffffff60c01b031993849182908181800909900991600160601b63ffffffff60c01b03199182908c82039008090896985b600019019796959493929190610600565b8961082957959b9a9850600160601b63ffffffff60c01b0319905080808360008051602061102483398151915209600160601b63ffffffff60c01b03198460008051602061102483398151915209098c0999600160601b63ffffffff60c01b0319808781038e08600160601b63ffffffff60c01b0319888f0809600160601b63ffffffff60c01b03199060030990600160601b63ffffffff60c01b0319908180808660008051602061102483398151915209600160601b63ffffffff60c01b0319876000805160206110248339815191520909600160601b63ffffffff60c01b03198660008051602061102483398151915209090995600160601b63ffffffff60c01b03199081808560008051602061102483398151915209600160601b63ffffffff60c01b0319866000805160206110248339815191520909099b600160601b63ffffffff60c01b0319908190819081808760008051602061102483398151915209600160601b63ffffffff60c01b0319886000805160206110248339815191520909900960008051602061102483398151915209600160601b63ffffffff60c01b0319838009089a600160601b63ffffffff60c01b03199283908180808360008051602061102483398151915209600160601b63ffffffff60c01b0319846000805160206110248339815191520909600160601b63ffffffff60c01b03198360008051602061102483398151915209090991600160601b63ffffffff60c01b03199182908e82039008900908966108f8565b60019c50909a9098508b955090506108f8565b505082846107e8565b508a93508992508591508d90508c6107d0565b5050600080516020610fe48339815191527f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f56107b6565b50979a9499600160601b63ffffffff60c01b03199190910397506108f8565b94509550849580946105ec565b9550965083966003849690506105e4565b600080516020610fe483398151915298507f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f596506105db565b60001901600160028185841c16918b841c901b16016105bd565b9790916000805160206110048339815191529182039008906000976105b1565b5081156105ac565b50505050505050600090565b508615610594565b7f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f59291600080516020610fe4833981519152918115610dc75780831480610dbe575b15610da75750600160601b63ffffffff60c01b03199190508184600209918083800992818080808781818909950995817fffffffff00000001000000000000000000000000fffffffffffffffffffffffe816001840892080960030981808080866000805160206110248339815191520981858009089981600181818b099a099709810393898203900890090893915b60405190602082526020808301526020604083015260608201526000805160206110248339815191526080820152600163ffffffff60601b0360601b19928360a083015260208260c0816005600019fa156100f857838080935180950980099009930990565b909150610db5929350610dcd565b91939291610d41565b50818514610cb1565b50509190565b60019283927f94e82e0c1ed3bdb90743191a9c5bbf0d88fc827fd214cc5f0b5ec6ba27673d69600163ffffffff60601b0360601b198095818094817fb01cbd1c01e58065711814b583f061e9d431cca994cea1313449bf97c840ae0a9a8b920908950908928080808087800996870994818088600080516020610fe483398151915209918180808560008051602061102483398151915209818b810381868009080893818a869d0994820390080908946001099260010990565b604051906060820182811067ffffffffffffffff8211176102b557604052604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b600281901b91906001600160fe1b0381160361037b57565b805115610fda57610f1e610e87565b610f3d6101cf610f38610f318551610380565b6003900490565b610ef7565b9160208301918182518301915b828210610f8857505050600390510680600114610f7e57600214610f75575b819003601f1901815290565b60001901610f69565b5060011901610f69565b9091936004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c1688010151600286015316850101519082015301939190610f4a565b5061022c6102d656fe6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551ffffffff00000001000000000000000000000000fffffffffffffffffffffffd", - "nonce": "0x2554", - "accessList": [] - }, - "additionalContracts": [], - "isFixedGasLimit": false - }, - { - "hash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", - "transactionType": "CREATE2", - "contractName": "WebAuthnValidator", - "contractAddress": "0x52F06b3E336198BC55f981B10de94B5713f9aE1a", - "function": null, - "arguments": null, - "transaction": { - "type": "0x02", - "from": "0x7caf754c934710d7c73bc453654552beca38223f", - "to": "0x4e59b44847b379578588920ca78fbf26c0b4956c", - "gas": "0x92893", - "value": "0x0", - "data": "0x00000000000000000000000000000000000000000000000000000000000000006080806040523461001657610671908161001c8239f35b600080fdfe608060408181526004918236101561001657600080fd5b600090813560e01c9081630c959556146101c957508063333daf921461018a5780633a871cdd14610143578063857cdbb8146100fe5780638fc925aa146100b257639ea9bd591461006657600080fd5b346100af57816003193601126100af5761007e610288565b506024359067ffffffffffffffff82116100af57506100a09036908401610255565b50505163d623472560e01b8152fd5b80fd5b5091829160203660031901126100fa57813567ffffffffffffffff81116100f5576001926100e291369101610255565b5050338352826020528220828155015580f35b505050fd5b5050fd5b50903461013f57602036600319011261013f579081906001600160a01b03610124610288565b16815280602052206001815491015482519182526020820152f35b5080fd5b50600319906060368301126100af5783359167ffffffffffffffff831161013f576101609083360301126100af5750602092610183916024359101610345565b9051908152f35b50346100af57816003193601126100af576024359067ffffffffffffffff82116100af57506020926101c26101839236908301610255565b91356103dc565b90508284602036600319011261024d57803567ffffffffffffffff81116102515782916101f891369101610255565b908093918101031261024d578160207f09b72addb8ad094c9a8a8a968606cc44820134a10b0c58144a18cce1b43e2b20933591013590338652856020528160018488208381550155845260208401523392a280f35b8380fd5b8480fd5b9181601f840112156102835782359167ffffffffffffffff8311610283576020838186019501011161028357565b600080fd5b600435906001600160a01b038216820361028357565b6040810190811067ffffffffffffffff8211176102ba57604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102ba57604052565b67ffffffffffffffff81116102ba57601f01601f191660200190565b92919261031a826102f2565b9161032860405193846102d0565b829481845281830111610283578281602093846000960137010152565b80356001600160a01b03811692908390036102835760009283528260205260408320916001604051936103778561029e565b805485520154602084015261014081013590601e1981360301821215610251570180359067ffffffffffffffff821161025157602001908036038213610251576103ce9392916103c891369161030e565b916104d4565b156103d95750600190565b90565b6103c861041493923360005260006020526040600020936001604051956104028761029e565b8054875201546020860152369161030e565b61041d57600190565b600090565b60005b8381106104355750506000910152565b8181015183820152602001610425565b81601f8201121561028357805161045b816102f2565b9261046960405194856102d0565b81845260208284010111610283576103d99160208085019101610422565b906020916104a081518092818552858086019101610422565b601f01601f1916010190565b6000915b600283106104bd57505050565b6001908251815260208091019201920191906104b0565b909180519260209382019260a08386860195031261028357848301519267ffffffffffffffff9384811161028357858761051092840101610445565b93604082015190811161028357858761052b92840101610445565b9460608201519080609f84011215610283576040519261054a8461029e565b839060c08101928311610283579060808a9795989694939201905b82821061066157505050906105ed85966105f7936105bc976040519461058a8661029e565b805186520151898501526105d86040519a8b998a99630d5efec960e01b8b5261012060048c01526101248b0190610487565b600160f81b60248b01528981036003190160448b015290610487565b956064880152608487015260a48601906104ac565b60e48401906104ac565b0381739c4538396993166b7f7ec93552c8763d4742dedb5af49182156106555760009261062357505090565b81813d831161064e575b61063781836102d0565b8101031261013f57519081151582036100af575090565b503d61062d565b6040513d6000823e3d90fd5b815181528a97918201910161056556", - "nonce": "0x2555", - "accessList": [] - }, - "additionalContracts": [], - "isFixedGasLimit": false - } - ], - "receipts": [], - "libraries": [ - "src/utils/WebAuthnWrapper.sol:WebAuthnWrapper:0x9c4538396993166b7f7ec93552c8763d4742dedb" - ], - "pending": [ - "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", - "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf" - ], - "returns": {}, - "timestamp": 1704722737, - "chain": 80001, - "multi": false, - "commit": "a611cec" -} \ No newline at end of file diff --git a/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722750.json b/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722750.json deleted file mode 100644 index 3469067a..00000000 --- a/broadcast/DeployWebAuthnValidator.s.sol/80001/run-1704722750.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "transactions": [ - { - "hash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", - "transactionType": "CREATE", - "contractName": "WebAuthnWrapper", - "contractAddress": "0x9C4538396993166b7F7ec93552C8763d4742DEDB", - "function": null, - "arguments": null, - "transaction": { - "type": "0x02", - "from": "0x7caf754c934710d7c73bc453654552beca38223f", - "gas": "0x12e329", - "data": "0x6080806040523461001a576110449081610020823930815050f35b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c630d5efec91461002857600080fd5b6101203660031901126100c35767ffffffffffffffff6004358181116100c6576100569036906004016100ca565b90916024359360ff60f81b851685036100c3576044359182116100c3576100bf6100ad86868661008936600489016100ca565b610095939193366100fd565b9361009f3661010a565b956084359460643594610118565b60405190151581529081906020820190565b0390f35b80fd5b8280fd5b9181601f840112156100f85782359167ffffffffffffffff83116100f857602083818601950101116100f857565b600080fd5b9060a49160e4116100f857565b9060e491610124116100f857565b939291979695949094602098806101406101328989610258565b356001600160f81b03191690565b169060ff60f81b8091169116036102465760405189810192835291829003808352601f199261017b916101769060200182610293565b610f0f565b9061018682516102fa565b80518b82019286018337519020916101b560405191826101a98d8201809661032c565b03908101835282610293565b51902003610234578691600091856101d46101cf8261036d565b6102fa565b95858701376101e86040518093819361038e565b039060025afa1561022f5761020f600091869384845191830101526040519182809261032c565b039060025afa1561022f5761022c928201359135906000516103c4565b90565b61039c565b60405163ebab5d2960e01b8152600490fd5b604051637e49a3c960e11b8152600490fd5b90602010156102675760200190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102b557604052565b61027d565b67ffffffffffffffff81116102b557601f01601f191660200190565b604051906020820182811067ffffffffffffffff8211176102b55760405260008252565b90610304826102ba565b6103116040519182610293565b8281528092610322601f19916102ba565b0190602036910137565b9081519160005b838110610344575050016000815290565b8060208092840101518185015201610333565b634e487b7160e01b600052601160045260246000fd5b906020820180921161037b57565b610357565b906002820180921161037b57565b908092918237016000815290565b6040513d6000823e3d90fd5b9060008051602061100483398151915291820391821161037b57565b60209382359390928501359190841580156104aa575b80156104a2575b801561048a575b61047f576103f684826104c2565b1561047f5760405192868452868085015286604085015260608401527fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f6080840152600080516020611004833981519152958660a08501528360c0816005600019fa156100f8576104799386610473945181818909940991610583565b916103a8565b90081590565b505050505050600090565b506000805160206110048339815191528310156103e8565b5082156103e1565b506000805160206110048339815191528510156103da565b80158061057b575b8015610564575b801561054d575b61054657600160601b63ffffffff60c01b03199081907f5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b90829081807fffffffff00000001000000000000000000000000fffffffffffffffffffffffc830991818180090908089180091490565b5050600090565b50600160601b63ffffffff60c01b031982146104d8565b50600160601b63ffffffff60c01b031981146104d1565b5081156104ca565b60009260ff92849291801580610c67575b610c5b576105a28284610c6f565b9095861580610c53575b610c33575b82811c60028a60fe1c16015b15610c1957600183821c1660028a831c60011b160160018114610be0575b60028114610bcf575b600314610bc2575b600198600019919091019692959493928992915b8a896000191161066f575050505050505050505060405191606083015260208252602080830152602060408301526000805160206110248339815191526080830152600163ffffffff60601b0360601b19918260a082015260208160c0816005600019fa156100f85751900990565b90919293949596979899600163ffffffff60601b0360601b198960020998600160601b63ffffffff60c01b03198a800999600160601b63ffffffff60c01b03198b840990600160601b63ffffffff60c01b0319908c900993849390600160601b63ffffffff60c01b03199081908181850890600160601b63ffffffff60c01b031990810385080960030998600160601b63ffffffff60c01b03199085099e600160601b63ffffffff60c01b0319908d099b600160601b63ffffffff60c01b031991829182910960008051602061102483398151915209600160601b63ffffffff60c01b03198a80090897600160601b63ffffffff60c01b031991829081038a08900992600160601b63ffffffff60c01b03199184918391900908918a8c1c600116848d1c60011b6002160115610ba35760018c600286838f841c16921c831b160114610b6c575b838c8c6002600182841c168185851c60011b160114610b59575b6003926001600292841c16921c60011b160114610b50575b8915610b3d57600160601b63ffffffff60c01b031990839082908f90090890600160601b63ffffffff60c01b0319908782039082908c900908988115610909575b600160601b63ffffffff60c01b031990818b800990099b600160601b63ffffffff60c01b031990818b8181800909900995600160601b63ffffffff60c01b031990818b80099009600160601b63ffffffff60c01b0319808260008051602061102483398151915209600160601b63ffffffff60c01b0319808d8181800909600160601b63ffffffff60c01b031990810390868009080899600160601b63ffffffff60c01b031993849182908181800909900991600160601b63ffffffff60c01b03199182908c82039008090896985b600019019796959493929190610600565b8961082957959b9a9850600160601b63ffffffff60c01b0319905080808360008051602061102483398151915209600160601b63ffffffff60c01b03198460008051602061102483398151915209098c0999600160601b63ffffffff60c01b0319808781038e08600160601b63ffffffff60c01b0319888f0809600160601b63ffffffff60c01b03199060030990600160601b63ffffffff60c01b0319908180808660008051602061102483398151915209600160601b63ffffffff60c01b0319876000805160206110248339815191520909600160601b63ffffffff60c01b03198660008051602061102483398151915209090995600160601b63ffffffff60c01b03199081808560008051602061102483398151915209600160601b63ffffffff60c01b0319866000805160206110248339815191520909099b600160601b63ffffffff60c01b0319908190819081808760008051602061102483398151915209600160601b63ffffffff60c01b0319886000805160206110248339815191520909900960008051602061102483398151915209600160601b63ffffffff60c01b0319838009089a600160601b63ffffffff60c01b03199283908180808360008051602061102483398151915209600160601b63ffffffff60c01b0319846000805160206110248339815191520909600160601b63ffffffff60c01b03198360008051602061102483398151915209090991600160601b63ffffffff60c01b03199182908e82039008900908966108f8565b60019c50909a9098508b955090506108f8565b505082846107e8565b508a93508992508591508d90508c6107d0565b5050600080516020610fe48339815191527f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f56107b6565b50979a9499600160601b63ffffffff60c01b03199190910397506108f8565b94509550849580946105ec565b9550965083966003849690506105e4565b600080516020610fe483398151915298507f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f596506105db565b60001901600160028185841c16918b841c901b16016105bd565b9790916000805160206110048339815191529182039008906000976105b1565b5081156105ac565b50505050505050600090565b508615610594565b7f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f59291600080516020610fe4833981519152918115610dc75780831480610dbe575b15610da75750600160601b63ffffffff60c01b03199190508184600209918083800992818080808781818909950995817fffffffff00000001000000000000000000000000fffffffffffffffffffffffe816001840892080960030981808080866000805160206110248339815191520981858009089981600181818b099a099709810393898203900890090893915b60405190602082526020808301526020604083015260608201526000805160206110248339815191526080820152600163ffffffff60601b0360601b19928360a083015260208260c0816005600019fa156100f857838080935180950980099009930990565b909150610db5929350610dcd565b91939291610d41565b50818514610cb1565b50509190565b60019283927f94e82e0c1ed3bdb90743191a9c5bbf0d88fc827fd214cc5f0b5ec6ba27673d69600163ffffffff60601b0360601b198095818094817fb01cbd1c01e58065711814b583f061e9d431cca994cea1313449bf97c840ae0a9a8b920908950908928080808087800996870994818088600080516020610fe483398151915209918180808560008051602061102483398151915209818b810381868009080893818a869d0994820390080908946001099260010990565b604051906060820182811067ffffffffffffffff8211176102b557604052604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b600281901b91906001600160fe1b0381160361037b57565b805115610fda57610f1e610e87565b610f3d6101cf610f38610f318551610380565b6003900490565b610ef7565b9160208301918182518301915b828210610f8857505050600390510680600114610f7e57600214610f75575b819003601f1901815290565b60001901610f69565b5060011901610f69565b9091936004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c1688010151600286015316850101519082015301939190610f4a565b5061022c6102d656fe6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551ffffffff00000001000000000000000000000000fffffffffffffffffffffffd", - "nonce": "0x2554", - "accessList": [] - }, - "additionalContracts": [], - "isFixedGasLimit": false - }, - { - "hash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", - "transactionType": "CREATE2", - "contractName": "WebAuthnValidator", - "contractAddress": "0x52F06b3E336198BC55f981B10de94B5713f9aE1a", - "function": null, - "arguments": null, - "transaction": { - "type": "0x02", - "from": "0x7caf754c934710d7c73bc453654552beca38223f", - "to": "0x4e59b44847b379578588920ca78fbf26c0b4956c", - "gas": "0x92893", - "value": "0x0", - "data": "0x00000000000000000000000000000000000000000000000000000000000000006080806040523461001657610671908161001c8239f35b600080fdfe608060408181526004918236101561001657600080fd5b600090813560e01c9081630c959556146101c957508063333daf921461018a5780633a871cdd14610143578063857cdbb8146100fe5780638fc925aa146100b257639ea9bd591461006657600080fd5b346100af57816003193601126100af5761007e610288565b506024359067ffffffffffffffff82116100af57506100a09036908401610255565b50505163d623472560e01b8152fd5b80fd5b5091829160203660031901126100fa57813567ffffffffffffffff81116100f5576001926100e291369101610255565b5050338352826020528220828155015580f35b505050fd5b5050fd5b50903461013f57602036600319011261013f579081906001600160a01b03610124610288565b16815280602052206001815491015482519182526020820152f35b5080fd5b50600319906060368301126100af5783359167ffffffffffffffff831161013f576101609083360301126100af5750602092610183916024359101610345565b9051908152f35b50346100af57816003193601126100af576024359067ffffffffffffffff82116100af57506020926101c26101839236908301610255565b91356103dc565b90508284602036600319011261024d57803567ffffffffffffffff81116102515782916101f891369101610255565b908093918101031261024d578160207f09b72addb8ad094c9a8a8a968606cc44820134a10b0c58144a18cce1b43e2b20933591013590338652856020528160018488208381550155845260208401523392a280f35b8380fd5b8480fd5b9181601f840112156102835782359167ffffffffffffffff8311610283576020838186019501011161028357565b600080fd5b600435906001600160a01b038216820361028357565b6040810190811067ffffffffffffffff8211176102ba57604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102ba57604052565b67ffffffffffffffff81116102ba57601f01601f191660200190565b92919261031a826102f2565b9161032860405193846102d0565b829481845281830111610283578281602093846000960137010152565b80356001600160a01b03811692908390036102835760009283528260205260408320916001604051936103778561029e565b805485520154602084015261014081013590601e1981360301821215610251570180359067ffffffffffffffff821161025157602001908036038213610251576103ce9392916103c891369161030e565b916104d4565b156103d95750600190565b90565b6103c861041493923360005260006020526040600020936001604051956104028761029e565b8054875201546020860152369161030e565b61041d57600190565b600090565b60005b8381106104355750506000910152565b8181015183820152602001610425565b81601f8201121561028357805161045b816102f2565b9261046960405194856102d0565b81845260208284010111610283576103d99160208085019101610422565b906020916104a081518092818552858086019101610422565b601f01601f1916010190565b6000915b600283106104bd57505050565b6001908251815260208091019201920191906104b0565b909180519260209382019260a08386860195031261028357848301519267ffffffffffffffff9384811161028357858761051092840101610445565b93604082015190811161028357858761052b92840101610445565b9460608201519080609f84011215610283576040519261054a8461029e565b839060c08101928311610283579060808a9795989694939201905b82821061066157505050906105ed85966105f7936105bc976040519461058a8661029e565b805186520151898501526105d86040519a8b998a99630d5efec960e01b8b5261012060048c01526101248b0190610487565b600160f81b60248b01528981036003190160448b015290610487565b956064880152608487015260a48601906104ac565b60e48401906104ac565b0381739c4538396993166b7f7ec93552c8763d4742dedb5af49182156106555760009261062357505090565b81813d831161064e575b61063781836102d0565b8101031261013f57519081151582036100af575090565b503d61062d565b6040513d6000823e3d90fd5b815181528a97918201910161056556", - "nonce": "0x2555", - "accessList": [] - }, - "additionalContracts": [], - "isFixedGasLimit": false - } - ], - "receipts": [ - { - "transactionHash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", - "transactionIndex": "0x0", - "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", - "blockNumber": "0x2a7ac87", - "from": "0x7caF754C934710D7C73bc453654552BEcA38223F", - "to": null, - "cumulativeGasUsed": "0xe8863", - "gasUsed": "0xe8863", - "contractAddress": "0x9C4538396993166b7F7ec93552C8763d4742DEDB", - "logs": [ - { - "address": "0x0000000000000000000000000000000000001010", - "topics": [ - "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", - "0x0000000000000000000000000000000000000000000000000000000000001010", - "0x0000000000000000000000007caf754c934710d7c73bc453654552beca38223f", - "0x0000000000000000000000005082f249cdb2f2c1ee035e4f423c46ea2dab3ab1" - ], - "data": "0x00000000000000000000000000000000000000000000000000658299dd2b8400000000000000000000000000000000000000000000000006bfce90352866ec930000000000000000000000000000000000000000000005083ff6eb3d8b290556000000000000000000000000000000000000000000000006bf690d9b4b3b6893000000000000000000000000000000000000000000000508405c6dd768548956", - "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", - "blockNumber": "0x2a7ac87", - "transactionHash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", - "transactionIndex": "0x0", - "logIndex": "0x0", - "removed": false - } - ], - "status": "0x1", - "logsBloom": "0x00000000000000000000000000000000000200000000000000000000020000000000000002000000000000000000000000008000000000000000000000000000000000000000000000000000000000800000000000000000000100000000000000000000000000000000000000000002000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000008000000000000000004000000000000000000001000000000000000000000000000000100000000000000000000000000080000000000000000000000000000000000000000000100000", - "type": "0x2", - "effectiveGasPrice": "0x6fc23ac11" - }, - { - "transactionHash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", - "transactionIndex": "0x1", - "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", - "blockNumber": "0x2a7ac87", - "from": "0x7caF754C934710D7C73bc453654552BEcA38223F", - "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", - "cumulativeGasUsed": "0x14cbee", - "gasUsed": "0x6438b", - "contractAddress": null, - "logs": [ - { - "address": "0x0000000000000000000000000000000000001010", - "topics": [ - "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", - "0x0000000000000000000000000000000000000000000000000000000000001010", - "0x0000000000000000000000007caf754c934710d7c73bc453654552beca38223f", - "0x0000000000000000000000005082f249cdb2f2c1ee035e4f423c46ea2dab3ab1" - ], - "data": "0x000000000000000000000000000000000000000000000000002bc09e45626400000000000000000000000000000000000000000000000006bf690d9b4a445a00000000000000000000000000000000000000000000000508405c6dd768548956000000000000000000000000000000000000000000000006bf3d4cfd04e1f60000000000000000000000000000000000000000000000050840882e75adb6ed56", - "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", - "blockNumber": "0x2a7ac87", - "transactionHash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", - "transactionIndex": "0x1", - "logIndex": "0x1", - "removed": false - } - ], - "status": "0x1", - "logsBloom": "0x00000000000000000000000000000000000200000000000000000000020000000000000002000000000000000000000000008000000000000000000000000000000000000000000000000000000000800000000000000000000100000000000000000000000000000000000000000002000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000008000000000000000004000000000000000000001000000000000000000000000000000100000000000000000000000000080000000000000000000000000000000000000000000100000", - "type": "0x2", - "effectiveGasPrice": "0x6fc23ac11" - } - ], - "libraries": [ - "src/utils/WebAuthnWrapper.sol:WebAuthnWrapper:0x9c4538396993166b7f7ec93552c8763d4742dedb" - ], - "pending": [], - "returns": {}, - "timestamp": 1704722750, - "chain": 80001, - "multi": false, - "commit": "a611cec" -} \ No newline at end of file diff --git a/broadcast/DeployWebAuthnValidator.s.sol/80001/run-latest.json b/broadcast/DeployWebAuthnValidator.s.sol/80001/run-latest.json deleted file mode 100644 index 3469067a..00000000 --- a/broadcast/DeployWebAuthnValidator.s.sol/80001/run-latest.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "transactions": [ - { - "hash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", - "transactionType": "CREATE", - "contractName": "WebAuthnWrapper", - "contractAddress": "0x9C4538396993166b7F7ec93552C8763d4742DEDB", - "function": null, - "arguments": null, - "transaction": { - "type": "0x02", - "from": "0x7caf754c934710d7c73bc453654552beca38223f", - "gas": "0x12e329", - "data": "0x6080806040523461001a576110449081610020823930815050f35b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c630d5efec91461002857600080fd5b6101203660031901126100c35767ffffffffffffffff6004358181116100c6576100569036906004016100ca565b90916024359360ff60f81b851685036100c3576044359182116100c3576100bf6100ad86868661008936600489016100ca565b610095939193366100fd565b9361009f3661010a565b956084359460643594610118565b60405190151581529081906020820190565b0390f35b80fd5b8280fd5b9181601f840112156100f85782359167ffffffffffffffff83116100f857602083818601950101116100f857565b600080fd5b9060a49160e4116100f857565b9060e491610124116100f857565b939291979695949094602098806101406101328989610258565b356001600160f81b03191690565b169060ff60f81b8091169116036102465760405189810192835291829003808352601f199261017b916101769060200182610293565b610f0f565b9061018682516102fa565b80518b82019286018337519020916101b560405191826101a98d8201809661032c565b03908101835282610293565b51902003610234578691600091856101d46101cf8261036d565b6102fa565b95858701376101e86040518093819361038e565b039060025afa1561022f5761020f600091869384845191830101526040519182809261032c565b039060025afa1561022f5761022c928201359135906000516103c4565b90565b61039c565b60405163ebab5d2960e01b8152600490fd5b604051637e49a3c960e11b8152600490fd5b90602010156102675760200190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102b557604052565b61027d565b67ffffffffffffffff81116102b557601f01601f191660200190565b604051906020820182811067ffffffffffffffff8211176102b55760405260008252565b90610304826102ba565b6103116040519182610293565b8281528092610322601f19916102ba565b0190602036910137565b9081519160005b838110610344575050016000815290565b8060208092840101518185015201610333565b634e487b7160e01b600052601160045260246000fd5b906020820180921161037b57565b610357565b906002820180921161037b57565b908092918237016000815290565b6040513d6000823e3d90fd5b9060008051602061100483398151915291820391821161037b57565b60209382359390928501359190841580156104aa575b80156104a2575b801561048a575b61047f576103f684826104c2565b1561047f5760405192868452868085015286604085015260608401527fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f6080840152600080516020611004833981519152958660a08501528360c0816005600019fa156100f8576104799386610473945181818909940991610583565b916103a8565b90081590565b505050505050600090565b506000805160206110048339815191528310156103e8565b5082156103e1565b506000805160206110048339815191528510156103da565b80158061057b575b8015610564575b801561054d575b61054657600160601b63ffffffff60c01b03199081907f5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b90829081807fffffffff00000001000000000000000000000000fffffffffffffffffffffffc830991818180090908089180091490565b5050600090565b50600160601b63ffffffff60c01b031982146104d8565b50600160601b63ffffffff60c01b031981146104d1565b5081156104ca565b60009260ff92849291801580610c67575b610c5b576105a28284610c6f565b9095861580610c53575b610c33575b82811c60028a60fe1c16015b15610c1957600183821c1660028a831c60011b160160018114610be0575b60028114610bcf575b600314610bc2575b600198600019919091019692959493928992915b8a896000191161066f575050505050505050505060405191606083015260208252602080830152602060408301526000805160206110248339815191526080830152600163ffffffff60601b0360601b19918260a082015260208160c0816005600019fa156100f85751900990565b90919293949596979899600163ffffffff60601b0360601b198960020998600160601b63ffffffff60c01b03198a800999600160601b63ffffffff60c01b03198b840990600160601b63ffffffff60c01b0319908c900993849390600160601b63ffffffff60c01b03199081908181850890600160601b63ffffffff60c01b031990810385080960030998600160601b63ffffffff60c01b03199085099e600160601b63ffffffff60c01b0319908d099b600160601b63ffffffff60c01b031991829182910960008051602061102483398151915209600160601b63ffffffff60c01b03198a80090897600160601b63ffffffff60c01b031991829081038a08900992600160601b63ffffffff60c01b03199184918391900908918a8c1c600116848d1c60011b6002160115610ba35760018c600286838f841c16921c831b160114610b6c575b838c8c6002600182841c168185851c60011b160114610b59575b6003926001600292841c16921c60011b160114610b50575b8915610b3d57600160601b63ffffffff60c01b031990839082908f90090890600160601b63ffffffff60c01b0319908782039082908c900908988115610909575b600160601b63ffffffff60c01b031990818b800990099b600160601b63ffffffff60c01b031990818b8181800909900995600160601b63ffffffff60c01b031990818b80099009600160601b63ffffffff60c01b0319808260008051602061102483398151915209600160601b63ffffffff60c01b0319808d8181800909600160601b63ffffffff60c01b031990810390868009080899600160601b63ffffffff60c01b031993849182908181800909900991600160601b63ffffffff60c01b03199182908c82039008090896985b600019019796959493929190610600565b8961082957959b9a9850600160601b63ffffffff60c01b0319905080808360008051602061102483398151915209600160601b63ffffffff60c01b03198460008051602061102483398151915209098c0999600160601b63ffffffff60c01b0319808781038e08600160601b63ffffffff60c01b0319888f0809600160601b63ffffffff60c01b03199060030990600160601b63ffffffff60c01b0319908180808660008051602061102483398151915209600160601b63ffffffff60c01b0319876000805160206110248339815191520909600160601b63ffffffff60c01b03198660008051602061102483398151915209090995600160601b63ffffffff60c01b03199081808560008051602061102483398151915209600160601b63ffffffff60c01b0319866000805160206110248339815191520909099b600160601b63ffffffff60c01b0319908190819081808760008051602061102483398151915209600160601b63ffffffff60c01b0319886000805160206110248339815191520909900960008051602061102483398151915209600160601b63ffffffff60c01b0319838009089a600160601b63ffffffff60c01b03199283908180808360008051602061102483398151915209600160601b63ffffffff60c01b0319846000805160206110248339815191520909600160601b63ffffffff60c01b03198360008051602061102483398151915209090991600160601b63ffffffff60c01b03199182908e82039008900908966108f8565b60019c50909a9098508b955090506108f8565b505082846107e8565b508a93508992508591508d90508c6107d0565b5050600080516020610fe48339815191527f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f56107b6565b50979a9499600160601b63ffffffff60c01b03199190910397506108f8565b94509550849580946105ec565b9550965083966003849690506105e4565b600080516020610fe483398151915298507f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f596506105db565b60001901600160028185841c16918b841c901b16016105bd565b9790916000805160206110048339815191529182039008906000976105b1565b5081156105ac565b50505050505050600090565b508615610594565b7f4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f59291600080516020610fe4833981519152918115610dc75780831480610dbe575b15610da75750600160601b63ffffffff60c01b03199190508184600209918083800992818080808781818909950995817fffffffff00000001000000000000000000000000fffffffffffffffffffffffe816001840892080960030981808080866000805160206110248339815191520981858009089981600181818b099a099709810393898203900890090893915b60405190602082526020808301526020604083015260608201526000805160206110248339815191526080820152600163ffffffff60601b0360601b19928360a083015260208260c0816005600019fa156100f857838080935180950980099009930990565b909150610db5929350610dcd565b91939291610d41565b50818514610cb1565b50509190565b60019283927f94e82e0c1ed3bdb90743191a9c5bbf0d88fc827fd214cc5f0b5ec6ba27673d69600163ffffffff60601b0360601b198095818094817fb01cbd1c01e58065711814b583f061e9d431cca994cea1313449bf97c840ae0a9a8b920908950908928080808087800996870994818088600080516020610fe483398151915209918180808560008051602061102483398151915209818b810381868009080893818a869d0994820390080908946001099260010990565b604051906060820182811067ffffffffffffffff8211176102b557604052604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b600281901b91906001600160fe1b0381160361037b57565b805115610fda57610f1e610e87565b610f3d6101cf610f38610f318551610380565b6003900490565b610ef7565b9160208301918182518301915b828210610f8857505050600390510680600114610f7e57600214610f75575b819003601f1901815290565b60001901610f69565b5060011901610f69565b9091936004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c1688010151600286015316850101519082015301939190610f4a565b5061022c6102d656fe6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551ffffffff00000001000000000000000000000000fffffffffffffffffffffffd", - "nonce": "0x2554", - "accessList": [] - }, - "additionalContracts": [], - "isFixedGasLimit": false - }, - { - "hash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", - "transactionType": "CREATE2", - "contractName": "WebAuthnValidator", - "contractAddress": "0x52F06b3E336198BC55f981B10de94B5713f9aE1a", - "function": null, - "arguments": null, - "transaction": { - "type": "0x02", - "from": "0x7caf754c934710d7c73bc453654552beca38223f", - "to": "0x4e59b44847b379578588920ca78fbf26c0b4956c", - "gas": "0x92893", - "value": "0x0", - "data": "0x00000000000000000000000000000000000000000000000000000000000000006080806040523461001657610671908161001c8239f35b600080fdfe608060408181526004918236101561001657600080fd5b600090813560e01c9081630c959556146101c957508063333daf921461018a5780633a871cdd14610143578063857cdbb8146100fe5780638fc925aa146100b257639ea9bd591461006657600080fd5b346100af57816003193601126100af5761007e610288565b506024359067ffffffffffffffff82116100af57506100a09036908401610255565b50505163d623472560e01b8152fd5b80fd5b5091829160203660031901126100fa57813567ffffffffffffffff81116100f5576001926100e291369101610255565b5050338352826020528220828155015580f35b505050fd5b5050fd5b50903461013f57602036600319011261013f579081906001600160a01b03610124610288565b16815280602052206001815491015482519182526020820152f35b5080fd5b50600319906060368301126100af5783359167ffffffffffffffff831161013f576101609083360301126100af5750602092610183916024359101610345565b9051908152f35b50346100af57816003193601126100af576024359067ffffffffffffffff82116100af57506020926101c26101839236908301610255565b91356103dc565b90508284602036600319011261024d57803567ffffffffffffffff81116102515782916101f891369101610255565b908093918101031261024d578160207f09b72addb8ad094c9a8a8a968606cc44820134a10b0c58144a18cce1b43e2b20933591013590338652856020528160018488208381550155845260208401523392a280f35b8380fd5b8480fd5b9181601f840112156102835782359167ffffffffffffffff8311610283576020838186019501011161028357565b600080fd5b600435906001600160a01b038216820361028357565b6040810190811067ffffffffffffffff8211176102ba57604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176102ba57604052565b67ffffffffffffffff81116102ba57601f01601f191660200190565b92919261031a826102f2565b9161032860405193846102d0565b829481845281830111610283578281602093846000960137010152565b80356001600160a01b03811692908390036102835760009283528260205260408320916001604051936103778561029e565b805485520154602084015261014081013590601e1981360301821215610251570180359067ffffffffffffffff821161025157602001908036038213610251576103ce9392916103c891369161030e565b916104d4565b156103d95750600190565b90565b6103c861041493923360005260006020526040600020936001604051956104028761029e565b8054875201546020860152369161030e565b61041d57600190565b600090565b60005b8381106104355750506000910152565b8181015183820152602001610425565b81601f8201121561028357805161045b816102f2565b9261046960405194856102d0565b81845260208284010111610283576103d99160208085019101610422565b906020916104a081518092818552858086019101610422565b601f01601f1916010190565b6000915b600283106104bd57505050565b6001908251815260208091019201920191906104b0565b909180519260209382019260a08386860195031261028357848301519267ffffffffffffffff9384811161028357858761051092840101610445565b93604082015190811161028357858761052b92840101610445565b9460608201519080609f84011215610283576040519261054a8461029e565b839060c08101928311610283579060808a9795989694939201905b82821061066157505050906105ed85966105f7936105bc976040519461058a8661029e565b805186520151898501526105d86040519a8b998a99630d5efec960e01b8b5261012060048c01526101248b0190610487565b600160f81b60248b01528981036003190160448b015290610487565b956064880152608487015260a48601906104ac565b60e48401906104ac565b0381739c4538396993166b7f7ec93552c8763d4742dedb5af49182156106555760009261062357505090565b81813d831161064e575b61063781836102d0565b8101031261013f57519081151582036100af575090565b503d61062d565b6040513d6000823e3d90fd5b815181528a97918201910161056556", - "nonce": "0x2555", - "accessList": [] - }, - "additionalContracts": [], - "isFixedGasLimit": false - } - ], - "receipts": [ - { - "transactionHash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", - "transactionIndex": "0x0", - "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", - "blockNumber": "0x2a7ac87", - "from": "0x7caF754C934710D7C73bc453654552BEcA38223F", - "to": null, - "cumulativeGasUsed": "0xe8863", - "gasUsed": "0xe8863", - "contractAddress": "0x9C4538396993166b7F7ec93552C8763d4742DEDB", - "logs": [ - { - "address": "0x0000000000000000000000000000000000001010", - "topics": [ - "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", - "0x0000000000000000000000000000000000000000000000000000000000001010", - "0x0000000000000000000000007caf754c934710d7c73bc453654552beca38223f", - "0x0000000000000000000000005082f249cdb2f2c1ee035e4f423c46ea2dab3ab1" - ], - "data": "0x00000000000000000000000000000000000000000000000000658299dd2b8400000000000000000000000000000000000000000000000006bfce90352866ec930000000000000000000000000000000000000000000005083ff6eb3d8b290556000000000000000000000000000000000000000000000006bf690d9b4b3b6893000000000000000000000000000000000000000000000508405c6dd768548956", - "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", - "blockNumber": "0x2a7ac87", - "transactionHash": "0xfec20c4d3070d6c8d301af4fa55e195f4c4322e53110ad00d04ff027f7bc54ca", - "transactionIndex": "0x0", - "logIndex": "0x0", - "removed": false - } - ], - "status": "0x1", - "logsBloom": "0x00000000000000000000000000000000000200000000000000000000020000000000000002000000000000000000000000008000000000000000000000000000000000000000000000000000000000800000000000000000000100000000000000000000000000000000000000000002000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000008000000000000000004000000000000000000001000000000000000000000000000000100000000000000000000000000080000000000000000000000000000000000000000000100000", - "type": "0x2", - "effectiveGasPrice": "0x6fc23ac11" - }, - { - "transactionHash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", - "transactionIndex": "0x1", - "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", - "blockNumber": "0x2a7ac87", - "from": "0x7caF754C934710D7C73bc453654552BEcA38223F", - "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", - "cumulativeGasUsed": "0x14cbee", - "gasUsed": "0x6438b", - "contractAddress": null, - "logs": [ - { - "address": "0x0000000000000000000000000000000000001010", - "topics": [ - "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", - "0x0000000000000000000000000000000000000000000000000000000000001010", - "0x0000000000000000000000007caf754c934710d7c73bc453654552beca38223f", - "0x0000000000000000000000005082f249cdb2f2c1ee035e4f423c46ea2dab3ab1" - ], - "data": "0x000000000000000000000000000000000000000000000000002bc09e45626400000000000000000000000000000000000000000000000006bf690d9b4a445a00000000000000000000000000000000000000000000000508405c6dd768548956000000000000000000000000000000000000000000000006bf3d4cfd04e1f60000000000000000000000000000000000000000000000050840882e75adb6ed56", - "blockHash": "0x19d4b058a294f6fdc8e253ffbad4694c8433eb2f957fbbe8da19096f4db2fca4", - "blockNumber": "0x2a7ac87", - "transactionHash": "0xe889f19b54903a786eb929476e3a4ae6c139a86006daf63aeb567b5fe199ebdf", - "transactionIndex": "0x1", - "logIndex": "0x1", - "removed": false - } - ], - "status": "0x1", - "logsBloom": "0x00000000000000000000000000000000000200000000000000000000020000000000000002000000000000000000000000008000000000000000000000000000000000000000000000000000000000800000000000000000000100000000000000000000000000000000000000000002000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000008000000000000000004000000000000000000001000000000000000000000000000000100000000000000000000000000080000000000000000000000000000000000000000000100000", - "type": "0x2", - "effectiveGasPrice": "0x6fc23ac11" - } - ], - "libraries": [ - "src/utils/WebAuthnWrapper.sol:WebAuthnWrapper:0x9c4538396993166b7f7ec93552c8763d4742dedb" - ], - "pending": [], - "returns": {}, - "timestamp": 1704722750, - "chain": 80001, - "multi": false, - "commit": "a611cec" -} \ No newline at end of file diff --git a/lib/FreshCryptoLib b/lib/FreshCryptoLib new file mode 160000 index 00000000..1a484cdf --- /dev/null +++ b/lib/FreshCryptoLib @@ -0,0 +1 @@ +Subproject commit 1a484cdfd810046203f37b3e3c794d05720fb99c diff --git a/remappings.txt b/remappings.txt index 82c83131..55b13aad 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,5 +1,4 @@ ds-test/=lib/forge-std/lib/ds-test/src/ forge-std/=lib/forge-std/src/ solady/=lib/solady/src/ -p256-verifier/=lib/p256-verifier/src/ FreshCryptoLib/=lib/FreshCryptoLib/solidity/src/ \ No newline at end of file diff --git a/test/foundry/validator/WebAuthnFclValidator.t.sol b/test/foundry/validator/WebAuthnFclValidator.t.sol index a8e2cb13..9dff7b24 100644 --- a/test/foundry/validator/WebAuthnFclValidator.t.sol +++ b/test/foundry/validator/WebAuthnFclValidator.t.sol @@ -4,10 +4,10 @@ pragma solidity ^0.8.0; import {IEntryPoint} from "I4337/interfaces/IEntryPoint.sol"; import "src/Kernel.sol"; import "forge-std/Test.sol"; -import {ERC4337Utils} from "../utils/ERC4337Utils.sol"; -import {KernelTestBase} from "../KernelTestBase.sol"; -import {TestExecutor} from "../mock/TestExecutor.sol"; -import {TestValidator} from "../mock/TestValidator.sol"; +import {ERC4337Utils} from "src/utils/ERC4337Utils.sol"; +import {KernelTestBase} from "src/utils/KernelTestBase.sol"; +import {TestExecutor} from "src/mock/TestExecutor.sol"; +import {TestValidator} from "src/mock/TestValidator.sol"; import {WebAuthnFclVerifier} from "src/utils/WebAuthnFclVerifier.sol"; import {P256VerifierWrapper} from "src/utils/P256VerifierWrapper.sol"; import {WebAuthnFclValidator} from "src/validator/WebAuthnFclValidator.sol"; From 6e3eb91c262fe3471ca349c26cc356238ab89958 Mon Sep 17 00:00:00 2001 From: KONFeature Date: Mon, 22 Jan 2024 13:50:41 +0100 Subject: [PATCH 11/12] =?UTF-8?q?=F0=9F=9A=9A=20Move=20webauthn=20helper?= =?UTF-8?q?=20and=20validator=20inside=20subfolder=20validator/webauthn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/validator/{ => webauthn}/WebAuthnFclValidator.sol | 8 ++++---- src/{utils => validator/webauthn}/WebAuthnFclVerifier.sol | 0 test/foundry/validator/WebAuthnFclValidator.t.sol | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) rename src/validator/{ => webauthn}/WebAuthnFclValidator.sol (95%) rename src/{utils => validator/webauthn}/WebAuthnFclVerifier.sol (100%) diff --git a/src/validator/WebAuthnFclValidator.sol b/src/validator/webauthn/WebAuthnFclValidator.sol similarity index 95% rename from src/validator/WebAuthnFclValidator.sol rename to src/validator/webauthn/WebAuthnFclValidator.sol index e360f222..6169ed39 100644 --- a/src/validator/WebAuthnFclValidator.sol +++ b/src/validator/webauthn/WebAuthnFclValidator.sol @@ -3,10 +3,10 @@ pragma solidity ^0.8.0; import {UserOperation} from "I4337/interfaces/UserOperation.sol"; import {ECDSA} from "solady/utils/ECDSA.sol"; -import {IKernelValidator} from "../interfaces/IKernelValidator.sol"; -import {ValidationData} from "../common/Types.sol"; -import {SIG_VALIDATION_FAILED} from "../common/Constants.sol"; -import {WebAuthnFclVerifier} from "../utils/WebAuthnFclVerifier.sol"; +import {IKernelValidator} from "../../interfaces/IKernelValidator.sol"; +import {ValidationData} from "../../common/Types.sol"; +import {SIG_VALIDATION_FAILED} from "../../common/Constants.sol"; +import {WebAuthnFclVerifier} from "./WebAuthnFclVerifier.sol"; /// @dev Storage layout for a kernel in the WebAuthnValidator contract. struct WebAuthnFclValidatorStorage { diff --git a/src/utils/WebAuthnFclVerifier.sol b/src/validator/webauthn/WebAuthnFclVerifier.sol similarity index 100% rename from src/utils/WebAuthnFclVerifier.sol rename to src/validator/webauthn/WebAuthnFclVerifier.sol diff --git a/test/foundry/validator/WebAuthnFclValidator.t.sol b/test/foundry/validator/WebAuthnFclValidator.t.sol index 9dff7b24..6a9008c5 100644 --- a/test/foundry/validator/WebAuthnFclValidator.t.sol +++ b/test/foundry/validator/WebAuthnFclValidator.t.sol @@ -8,9 +8,9 @@ import {ERC4337Utils} from "src/utils/ERC4337Utils.sol"; import {KernelTestBase} from "src/utils/KernelTestBase.sol"; import {TestExecutor} from "src/mock/TestExecutor.sol"; import {TestValidator} from "src/mock/TestValidator.sol"; -import {WebAuthnFclVerifier} from "src/utils/WebAuthnFclVerifier.sol"; +import {WebAuthnFclVerifier} from "src/validator/webauthn/WebAuthnFclVerifier.sol"; import {P256VerifierWrapper} from "src/utils/P256VerifierWrapper.sol"; -import {WebAuthnFclValidator} from "src/validator/WebAuthnFclValidator.sol"; +import {WebAuthnFclValidator} from "src/validator/webauthn/WebAuthnFclValidator.sol"; import {FCL_ecdsa_utils} from "FreshCryptoLib/FCL_ecdsa_utils.sol"; import {Base64Url} from "FreshCryptoLib/utils/Base64Url.sol"; import {IKernel} from "src/interfaces/IKernel.sol"; From 384e221025b39bcd7f89d59f6307c96a4997dccf Mon Sep 17 00:00:00 2001 From: KONFeature Date: Mon, 22 Jan 2024 14:20:00 +0100 Subject: [PATCH 12/12] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Switched=20to=20foun?= =?UTF-8?q?dry=20cheatcode=20for=20p256=20sig=20validation=20during=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And fix deploy script --- lib/forge-std | 2 +- .../DeployWebAuthnFclValidator.sol | 7 ++++--- .../validator/WebAuthnFclValidator.t.sol | 19 ++++--------------- 3 files changed, 9 insertions(+), 19 deletions(-) rename scripts/DeployWebAuthnValidator.s.sol => script/DeployWebAuthnFclValidator.sol (73%) diff --git a/lib/forge-std b/lib/forge-std index 2f112697..ae570fec 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 2f112697506eab12d433a65fdc31a639548fe365 +Subproject commit ae570fec082bfe1c1f45b0acca4a2b4f84d345ce diff --git a/scripts/DeployWebAuthnValidator.s.sol b/script/DeployWebAuthnFclValidator.sol similarity index 73% rename from scripts/DeployWebAuthnValidator.s.sol rename to script/DeployWebAuthnFclValidator.sol index 63a3173a..235e1b5b 100644 --- a/scripts/DeployWebAuthnValidator.s.sol +++ b/script/DeployWebAuthnFclValidator.sol @@ -2,10 +2,11 @@ pragma solidity ^0.8.0; import "src/factory/KernelFactory.sol"; import "src/utils/P256VerifierWrapper.sol"; -import "src/validator/WebAuthnValidator.sol"; +import "src/validator/webauthn//WebAuthnFclValidator.sol"; import "forge-std/Script.sol"; import "forge-std/console.sol"; -contract DeployWebAuthnValidator is Script { + +contract DeployWebAuthnFclValidator is Script { function run() public { uint256 key = vm.envUint("DEPLOYER_PRIVATE_KEY"); @@ -14,7 +15,7 @@ contract DeployWebAuthnValidator is Script { P256VerifierWrapper p256VerifierWrapper = new P256VerifierWrapper{salt:0}(); console.log("p256 wrapper address: %s", address(p256VerifierWrapper)); - WebAuthnValidator validator = new WebAuthnValidator{salt:0}(address(p256VerifierWrapper)); + WebAuthnFclValidator validator = new WebAuthnFclValidator{salt:0}(address(p256VerifierWrapper)); console.log("validator address: %s", address(validator)); vm.stopBroadcast(); diff --git a/test/foundry/validator/WebAuthnFclValidator.t.sol b/test/foundry/validator/WebAuthnFclValidator.t.sol index 6a9008c5..8cd95139 100644 --- a/test/foundry/validator/WebAuthnFclValidator.t.sol +++ b/test/foundry/validator/WebAuthnFclValidator.t.sol @@ -222,6 +222,7 @@ contract WebAuthnFclValidatorTest is KernelTestBase { /// @dev Ensure that our flow to generate a webauthn signature is working function test_webAuthnSignatureGeneration(bytes32 _hash, uint256 _privateKey) public { vm.assume(_privateKey > 0); + vm.assume(_privateKey < n); (uint256 pubX, uint256 pubY) = _getPublicKey(_privateKey); // Build all the data required @@ -329,22 +330,10 @@ contract WebAuthnFclValidatorTest is KernelTestBase { uint256 constant P256_N_DIV_2 = 57896044605178124381348723474703786764998477612067880171211129530534256022184; /// @dev Generate a p256 signature, from the given `_privateKey` on the given `_hash` - function _getP256Signature(uint256 _privateKey, bytes32 _hash) internal view returns (uint256 r, uint256 s) { - // Securely generate a random k value for each signature - uint256 k = uint256(keccak256(abi.encodePacked(_hash, block.timestamp, block.prevrandao, _privateKey))) % n; - while (k == 0) { - k = uint256(keccak256(abi.encodePacked(k))) % n; - } - + function _getP256Signature(uint256 _privateKey, bytes32 _hash) internal view returns (uint256, uint256) { // Generate the signature using the k value and the private key - (r, s) = FCL_ecdsa_utils.ecdsa_sign(_hash, k, _privateKey); - - // Ensure that s is in the lower half of the range [1, n-1] - if (r == 0 || s == 0 || s > P256_N_DIV_2) { - s = n - s; // If s is in the upper half, use n - s instead - } - - return (r, s); + (bytes32 r, bytes32 s) = vm.signP256(_privateKey, _hash); + return (uint256(r), uint256(s)); } }