From a2c8e73a313b848dc4bbd055c206a682605cfa97 Mon Sep 17 00:00:00 2001 From: ququzone Date: Sat, 7 Oct 2023 19:03:22 +0800 Subject: [PATCH] split p256 validator and webauthn validator --- contracts/validators/p256/P256Validator.sol | 19 +- .../validators/p256/WebauthnValidator.sol | 60 +++++ deploy/validator_secp256r1.ts | 6 + deployments/iotex_testnet/P256Validator.json | 24 +- .../iotex_testnet/WebauthnValidator.json | 253 ++++++++++++++++++ .../b23988587d28d82ed6484bc5aecdcd50.json | 61 +++++ 6 files changed, 393 insertions(+), 30 deletions(-) create mode 100644 contracts/validators/p256/WebauthnValidator.sol create mode 100644 deployments/iotex_testnet/WebauthnValidator.json create mode 100644 deployments/iotex_testnet/solcInputs/b23988587d28d82ed6484bc5aecdcd50.json diff --git a/contracts/validators/p256/P256Validator.sol b/contracts/validators/p256/P256Validator.sol index bb09bd5..0f164ba 100644 --- a/contracts/validators/p256/P256Validator.sol +++ b/contracts/validators/p256/P256Validator.sol @@ -25,24 +25,7 @@ contract P256Validator is BaseValidator { override returns (uint256 validationData) { - bytes memory sig; - bytes32 messageHash; - { - ( - bytes memory realSig, - bytes memory authenticatorData, - string memory clientDataJSONPre, - string memory clientDataJSONPost - ) = abi.decode(signature, (bytes, bytes, string, string)); - - string memory clientDataJSON = - string.concat(clientDataJSONPre, Base64.encode(bytes.concat(userOpHash)), clientDataJSONPost); - bytes32 clientDataHash = sha256(bytes(clientDataJSON)); - messageHash = sha256(bytes.concat(authenticatorData, clientDataHash)); - sig = realSig; - } - - if (impl.validateSignature(messageHash, sig, pks[account])) { + if (impl.validateSignature(sha256(abi.encode(userOpHash)), signature, pks[account])) { return 0; } return Contants.SIG_VALIDATION_FAILED; diff --git a/contracts/validators/p256/WebauthnValidator.sol b/contracts/validators/p256/WebauthnValidator.sol new file mode 100644 index 0000000..bd4a65c --- /dev/null +++ b/contracts/validators/p256/WebauthnValidator.sol @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.19; + +import "../../common/Contants.sol"; +import "../BaseValidator.sol"; +import "./ISecp256r1.sol"; +import "./Base64.sol"; + +contract WebauthnValidator is BaseValidator { + string public constant override NAME = "Webauthn Validator"; + string public constant override VERSION = "0.0.1"; + + event PkChanged(address indexed account, bytes oldPk, bytes newPk); + + ISecp256r1 public immutable impl; + mapping(address => bytes) public pks; + + constructor(ISecp256r1 _impl) { + impl = _impl; + } + + function validateSignature(address account, bytes32 userOpHash, bytes calldata signature) + external + payable + override + returns (uint256 validationData) + { + bytes memory sig; + bytes32 messageHash; + { + ( + bytes memory realSig, + bytes memory authenticatorData, + string memory clientDataJSONPre, + string memory clientDataJSONPost + ) = abi.decode(signature, (bytes, bytes, string, string)); + + string memory clientDataJSON = + string.concat(clientDataJSONPre, Base64.encode(bytes.concat(userOpHash)), clientDataJSONPost); + bytes32 clientDataHash = sha256(bytes(clientDataJSON)); + messageHash = sha256(bytes.concat(authenticatorData, clientDataHash)); + sig = realSig; + } + + if (impl.validateSignature(messageHash, sig, pks[account])) { + return 0; + } + return Contants.SIG_VALIDATION_FAILED; + } + + function enable(bytes calldata data) external payable override { + bytes memory old = pks[msg.sender]; + pks[msg.sender] = data; + emit PkChanged(msg.sender, old, data); + } + + function validCaller(address, bytes calldata) external pure override returns (bool) { + revert("not implemented"); + } +} diff --git a/deploy/validator_secp256r1.ts b/deploy/validator_secp256r1.ts index b17bcc7..0f0ac2a 100644 --- a/deploy/validator_secp256r1.ts +++ b/deploy/validator_secp256r1.ts @@ -25,6 +25,12 @@ const deploy: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { log: true, deterministicDeployment: true, }) + await deploy('WebauthnValidator', { + from: deployer, + args: [secp256r1.address], + log: true, + deterministicDeployment: true, + }) } deploy.tags = ['secp256r1', 'validator'] diff --git a/deployments/iotex_testnet/P256Validator.json b/deployments/iotex_testnet/P256Validator.json index 327eb3f..ec22d07 100644 --- a/deployments/iotex_testnet/P256Validator.json +++ b/deployments/iotex_testnet/P256Validator.json @@ -1,5 +1,5 @@ { - "address": "0xaBe86e9D63c08C458689F61B29E4B0D5B0321FF3", + "address": "0x5F5dC33B8C2861D2E0D5ecfe2c9dA6985c6f0Cbb", "abi": [ { "inputs": [ @@ -181,30 +181,30 @@ "type": "function" } ], - "transactionHash": "0xe5d7384b000d16f353f2fb6f02721ef2e03f9766995091f31f6475304fa4238f", + "transactionHash": "0x188c9d8615ee580060e5dfc33a3f30cf1ffae6d74b092de52de5666a465c6244", "receipt": { "to": "0x355BE1cbfFBf803fdb17E0CB207D051cD9816916", "from": "0x7c029553644F5E9442cb576c1056e0f7663Db1Fa", "contractAddress": null, "transactionIndex": 0, - "gasUsed": "1185502", + "gasUsed": "837625", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xa1a5450ea539f91f3903b4ac229b299b1a7adb4b217dedefbadb147393e36155", - "transactionHash": "0xe5d7384b000d16f353f2fb6f02721ef2e03f9766995091f31f6475304fa4238f", + "blockHash": "0x04d082f2d2905dc0b1f1dccd45e31e3d52ec26c110325e27251d9dd7f6f26ac6", + "transactionHash": "0x188c9d8615ee580060e5dfc33a3f30cf1ffae6d74b092de52de5666a465c6244", "logs": [], - "blockNumber": 22646254, - "cumulativeGasUsed": "1185502", + "blockNumber": 22647808, + "cumulativeGasUsed": "837625", "status": 1, "byzantium": true }, "args": [ "0xebB3F7930b044f4F85263e1Ed99490CA1D5414b2" ], - "numDeployments": 1, - "solcInputHash": "63f225a5adf97e610c597fc373092b36", - "metadata": "{\"compiler\":{\"version\":\"0.8.19+commit.7dd6d404\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract ISecp256r1\",\"name\":\"_impl\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"oldPk\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"newPk\",\"type\":\"bytes\"}],\"name\":\"PkChanged\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"NAME\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"VERSION\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"enable\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"impl\",\"outputs\":[{\"internalType\":\"contract ISecp256r1\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"pks\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"validCaller\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"userOpHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"validateSignature\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"validationData\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"supportsInterface(bytes4)\":{\"details\":\"Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/validators/p256/P256Validator.sol\":\"P256Validator\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":800},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"contracts/common/Contants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nlibrary Contants {\\n address internal constant SENTINEL = address(0x1);\\n\\n uint256 internal constant SIG_VALIDATION_FAILED = 1;\\n}\\n\",\"keccak256\":\"0x4def4c34ea7d1925f182376cda97a69c536491aa43ebadaaf710b58173f5f76b\",\"license\":\"MIT\"},\"contracts/interfaces/IValidator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nimport \\\"./Metadata.sol\\\";\\n\\ninterface IValidator is Metadata {\\n function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)\\n external\\n payable\\n returns (uint256 validationData);\\n\\n function validCaller(address caller, bytes calldata data) external view returns (bool);\\n\\n function enable(bytes calldata data) external payable;\\n}\\n\",\"keccak256\":\"0x7c6a9305295ecdee128a434cc87514250605c3a3159ecd2dd3ee56dc9ce6f862\",\"license\":\"MIT\"},\"contracts/interfaces/Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\n\\ninterface Metadata is IERC165 {\\n function NAME() external view returns (string memory);\\n function VERSION() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0xcbcd27a057fef9d4c42f0e229575bd8fb28a8baad9440869bb30fcaefccc0729\",\"license\":\"MIT\"},\"contracts/validators/BaseValidator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nimport \\\"../interfaces/IValidator.sol\\\";\\n\\nabstract contract BaseValidator is IValidator {\\n function supportsInterface(bytes4 interfaceId) external pure returns (bool) {\\n return interfaceId == type(IValidator).interfaceId;\\n }\\n}\\n\",\"keccak256\":\"0x6bc845d709ba4b8925de3dd209016868ca59f6ede3c52c76d1f12a5783a04579\",\"license\":\"MIT\"},\"contracts/validators/p256/Base64.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nlibrary Base64 {\\n /**\\n * @dev Base64 Encoding/Decoding Table\\n */\\n string internal constant _TABLE = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\\\";\\n\\n /**\\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\\n */\\n function encode(bytes memory data) internal pure returns (string memory) {\\n /**\\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\\n */\\n if (data.length == 0) return \\\"\\\";\\n\\n // Loads the table into memory\\n string memory table = _TABLE;\\n\\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\\n // and split into 4 numbers of 6 bits.\\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\\n // - `data.length + 2` -> Round up\\n // - `/ 3` -> Number of 3-bytes chunks\\n // - `4 *` -> 4 characters for each chunk\\n uint256 newlength = data.length * 8 / 6;\\n if (data.length % 6 > 0) {\\n newlength++;\\n }\\n string memory result = new string(newlength);\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Prepare the lookup table (skip the first \\\"length\\\" byte)\\n let tablePtr := add(table, 1)\\n\\n // Prepare result pointer, jump over length\\n let resultPtr := add(result, 32)\\n // let targetLength := add(resultPtr, newlength)\\n\\n // Run over the input, 3 bytes at a time\\n for {\\n let dataPtr := data\\n let endPtr := add(data, mload(data))\\n } lt(dataPtr, endPtr) {} {\\n // Advance 3 bytes\\n dataPtr := add(dataPtr, 3)\\n let input := mload(dataPtr)\\n\\n // To write each character, shift the 3 bytes (18 bits) chunk\\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\\n // and apply logical AND with 0x3F which is the number of\\n // the previous character in the ASCII table prior to the Base64 Table\\n // The result is then added to the table to get the character to write,\\n // and finally write it in the result pointer but with a left shift\\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\\n resultPtr := add(resultPtr, 1)\\n\\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\\n resultPtr := add(resultPtr, 1)\\n\\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\\n resultPtr := add(resultPtr, 1)\\n\\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\\n resultPtr := add(resultPtr, 1)\\n }\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x2aa241e8e13cdb63bc886b6a5ab0d464af440e7019d15abf0dc0a67bd3fe7def\",\"license\":\"MIT\"},\"contracts/validators/p256/ISecp256r1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\ninterface ISecp256r1 {\\n function validateSignature(bytes32 message, bytes calldata signature, bytes calldata publicKey)\\n external\\n view\\n returns (bool);\\n}\\n\",\"keccak256\":\"0x2c27d09b504eebfad02daf6a774b8df8bf29c51077f288bf6dd5464b4a18d177\",\"license\":\"MIT\"},\"contracts/validators/p256/P256Validator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nimport \\\"../../common/Contants.sol\\\";\\nimport \\\"../BaseValidator.sol\\\";\\nimport \\\"./ISecp256r1.sol\\\";\\nimport \\\"./Base64.sol\\\";\\n\\ncontract P256Validator is BaseValidator {\\n string public constant override NAME = \\\"P256 Validator\\\";\\n string public constant override VERSION = \\\"0.0.1\\\";\\n\\n event PkChanged(address indexed account, bytes oldPk, bytes newPk);\\n\\n ISecp256r1 public immutable impl;\\n mapping(address => bytes) public pks;\\n\\n constructor(ISecp256r1 _impl) {\\n impl = _impl;\\n }\\n\\n function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)\\n external\\n payable\\n override\\n returns (uint256 validationData)\\n {\\n bytes memory sig;\\n bytes32 messageHash;\\n {\\n (\\n bytes memory realSig,\\n bytes memory authenticatorData,\\n string memory clientDataJSONPre,\\n string memory clientDataJSONPost\\n ) = abi.decode(signature, (bytes, bytes, string, string));\\n\\n string memory clientDataJSON =\\n string.concat(clientDataJSONPre, Base64.encode(bytes.concat(userOpHash)), clientDataJSONPost);\\n bytes32 clientDataHash = sha256(bytes(clientDataJSON));\\n messageHash = sha256(bytes.concat(authenticatorData, clientDataHash));\\n sig = realSig;\\n }\\n\\n if (impl.validateSignature(messageHash, sig, pks[account])) {\\n return 0;\\n }\\n return Contants.SIG_VALIDATION_FAILED;\\n }\\n\\n function enable(bytes calldata data) external payable override {\\n bytes memory old = pks[msg.sender];\\n pks[msg.sender] = data;\\n emit PkChanged(msg.sender, old, data);\\n }\\n\\n function validCaller(address, bytes calldata) external pure override returns (bool) {\\n revert(\\\"not implemented\\\");\\n }\\n}\\n\",\"keccak256\":\"0x4262dfc6da1edc5b816281f4de83192729c07a37523adcec7ab2fb9bd85bae60\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60a060405234801561001057600080fd5b50604051610f27380380610f2783398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b608051610e9561009260003960008181610105015261053c0152610e956000f3fe60806040526004361061007b5760003560e01c8063971604c61161004e578063971604c61461016c5780639ea9bd591461018d578063a3f4df7e146101ad578063ffa1ad74146101f657600080fd5b806301ffc9a7146100805780630c959556146100de5780638abf6077146100f35780639356375c1461013f575b600080fd5b34801561008c57600080fd5b506100c961009b366004610765565b7fffffffff000000000000000000000000000000000000000000000000000000001663052a2cc960e01b1490565b60405190151581526020015b60405180910390f35b6100f16100ec3660046107f7565b61023f565b005b3480156100ff57600080fd5b506101277f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100d5565b34801561014b57600080fd5b5061015f61015a366004610855565b610342565b6040516100d591906108c0565b61017f61017a3660046108d3565b6103dc565b6040519081526020016100d5565b34801561019957600080fd5b506100c96101a836600461092d565b6105da565b3480156101b957600080fd5b5061015f6040518060400160405280600e81526020017f503235362056616c696461746f7200000000000000000000000000000000000081525081565b34801561020257600080fd5b5061015f6040518060400160405280600581526020017f302e302e3100000000000000000000000000000000000000000000000000000081525081565b336000908152602081905260408120805461025990610980565b80601f016020809104026020016040519081016040528092919081815260200182805461028590610980565b80156102d25780601f106102a7576101008083540402835291602001916102d2565b820191906000526020600020905b8154815290600101906020018083116102b557829003601f168201915b50503360009081526020819052604090209394506102f7925085915086905083610a1f565b50336001600160a01b03167f49a125229beaa1b288f0f807170a37c7a131925683b0250b113db84181bfb06682858560405161033593929190610ae0565b60405180910390a2505050565b6000602081905290815260409020805461035b90610980565b80601f016020809104026020016040519081016040528092919081815260200182805461038790610980565b80156103d45780601f106103a9576101008083540402835291602001916103d4565b820191906000526020600020905b8154815290600101906020018083116103b757829003601f168201915b505050505081565b6000606081808080806103f1888a018a610bb3565b93509350935093506000826104268c60405160200161041291815260200190565b604051602081830303815290604052610629565b8360405160200161043993929190610c60565b6040516020818303038152906040529050600060028260405161045c9190610ca3565b602060405180830381855afa158015610479573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061049c9190610cbf565b9050600285826040516020016104b3929190610cd8565b60408051601f19818403018152908290526104cd91610ca3565b602060405180830381855afa1580156104ea573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061050d9190610cbf565b6001600160a01b038e8116600090815260208190526040908190209051630ae7e17f60e41b8152989a509198507f0000000000000000000000000000000000000000000000000000000000000000169663ae7e17f0965061057a9550889450899350909150600401610cfa565b602060405180830381865afa158015610597573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105bb9190610d9c565b156105cb576000925050506105d2565b6001925050505b949350505050565b60405162461bcd60e51b815260206004820152600f60248201527f6e6f7420696d706c656d656e7465640000000000000000000000000000000000604482015260009060640160405180910390fd5b6060815160000361064857505060408051602081019091526000815290565b6000604051806060016040528060408152602001610e4960409139905060006006845160086106779190610dd4565b6106819190610e07565b90506000600685516106939190610e1b565b11156106a757806106a381610e2f565b9150505b60008167ffffffffffffffff8111156106c2576106c26109ba565b6040519080825280601f01601f1916602001820160405280156106ec576020820181803683370190505b509050600183016020820186875188015b80821015610758576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f81168501518453506001830192506106fd565b5092979650505050505050565b60006020828403121561077757600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146107a757600080fd5b9392505050565b60008083601f8401126107c057600080fd5b50813567ffffffffffffffff8111156107d857600080fd5b6020830191508360208285010111156107f057600080fd5b9250929050565b6000806020838503121561080a57600080fd5b823567ffffffffffffffff81111561082157600080fd5b61082d858286016107ae565b90969095509350505050565b80356001600160a01b038116811461085057600080fd5b919050565b60006020828403121561086757600080fd5b6107a782610839565b60005b8381101561088b578181015183820152602001610873565b50506000910152565b600081518084526108ac816020860160208601610870565b601f01601f19169290920160200192915050565b6020815260006107a76020830184610894565b600080600080606085870312156108e957600080fd5b6108f285610839565b935060208501359250604085013567ffffffffffffffff81111561091557600080fd5b610921878288016107ae565b95989497509550505050565b60008060006040848603121561094257600080fd5b61094b84610839565b9250602084013567ffffffffffffffff81111561096757600080fd5b610973868287016107ae565b9497909650939450505050565b600181811c9082168061099457607f821691505b6020821081036109b457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b601f821115610a1a57600081815260208120601f850160051c810160208610156109f75750805b601f850160051c820191505b81811015610a1657828155600101610a03565b5050505b505050565b67ffffffffffffffff831115610a3757610a376109ba565b610a4b83610a458354610980565b836109d0565b6000601f841160018114610a7f5760008515610a675750838201355b600019600387901b1c1916600186901b178355610ad9565b600083815260209020601f19861690835b82811015610ab05786850135825560209485019460019092019101610a90565b5086821015610acd5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b604081526000610af36040830186610894565b8281036020840152838152838560208301376000602085830101526020601f19601f860116820101915050949350505050565b600082601f830112610b3757600080fd5b813567ffffffffffffffff80821115610b5257610b526109ba565b604051601f8301601f19908116603f01168101908282118183101715610b7a57610b7a6109ba565b81604052838152866020858801011115610b9357600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060808587031215610bc957600080fd5b843567ffffffffffffffff80821115610be157600080fd5b610bed88838901610b26565b95506020870135915080821115610c0357600080fd5b610c0f88838901610b26565b94506040870135915080821115610c2557600080fd5b610c3188838901610b26565b93506060870135915080821115610c4757600080fd5b50610c5487828801610b26565b91505092959194509250565b60008451610c72818460208901610870565b845190830190610c86818360208901610870565b8451910190610c99818360208801610870565b0195945050505050565b60008251610cb5818460208701610870565b9190910192915050565b600060208284031215610cd157600080fd5b5051919050565b60008351610cea818460208801610870565b9190910191825250602001919050565b83815260006020606081840152610d146060840186610894565b838103604085015260008554610d2981610980565b80845260018281168015610d445760018114610d5e57610d8c565b60ff1984168688015282151560051b860187019450610d8c565b896000528660002060005b84811015610d845781548882018a0152908301908801610d69565b870188019550505b50929a9950505050505050505050565b600060208284031215610dae57600080fd5b815180151581146107a757600080fd5b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610deb57610deb610dbe565b92915050565b634e487b7160e01b600052601260045260246000fd5b600082610e1657610e16610df1565b500490565b600082610e2a57610e2a610df1565b500690565b600060018201610e4157610e41610dbe565b506001019056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5fa164736f6c6343000813000a", - "deployedBytecode": "0x60806040526004361061007b5760003560e01c8063971604c61161004e578063971604c61461016c5780639ea9bd591461018d578063a3f4df7e146101ad578063ffa1ad74146101f657600080fd5b806301ffc9a7146100805780630c959556146100de5780638abf6077146100f35780639356375c1461013f575b600080fd5b34801561008c57600080fd5b506100c961009b366004610765565b7fffffffff000000000000000000000000000000000000000000000000000000001663052a2cc960e01b1490565b60405190151581526020015b60405180910390f35b6100f16100ec3660046107f7565b61023f565b005b3480156100ff57600080fd5b506101277f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100d5565b34801561014b57600080fd5b5061015f61015a366004610855565b610342565b6040516100d591906108c0565b61017f61017a3660046108d3565b6103dc565b6040519081526020016100d5565b34801561019957600080fd5b506100c96101a836600461092d565b6105da565b3480156101b957600080fd5b5061015f6040518060400160405280600e81526020017f503235362056616c696461746f7200000000000000000000000000000000000081525081565b34801561020257600080fd5b5061015f6040518060400160405280600581526020017f302e302e3100000000000000000000000000000000000000000000000000000081525081565b336000908152602081905260408120805461025990610980565b80601f016020809104026020016040519081016040528092919081815260200182805461028590610980565b80156102d25780601f106102a7576101008083540402835291602001916102d2565b820191906000526020600020905b8154815290600101906020018083116102b557829003601f168201915b50503360009081526020819052604090209394506102f7925085915086905083610a1f565b50336001600160a01b03167f49a125229beaa1b288f0f807170a37c7a131925683b0250b113db84181bfb06682858560405161033593929190610ae0565b60405180910390a2505050565b6000602081905290815260409020805461035b90610980565b80601f016020809104026020016040519081016040528092919081815260200182805461038790610980565b80156103d45780601f106103a9576101008083540402835291602001916103d4565b820191906000526020600020905b8154815290600101906020018083116103b757829003601f168201915b505050505081565b6000606081808080806103f1888a018a610bb3565b93509350935093506000826104268c60405160200161041291815260200190565b604051602081830303815290604052610629565b8360405160200161043993929190610c60565b6040516020818303038152906040529050600060028260405161045c9190610ca3565b602060405180830381855afa158015610479573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061049c9190610cbf565b9050600285826040516020016104b3929190610cd8565b60408051601f19818403018152908290526104cd91610ca3565b602060405180830381855afa1580156104ea573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061050d9190610cbf565b6001600160a01b038e8116600090815260208190526040908190209051630ae7e17f60e41b8152989a509198507f0000000000000000000000000000000000000000000000000000000000000000169663ae7e17f0965061057a9550889450899350909150600401610cfa565b602060405180830381865afa158015610597573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105bb9190610d9c565b156105cb576000925050506105d2565b6001925050505b949350505050565b60405162461bcd60e51b815260206004820152600f60248201527f6e6f7420696d706c656d656e7465640000000000000000000000000000000000604482015260009060640160405180910390fd5b6060815160000361064857505060408051602081019091526000815290565b6000604051806060016040528060408152602001610e4960409139905060006006845160086106779190610dd4565b6106819190610e07565b90506000600685516106939190610e1b565b11156106a757806106a381610e2f565b9150505b60008167ffffffffffffffff8111156106c2576106c26109ba565b6040519080825280601f01601f1916602001820160405280156106ec576020820181803683370190505b509050600183016020820186875188015b80821015610758576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f81168501518453506001830192506106fd565b5092979650505050505050565b60006020828403121561077757600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146107a757600080fd5b9392505050565b60008083601f8401126107c057600080fd5b50813567ffffffffffffffff8111156107d857600080fd5b6020830191508360208285010111156107f057600080fd5b9250929050565b6000806020838503121561080a57600080fd5b823567ffffffffffffffff81111561082157600080fd5b61082d858286016107ae565b90969095509350505050565b80356001600160a01b038116811461085057600080fd5b919050565b60006020828403121561086757600080fd5b6107a782610839565b60005b8381101561088b578181015183820152602001610873565b50506000910152565b600081518084526108ac816020860160208601610870565b601f01601f19169290920160200192915050565b6020815260006107a76020830184610894565b600080600080606085870312156108e957600080fd5b6108f285610839565b935060208501359250604085013567ffffffffffffffff81111561091557600080fd5b610921878288016107ae565b95989497509550505050565b60008060006040848603121561094257600080fd5b61094b84610839565b9250602084013567ffffffffffffffff81111561096757600080fd5b610973868287016107ae565b9497909650939450505050565b600181811c9082168061099457607f821691505b6020821081036109b457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b601f821115610a1a57600081815260208120601f850160051c810160208610156109f75750805b601f850160051c820191505b81811015610a1657828155600101610a03565b5050505b505050565b67ffffffffffffffff831115610a3757610a376109ba565b610a4b83610a458354610980565b836109d0565b6000601f841160018114610a7f5760008515610a675750838201355b600019600387901b1c1916600186901b178355610ad9565b600083815260209020601f19861690835b82811015610ab05786850135825560209485019460019092019101610a90565b5086821015610acd5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b604081526000610af36040830186610894565b8281036020840152838152838560208301376000602085830101526020601f19601f860116820101915050949350505050565b600082601f830112610b3757600080fd5b813567ffffffffffffffff80821115610b5257610b526109ba565b604051601f8301601f19908116603f01168101908282118183101715610b7a57610b7a6109ba565b81604052838152866020858801011115610b9357600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060808587031215610bc957600080fd5b843567ffffffffffffffff80821115610be157600080fd5b610bed88838901610b26565b95506020870135915080821115610c0357600080fd5b610c0f88838901610b26565b94506040870135915080821115610c2557600080fd5b610c3188838901610b26565b93506060870135915080821115610c4757600080fd5b50610c5487828801610b26565b91505092959194509250565b60008451610c72818460208901610870565b845190830190610c86818360208901610870565b8451910190610c99818360208801610870565b0195945050505050565b60008251610cb5818460208701610870565b9190910192915050565b600060208284031215610cd157600080fd5b5051919050565b60008351610cea818460208801610870565b9190910191825250602001919050565b83815260006020606081840152610d146060840186610894565b838103604085015260008554610d2981610980565b80845260018281168015610d445760018114610d5e57610d8c565b60ff1984168688015282151560051b860187019450610d8c565b896000528660002060005b84811015610d845781548882018a0152908301908801610d69565b870188019550505b50929a9950505050505050505050565b600060208284031215610dae57600080fd5b815180151581146107a757600080fd5b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610deb57610deb610dbe565b92915050565b634e487b7160e01b600052601260045260246000fd5b600082610e1657610e16610df1565b500490565b600082610e2a57610e2a610df1565b500690565b600060018201610e4157610e41610dbe565b506001019056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5fa164736f6c6343000813000a", + "numDeployments": 2, + "solcInputHash": "b23988587d28d82ed6484bc5aecdcd50", + "metadata": "{\"compiler\":{\"version\":\"0.8.19+commit.7dd6d404\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract ISecp256r1\",\"name\":\"_impl\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"oldPk\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"newPk\",\"type\":\"bytes\"}],\"name\":\"PkChanged\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"NAME\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"VERSION\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"enable\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"impl\",\"outputs\":[{\"internalType\":\"contract ISecp256r1\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"pks\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"validCaller\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"userOpHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"validateSignature\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"validationData\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"supportsInterface(bytes4)\":{\"details\":\"Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/validators/p256/P256Validator.sol\":\"P256Validator\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":800},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"contracts/common/Contants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nlibrary Contants {\\n address internal constant SENTINEL = address(0x1);\\n\\n uint256 internal constant SIG_VALIDATION_FAILED = 1;\\n}\\n\",\"keccak256\":\"0x4def4c34ea7d1925f182376cda97a69c536491aa43ebadaaf710b58173f5f76b\",\"license\":\"MIT\"},\"contracts/interfaces/IValidator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nimport \\\"./Metadata.sol\\\";\\n\\ninterface IValidator is Metadata {\\n function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)\\n external\\n payable\\n returns (uint256 validationData);\\n\\n function validCaller(address caller, bytes calldata data) external view returns (bool);\\n\\n function enable(bytes calldata data) external payable;\\n}\\n\",\"keccak256\":\"0x7c6a9305295ecdee128a434cc87514250605c3a3159ecd2dd3ee56dc9ce6f862\",\"license\":\"MIT\"},\"contracts/interfaces/Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\n\\ninterface Metadata is IERC165 {\\n function NAME() external view returns (string memory);\\n function VERSION() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0xcbcd27a057fef9d4c42f0e229575bd8fb28a8baad9440869bb30fcaefccc0729\",\"license\":\"MIT\"},\"contracts/validators/BaseValidator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nimport \\\"../interfaces/IValidator.sol\\\";\\n\\nabstract contract BaseValidator is IValidator {\\n function supportsInterface(bytes4 interfaceId) external pure returns (bool) {\\n return interfaceId == type(IValidator).interfaceId;\\n }\\n}\\n\",\"keccak256\":\"0x6bc845d709ba4b8925de3dd209016868ca59f6ede3c52c76d1f12a5783a04579\",\"license\":\"MIT\"},\"contracts/validators/p256/Base64.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nlibrary Base64 {\\n /**\\n * @dev Base64 Encoding/Decoding Table\\n */\\n string internal constant _TABLE = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\\\";\\n\\n /**\\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\\n */\\n function encode(bytes memory data) internal pure returns (string memory) {\\n /**\\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\\n */\\n if (data.length == 0) return \\\"\\\";\\n\\n // Loads the table into memory\\n string memory table = _TABLE;\\n\\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\\n // and split into 4 numbers of 6 bits.\\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\\n // - `data.length + 2` -> Round up\\n // - `/ 3` -> Number of 3-bytes chunks\\n // - `4 *` -> 4 characters for each chunk\\n uint256 newlength = data.length * 8 / 6;\\n if (data.length % 6 > 0) {\\n newlength++;\\n }\\n string memory result = new string(newlength);\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Prepare the lookup table (skip the first \\\"length\\\" byte)\\n let tablePtr := add(table, 1)\\n\\n // Prepare result pointer, jump over length\\n let resultPtr := add(result, 32)\\n // let targetLength := add(resultPtr, newlength)\\n\\n // Run over the input, 3 bytes at a time\\n for {\\n let dataPtr := data\\n let endPtr := add(data, mload(data))\\n } lt(dataPtr, endPtr) {} {\\n // Advance 3 bytes\\n dataPtr := add(dataPtr, 3)\\n let input := mload(dataPtr)\\n\\n // To write each character, shift the 3 bytes (18 bits) chunk\\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\\n // and apply logical AND with 0x3F which is the number of\\n // the previous character in the ASCII table prior to the Base64 Table\\n // The result is then added to the table to get the character to write,\\n // and finally write it in the result pointer but with a left shift\\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\\n resultPtr := add(resultPtr, 1)\\n\\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\\n resultPtr := add(resultPtr, 1)\\n\\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\\n resultPtr := add(resultPtr, 1)\\n\\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\\n resultPtr := add(resultPtr, 1)\\n }\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x2aa241e8e13cdb63bc886b6a5ab0d464af440e7019d15abf0dc0a67bd3fe7def\",\"license\":\"MIT\"},\"contracts/validators/p256/ISecp256r1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\ninterface ISecp256r1 {\\n function validateSignature(bytes32 message, bytes calldata signature, bytes calldata publicKey)\\n external\\n view\\n returns (bool);\\n}\\n\",\"keccak256\":\"0x2c27d09b504eebfad02daf6a774b8df8bf29c51077f288bf6dd5464b4a18d177\",\"license\":\"MIT\"},\"contracts/validators/p256/P256Validator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nimport \\\"../../common/Contants.sol\\\";\\nimport \\\"../BaseValidator.sol\\\";\\nimport \\\"./ISecp256r1.sol\\\";\\nimport \\\"./Base64.sol\\\";\\n\\ncontract P256Validator is BaseValidator {\\n string public constant override NAME = \\\"P256 Validator\\\";\\n string public constant override VERSION = \\\"0.0.1\\\";\\n\\n event PkChanged(address indexed account, bytes oldPk, bytes newPk);\\n\\n ISecp256r1 public immutable impl;\\n mapping(address => bytes) public pks;\\n\\n constructor(ISecp256r1 _impl) {\\n impl = _impl;\\n }\\n\\n function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)\\n external\\n payable\\n override\\n returns (uint256 validationData)\\n {\\n if (impl.validateSignature(sha256(abi.encode(userOpHash)), signature, pks[account])) {\\n return 0;\\n }\\n return Contants.SIG_VALIDATION_FAILED;\\n }\\n\\n function enable(bytes calldata data) external payable override {\\n bytes memory old = pks[msg.sender];\\n pks[msg.sender] = data;\\n emit PkChanged(msg.sender, old, data);\\n }\\n\\n function validCaller(address, bytes calldata) external pure override returns (bool) {\\n revert(\\\"not implemented\\\");\\n }\\n}\\n\",\"keccak256\":\"0x803005daa3a60608986a4dbad6abedd7d395b9f4ca02931d531cd19a60371d09\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a060405234801561001057600080fd5b50604051610aa1380380610aa183398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b608051610a106100916000396000818160ed01526103c80152610a106000f3fe60806040526004361061007b5760003560e01c8063971604c61161004e578063971604c6146101545780639ea9bd5914610175578063a3f4df7e14610195578063ffa1ad74146101de57600080fd5b806301ffc9a7146100805780630c959556146100c65780638abf6077146100db5780639356375c14610127575b600080fd5b34801561008c57600080fd5b506100b161009b36600461054c565b6001600160e01b03191663052a2cc960e01b1490565b60405190151581526020015b60405180910390f35b6100d96100d43660046105c6565b610227565b005b3480156100e757600080fd5b5061010f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100bd565b34801561013357600080fd5b50610147610142366004610624565b61032a565b6040516100bd919061068f565b6101676101623660046106a2565b6103c4565b6040519081526020016100bd565b34801561018157600080fd5b506100b16101903660046106fc565b6104fd565b3480156101a157600080fd5b506101476040518060400160405280600e81526020017f503235362056616c696461746f7200000000000000000000000000000000000081525081565b3480156101ea57600080fd5b506101476040518060400160405280600581526020017f302e302e3100000000000000000000000000000000000000000000000000000081525081565b33600090815260208190526040812080546102419061074f565b80601f016020809104026020016040519081016040528092919081815260200182805461026d9061074f565b80156102ba5780601f1061028f576101008083540402835291602001916102ba565b820191906000526020600020905b81548152906001019060200180831161029d57829003601f168201915b50503360009081526020819052604090209394506102df9250859150869050836107ee565b50336001600160a01b03167f49a125229beaa1b288f0f807170a37c7a131925683b0250b113db84181bfb06682858560405161031d939291906108d8565b60405180910390a2505050565b600060208190529081526040902080546103439061074f565b80601f016020809104026020016040519081016040528092919081815260200182805461036f9061074f565b80156103bc5780601f10610391576101008083540402835291602001916103bc565b820191906000526020600020905b81548152906001019060200180831161039f57829003601f168201915b505050505081565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ae7e17f060028660405160200161040a91815260200190565b60408051601f198184030181529082905261042491610908565b602060405180830381855afa158015610441573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906104649190610924565b6001600160a01b0388166000908152602081905260409081902090516001600160e01b031960e085901b1681526104a39291889188919060040161093d565b602060405180830381865afa1580156104c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104e491906109e1565b156104f1575060006104f5565b5060015b949350505050565b60405162461bcd60e51b815260206004820152600f60248201527f6e6f7420696d706c656d656e7465640000000000000000000000000000000000604482015260009060640160405180910390fd5b60006020828403121561055e57600080fd5b81356001600160e01b03198116811461057657600080fd5b9392505050565b60008083601f84011261058f57600080fd5b50813567ffffffffffffffff8111156105a757600080fd5b6020830191508360208285010111156105bf57600080fd5b9250929050565b600080602083850312156105d957600080fd5b823567ffffffffffffffff8111156105f057600080fd5b6105fc8582860161057d565b90969095509350505050565b80356001600160a01b038116811461061f57600080fd5b919050565b60006020828403121561063657600080fd5b61057682610608565b60005b8381101561065a578181015183820152602001610642565b50506000910152565b6000815180845261067b81602086016020860161063f565b601f01601f19169290920160200192915050565b6020815260006105766020830184610663565b600080600080606085870312156106b857600080fd5b6106c185610608565b935060208501359250604085013567ffffffffffffffff8111156106e457600080fd5b6106f08782880161057d565b95989497509550505050565b60008060006040848603121561071157600080fd5b61071a84610608565b9250602084013567ffffffffffffffff81111561073657600080fd5b6107428682870161057d565b9497909650939450505050565b600181811c9082168061076357607f821691505b60208210810361078357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b601f8211156107e957600081815260208120601f850160051c810160208610156107c65750805b601f850160051c820191505b818110156107e5578281556001016107d2565b5050505b505050565b67ffffffffffffffff83111561080657610806610789565b61081a83610814835461074f565b8361079f565b6000601f84116001811461084e57600085156108365750838201355b600019600387901b1c1916600186901b1783556108a8565b600083815260209020601f19861690835b8281101561087f578685013582556020948501946001909201910161085f565b508682101561089c5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6040815260006108eb6040830186610663565b82810360208401526108fe8185876108af565b9695505050505050565b6000825161091a81846020870161063f565b9190910192915050565b60006020828403121561093657600080fd5b5051919050565b848152600060206060818401526109586060840186886108af565b83810360408501526000855461096d8161074f565b8084526001828116801561098857600181146109a2576109d0565b60ff1984168688015282151560051b8601870194506109d0565b896000528660002060005b848110156109c85781548882018a01529083019088016109ad565b870188019550505b50929b9a5050505050505050505050565b6000602082840312156109f357600080fd5b8151801515811461057657600080fdfea164736f6c6343000813000a", + "deployedBytecode": "0x60806040526004361061007b5760003560e01c8063971604c61161004e578063971604c6146101545780639ea9bd5914610175578063a3f4df7e14610195578063ffa1ad74146101de57600080fd5b806301ffc9a7146100805780630c959556146100c65780638abf6077146100db5780639356375c14610127575b600080fd5b34801561008c57600080fd5b506100b161009b36600461054c565b6001600160e01b03191663052a2cc960e01b1490565b60405190151581526020015b60405180910390f35b6100d96100d43660046105c6565b610227565b005b3480156100e757600080fd5b5061010f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100bd565b34801561013357600080fd5b50610147610142366004610624565b61032a565b6040516100bd919061068f565b6101676101623660046106a2565b6103c4565b6040519081526020016100bd565b34801561018157600080fd5b506100b16101903660046106fc565b6104fd565b3480156101a157600080fd5b506101476040518060400160405280600e81526020017f503235362056616c696461746f7200000000000000000000000000000000000081525081565b3480156101ea57600080fd5b506101476040518060400160405280600581526020017f302e302e3100000000000000000000000000000000000000000000000000000081525081565b33600090815260208190526040812080546102419061074f565b80601f016020809104026020016040519081016040528092919081815260200182805461026d9061074f565b80156102ba5780601f1061028f576101008083540402835291602001916102ba565b820191906000526020600020905b81548152906001019060200180831161029d57829003601f168201915b50503360009081526020819052604090209394506102df9250859150869050836107ee565b50336001600160a01b03167f49a125229beaa1b288f0f807170a37c7a131925683b0250b113db84181bfb06682858560405161031d939291906108d8565b60405180910390a2505050565b600060208190529081526040902080546103439061074f565b80601f016020809104026020016040519081016040528092919081815260200182805461036f9061074f565b80156103bc5780601f10610391576101008083540402835291602001916103bc565b820191906000526020600020905b81548152906001019060200180831161039f57829003601f168201915b505050505081565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ae7e17f060028660405160200161040a91815260200190565b60408051601f198184030181529082905261042491610908565b602060405180830381855afa158015610441573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906104649190610924565b6001600160a01b0388166000908152602081905260409081902090516001600160e01b031960e085901b1681526104a39291889188919060040161093d565b602060405180830381865afa1580156104c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104e491906109e1565b156104f1575060006104f5565b5060015b949350505050565b60405162461bcd60e51b815260206004820152600f60248201527f6e6f7420696d706c656d656e7465640000000000000000000000000000000000604482015260009060640160405180910390fd5b60006020828403121561055e57600080fd5b81356001600160e01b03198116811461057657600080fd5b9392505050565b60008083601f84011261058f57600080fd5b50813567ffffffffffffffff8111156105a757600080fd5b6020830191508360208285010111156105bf57600080fd5b9250929050565b600080602083850312156105d957600080fd5b823567ffffffffffffffff8111156105f057600080fd5b6105fc8582860161057d565b90969095509350505050565b80356001600160a01b038116811461061f57600080fd5b919050565b60006020828403121561063657600080fd5b61057682610608565b60005b8381101561065a578181015183820152602001610642565b50506000910152565b6000815180845261067b81602086016020860161063f565b601f01601f19169290920160200192915050565b6020815260006105766020830184610663565b600080600080606085870312156106b857600080fd5b6106c185610608565b935060208501359250604085013567ffffffffffffffff8111156106e457600080fd5b6106f08782880161057d565b95989497509550505050565b60008060006040848603121561071157600080fd5b61071a84610608565b9250602084013567ffffffffffffffff81111561073657600080fd5b6107428682870161057d565b9497909650939450505050565b600181811c9082168061076357607f821691505b60208210810361078357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b601f8211156107e957600081815260208120601f850160051c810160208610156107c65750805b601f850160051c820191505b818110156107e5578281556001016107d2565b5050505b505050565b67ffffffffffffffff83111561080657610806610789565b61081a83610814835461074f565b8361079f565b6000601f84116001811461084e57600085156108365750838201355b600019600387901b1c1916600186901b1783556108a8565b600083815260209020601f19861690835b8281101561087f578685013582556020948501946001909201910161085f565b508682101561089c5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6040815260006108eb6040830186610663565b82810360208401526108fe8185876108af565b9695505050505050565b6000825161091a81846020870161063f565b9190910192915050565b60006020828403121561093657600080fd5b5051919050565b848152600060206060818401526109586060840186886108af565b83810360408501526000855461096d8161074f565b8084526001828116801561098857600181146109a2576109d0565b60ff1984168688015282151560051b8601870194506109d0565b896000528660002060005b848110156109c85781548882018a01529083019088016109ad565b870188019550505b50929b9a5050505050505050505050565b6000602082840312156109f357600080fd5b8151801515811461057657600080fdfea164736f6c6343000813000a", "devdoc": { "kind": "dev", "methods": { diff --git a/deployments/iotex_testnet/WebauthnValidator.json b/deployments/iotex_testnet/WebauthnValidator.json new file mode 100644 index 0000000..7ff5ae6 --- /dev/null +++ b/deployments/iotex_testnet/WebauthnValidator.json @@ -0,0 +1,253 @@ +{ + "address": "0xe2C03A87C78783d85C263B020E9AeFDa3525d69c", + "abi": [ + { + "inputs": [ + { + "internalType": "contract ISecp256r1", + "name": "_impl", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "oldPk", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "newPk", + "type": "bytes" + } + ], + "name": "PkChanged", + "type": "event" + }, + { + "inputs": [], + "name": "NAME", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "enable", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "impl", + "outputs": [ + { + "internalType": "contract ISecp256r1", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pks", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "validCaller", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "userOpHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "validateSignature", + "outputs": [ + { + "internalType": "uint256", + "name": "validationData", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + } + ], + "transactionHash": "0xfd12df3a18883f56edb310b56c2c47d490a3ec5f26bb457febf47410693f45ac", + "receipt": { + "to": "0x355BE1cbfFBf803fdb17E0CB207D051cD9816916", + "from": "0x7c029553644F5E9442cb576c1056e0f7663Db1Fa", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "1185502", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xea78cfcf90585179f7f07a99cbc1452ec489eedea985d7a285d9474a372b2027", + "transactionHash": "0xfd12df3a18883f56edb310b56c2c47d490a3ec5f26bb457febf47410693f45ac", + "logs": [], + "blockNumber": 22647811, + "cumulativeGasUsed": "1185502", + "status": 1, + "byzantium": true + }, + "args": [ + "0xebB3F7930b044f4F85263e1Ed99490CA1D5414b2" + ], + "numDeployments": 1, + "solcInputHash": "b23988587d28d82ed6484bc5aecdcd50", + "metadata": "{\"compiler\":{\"version\":\"0.8.19+commit.7dd6d404\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract ISecp256r1\",\"name\":\"_impl\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"oldPk\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"newPk\",\"type\":\"bytes\"}],\"name\":\"PkChanged\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"NAME\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"VERSION\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"enable\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"impl\",\"outputs\":[{\"internalType\":\"contract ISecp256r1\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"pks\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"validCaller\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"userOpHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"validateSignature\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"validationData\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"supportsInterface(bytes4)\":{\"details\":\"Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/validators/p256/WebauthnValidator.sol\":\"WebauthnValidator\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":800},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"contracts/common/Contants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nlibrary Contants {\\n address internal constant SENTINEL = address(0x1);\\n\\n uint256 internal constant SIG_VALIDATION_FAILED = 1;\\n}\\n\",\"keccak256\":\"0x4def4c34ea7d1925f182376cda97a69c536491aa43ebadaaf710b58173f5f76b\",\"license\":\"MIT\"},\"contracts/interfaces/IValidator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nimport \\\"./Metadata.sol\\\";\\n\\ninterface IValidator is Metadata {\\n function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)\\n external\\n payable\\n returns (uint256 validationData);\\n\\n function validCaller(address caller, bytes calldata data) external view returns (bool);\\n\\n function enable(bytes calldata data) external payable;\\n}\\n\",\"keccak256\":\"0x7c6a9305295ecdee128a434cc87514250605c3a3159ecd2dd3ee56dc9ce6f862\",\"license\":\"MIT\"},\"contracts/interfaces/Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\n\\ninterface Metadata is IERC165 {\\n function NAME() external view returns (string memory);\\n function VERSION() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0xcbcd27a057fef9d4c42f0e229575bd8fb28a8baad9440869bb30fcaefccc0729\",\"license\":\"MIT\"},\"contracts/validators/BaseValidator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nimport \\\"../interfaces/IValidator.sol\\\";\\n\\nabstract contract BaseValidator is IValidator {\\n function supportsInterface(bytes4 interfaceId) external pure returns (bool) {\\n return interfaceId == type(IValidator).interfaceId;\\n }\\n}\\n\",\"keccak256\":\"0x6bc845d709ba4b8925de3dd209016868ca59f6ede3c52c76d1f12a5783a04579\",\"license\":\"MIT\"},\"contracts/validators/p256/Base64.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nlibrary Base64 {\\n /**\\n * @dev Base64 Encoding/Decoding Table\\n */\\n string internal constant _TABLE = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\\\";\\n\\n /**\\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\\n */\\n function encode(bytes memory data) internal pure returns (string memory) {\\n /**\\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\\n */\\n if (data.length == 0) return \\\"\\\";\\n\\n // Loads the table into memory\\n string memory table = _TABLE;\\n\\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\\n // and split into 4 numbers of 6 bits.\\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\\n // - `data.length + 2` -> Round up\\n // - `/ 3` -> Number of 3-bytes chunks\\n // - `4 *` -> 4 characters for each chunk\\n uint256 newlength = data.length * 8 / 6;\\n if (data.length % 6 > 0) {\\n newlength++;\\n }\\n string memory result = new string(newlength);\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Prepare the lookup table (skip the first \\\"length\\\" byte)\\n let tablePtr := add(table, 1)\\n\\n // Prepare result pointer, jump over length\\n let resultPtr := add(result, 32)\\n // let targetLength := add(resultPtr, newlength)\\n\\n // Run over the input, 3 bytes at a time\\n for {\\n let dataPtr := data\\n let endPtr := add(data, mload(data))\\n } lt(dataPtr, endPtr) {} {\\n // Advance 3 bytes\\n dataPtr := add(dataPtr, 3)\\n let input := mload(dataPtr)\\n\\n // To write each character, shift the 3 bytes (18 bits) chunk\\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\\n // and apply logical AND with 0x3F which is the number of\\n // the previous character in the ASCII table prior to the Base64 Table\\n // The result is then added to the table to get the character to write,\\n // and finally write it in the result pointer but with a left shift\\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\\n resultPtr := add(resultPtr, 1)\\n\\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\\n resultPtr := add(resultPtr, 1)\\n\\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\\n resultPtr := add(resultPtr, 1)\\n\\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\\n resultPtr := add(resultPtr, 1)\\n }\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x2aa241e8e13cdb63bc886b6a5ab0d464af440e7019d15abf0dc0a67bd3fe7def\",\"license\":\"MIT\"},\"contracts/validators/p256/ISecp256r1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\ninterface ISecp256r1 {\\n function validateSignature(bytes32 message, bytes calldata signature, bytes calldata publicKey)\\n external\\n view\\n returns (bool);\\n}\\n\",\"keccak256\":\"0x2c27d09b504eebfad02daf6a774b8df8bf29c51077f288bf6dd5464b4a18d177\",\"license\":\"MIT\"},\"contracts/validators/p256/WebauthnValidator.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.19;\\n\\nimport \\\"../../common/Contants.sol\\\";\\nimport \\\"../BaseValidator.sol\\\";\\nimport \\\"./ISecp256r1.sol\\\";\\nimport \\\"./Base64.sol\\\";\\n\\ncontract WebauthnValidator is BaseValidator {\\n string public constant override NAME = \\\"Webauthn Validator\\\";\\n string public constant override VERSION = \\\"0.0.1\\\";\\n\\n event PkChanged(address indexed account, bytes oldPk, bytes newPk);\\n\\n ISecp256r1 public immutable impl;\\n mapping(address => bytes) public pks;\\n\\n constructor(ISecp256r1 _impl) {\\n impl = _impl;\\n }\\n\\n function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)\\n external\\n payable\\n override\\n returns (uint256 validationData)\\n {\\n bytes memory sig;\\n bytes32 messageHash;\\n {\\n (\\n bytes memory realSig,\\n bytes memory authenticatorData,\\n string memory clientDataJSONPre,\\n string memory clientDataJSONPost\\n ) = abi.decode(signature, (bytes, bytes, string, string));\\n\\n string memory clientDataJSON =\\n string.concat(clientDataJSONPre, Base64.encode(bytes.concat(userOpHash)), clientDataJSONPost);\\n bytes32 clientDataHash = sha256(bytes(clientDataJSON));\\n messageHash = sha256(bytes.concat(authenticatorData, clientDataHash));\\n sig = realSig;\\n }\\n\\n if (impl.validateSignature(messageHash, sig, pks[account])) {\\n return 0;\\n }\\n return Contants.SIG_VALIDATION_FAILED;\\n }\\n\\n function enable(bytes calldata data) external payable override {\\n bytes memory old = pks[msg.sender];\\n pks[msg.sender] = data;\\n emit PkChanged(msg.sender, old, data);\\n }\\n\\n function validCaller(address, bytes calldata) external pure override returns (bool) {\\n revert(\\\"not implemented\\\");\\n }\\n}\\n\",\"keccak256\":\"0x1cdc3912fa26ad708d1878990068fb69ec95f2ec7955b501e6d6935bbd4e127c\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a060405234801561001057600080fd5b50604051610f27380380610f2783398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b608051610e9561009260003960008181610105015261053c0152610e956000f3fe60806040526004361061007b5760003560e01c8063971604c61161004e578063971604c61461016c5780639ea9bd591461018d578063a3f4df7e146101ad578063ffa1ad74146101f657600080fd5b806301ffc9a7146100805780630c959556146100de5780638abf6077146100f35780639356375c1461013f575b600080fd5b34801561008c57600080fd5b506100c961009b366004610765565b7fffffffff000000000000000000000000000000000000000000000000000000001663052a2cc960e01b1490565b60405190151581526020015b60405180910390f35b6100f16100ec3660046107f7565b61023f565b005b3480156100ff57600080fd5b506101277f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100d5565b34801561014b57600080fd5b5061015f61015a366004610855565b610342565b6040516100d591906108c0565b61017f61017a3660046108d3565b6103dc565b6040519081526020016100d5565b34801561019957600080fd5b506100c96101a836600461092d565b6105da565b3480156101b957600080fd5b5061015f6040518060400160405280601281526020017f576562617574686e2056616c696461746f72000000000000000000000000000081525081565b34801561020257600080fd5b5061015f6040518060400160405280600581526020017f302e302e3100000000000000000000000000000000000000000000000000000081525081565b336000908152602081905260408120805461025990610980565b80601f016020809104026020016040519081016040528092919081815260200182805461028590610980565b80156102d25780601f106102a7576101008083540402835291602001916102d2565b820191906000526020600020905b8154815290600101906020018083116102b557829003601f168201915b50503360009081526020819052604090209394506102f7925085915086905083610a1f565b50336001600160a01b03167f49a125229beaa1b288f0f807170a37c7a131925683b0250b113db84181bfb06682858560405161033593929190610ae0565b60405180910390a2505050565b6000602081905290815260409020805461035b90610980565b80601f016020809104026020016040519081016040528092919081815260200182805461038790610980565b80156103d45780601f106103a9576101008083540402835291602001916103d4565b820191906000526020600020905b8154815290600101906020018083116103b757829003601f168201915b505050505081565b6000606081808080806103f1888a018a610bb3565b93509350935093506000826104268c60405160200161041291815260200190565b604051602081830303815290604052610629565b8360405160200161043993929190610c60565b6040516020818303038152906040529050600060028260405161045c9190610ca3565b602060405180830381855afa158015610479573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061049c9190610cbf565b9050600285826040516020016104b3929190610cd8565b60408051601f19818403018152908290526104cd91610ca3565b602060405180830381855afa1580156104ea573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061050d9190610cbf565b6001600160a01b038e8116600090815260208190526040908190209051630ae7e17f60e41b8152989a509198507f0000000000000000000000000000000000000000000000000000000000000000169663ae7e17f0965061057a9550889450899350909150600401610cfa565b602060405180830381865afa158015610597573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105bb9190610d9c565b156105cb576000925050506105d2565b6001925050505b949350505050565b60405162461bcd60e51b815260206004820152600f60248201527f6e6f7420696d706c656d656e7465640000000000000000000000000000000000604482015260009060640160405180910390fd5b6060815160000361064857505060408051602081019091526000815290565b6000604051806060016040528060408152602001610e4960409139905060006006845160086106779190610dd4565b6106819190610e07565b90506000600685516106939190610e1b565b11156106a757806106a381610e2f565b9150505b60008167ffffffffffffffff8111156106c2576106c26109ba565b6040519080825280601f01601f1916602001820160405280156106ec576020820181803683370190505b509050600183016020820186875188015b80821015610758576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f81168501518453506001830192506106fd565b5092979650505050505050565b60006020828403121561077757600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146107a757600080fd5b9392505050565b60008083601f8401126107c057600080fd5b50813567ffffffffffffffff8111156107d857600080fd5b6020830191508360208285010111156107f057600080fd5b9250929050565b6000806020838503121561080a57600080fd5b823567ffffffffffffffff81111561082157600080fd5b61082d858286016107ae565b90969095509350505050565b80356001600160a01b038116811461085057600080fd5b919050565b60006020828403121561086757600080fd5b6107a782610839565b60005b8381101561088b578181015183820152602001610873565b50506000910152565b600081518084526108ac816020860160208601610870565b601f01601f19169290920160200192915050565b6020815260006107a76020830184610894565b600080600080606085870312156108e957600080fd5b6108f285610839565b935060208501359250604085013567ffffffffffffffff81111561091557600080fd5b610921878288016107ae565b95989497509550505050565b60008060006040848603121561094257600080fd5b61094b84610839565b9250602084013567ffffffffffffffff81111561096757600080fd5b610973868287016107ae565b9497909650939450505050565b600181811c9082168061099457607f821691505b6020821081036109b457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b601f821115610a1a57600081815260208120601f850160051c810160208610156109f75750805b601f850160051c820191505b81811015610a1657828155600101610a03565b5050505b505050565b67ffffffffffffffff831115610a3757610a376109ba565b610a4b83610a458354610980565b836109d0565b6000601f841160018114610a7f5760008515610a675750838201355b600019600387901b1c1916600186901b178355610ad9565b600083815260209020601f19861690835b82811015610ab05786850135825560209485019460019092019101610a90565b5086821015610acd5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b604081526000610af36040830186610894565b8281036020840152838152838560208301376000602085830101526020601f19601f860116820101915050949350505050565b600082601f830112610b3757600080fd5b813567ffffffffffffffff80821115610b5257610b526109ba565b604051601f8301601f19908116603f01168101908282118183101715610b7a57610b7a6109ba565b81604052838152866020858801011115610b9357600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060808587031215610bc957600080fd5b843567ffffffffffffffff80821115610be157600080fd5b610bed88838901610b26565b95506020870135915080821115610c0357600080fd5b610c0f88838901610b26565b94506040870135915080821115610c2557600080fd5b610c3188838901610b26565b93506060870135915080821115610c4757600080fd5b50610c5487828801610b26565b91505092959194509250565b60008451610c72818460208901610870565b845190830190610c86818360208901610870565b8451910190610c99818360208801610870565b0195945050505050565b60008251610cb5818460208701610870565b9190910192915050565b600060208284031215610cd157600080fd5b5051919050565b60008351610cea818460208801610870565b9190910191825250602001919050565b83815260006020606081840152610d146060840186610894565b838103604085015260008554610d2981610980565b80845260018281168015610d445760018114610d5e57610d8c565b60ff1984168688015282151560051b860187019450610d8c565b896000528660002060005b84811015610d845781548882018a0152908301908801610d69565b870188019550505b50929a9950505050505050505050565b600060208284031215610dae57600080fd5b815180151581146107a757600080fd5b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610deb57610deb610dbe565b92915050565b634e487b7160e01b600052601260045260246000fd5b600082610e1657610e16610df1565b500490565b600082610e2a57610e2a610df1565b500690565b600060018201610e4157610e41610dbe565b506001019056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5fa164736f6c6343000813000a", + "deployedBytecode": "0x60806040526004361061007b5760003560e01c8063971604c61161004e578063971604c61461016c5780639ea9bd591461018d578063a3f4df7e146101ad578063ffa1ad74146101f657600080fd5b806301ffc9a7146100805780630c959556146100de5780638abf6077146100f35780639356375c1461013f575b600080fd5b34801561008c57600080fd5b506100c961009b366004610765565b7fffffffff000000000000000000000000000000000000000000000000000000001663052a2cc960e01b1490565b60405190151581526020015b60405180910390f35b6100f16100ec3660046107f7565b61023f565b005b3480156100ff57600080fd5b506101277f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100d5565b34801561014b57600080fd5b5061015f61015a366004610855565b610342565b6040516100d591906108c0565b61017f61017a3660046108d3565b6103dc565b6040519081526020016100d5565b34801561019957600080fd5b506100c96101a836600461092d565b6105da565b3480156101b957600080fd5b5061015f6040518060400160405280601281526020017f576562617574686e2056616c696461746f72000000000000000000000000000081525081565b34801561020257600080fd5b5061015f6040518060400160405280600581526020017f302e302e3100000000000000000000000000000000000000000000000000000081525081565b336000908152602081905260408120805461025990610980565b80601f016020809104026020016040519081016040528092919081815260200182805461028590610980565b80156102d25780601f106102a7576101008083540402835291602001916102d2565b820191906000526020600020905b8154815290600101906020018083116102b557829003601f168201915b50503360009081526020819052604090209394506102f7925085915086905083610a1f565b50336001600160a01b03167f49a125229beaa1b288f0f807170a37c7a131925683b0250b113db84181bfb06682858560405161033593929190610ae0565b60405180910390a2505050565b6000602081905290815260409020805461035b90610980565b80601f016020809104026020016040519081016040528092919081815260200182805461038790610980565b80156103d45780601f106103a9576101008083540402835291602001916103d4565b820191906000526020600020905b8154815290600101906020018083116103b757829003601f168201915b505050505081565b6000606081808080806103f1888a018a610bb3565b93509350935093506000826104268c60405160200161041291815260200190565b604051602081830303815290604052610629565b8360405160200161043993929190610c60565b6040516020818303038152906040529050600060028260405161045c9190610ca3565b602060405180830381855afa158015610479573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061049c9190610cbf565b9050600285826040516020016104b3929190610cd8565b60408051601f19818403018152908290526104cd91610ca3565b602060405180830381855afa1580156104ea573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061050d9190610cbf565b6001600160a01b038e8116600090815260208190526040908190209051630ae7e17f60e41b8152989a509198507f0000000000000000000000000000000000000000000000000000000000000000169663ae7e17f0965061057a9550889450899350909150600401610cfa565b602060405180830381865afa158015610597573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105bb9190610d9c565b156105cb576000925050506105d2565b6001925050505b949350505050565b60405162461bcd60e51b815260206004820152600f60248201527f6e6f7420696d706c656d656e7465640000000000000000000000000000000000604482015260009060640160405180910390fd5b6060815160000361064857505060408051602081019091526000815290565b6000604051806060016040528060408152602001610e4960409139905060006006845160086106779190610dd4565b6106819190610e07565b90506000600685516106939190610e1b565b11156106a757806106a381610e2f565b9150505b60008167ffffffffffffffff8111156106c2576106c26109ba565b6040519080825280601f01601f1916602001820160405280156106ec576020820181803683370190505b509050600183016020820186875188015b80821015610758576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f81168501518453506001830192506106fd565b5092979650505050505050565b60006020828403121561077757600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146107a757600080fd5b9392505050565b60008083601f8401126107c057600080fd5b50813567ffffffffffffffff8111156107d857600080fd5b6020830191508360208285010111156107f057600080fd5b9250929050565b6000806020838503121561080a57600080fd5b823567ffffffffffffffff81111561082157600080fd5b61082d858286016107ae565b90969095509350505050565b80356001600160a01b038116811461085057600080fd5b919050565b60006020828403121561086757600080fd5b6107a782610839565b60005b8381101561088b578181015183820152602001610873565b50506000910152565b600081518084526108ac816020860160208601610870565b601f01601f19169290920160200192915050565b6020815260006107a76020830184610894565b600080600080606085870312156108e957600080fd5b6108f285610839565b935060208501359250604085013567ffffffffffffffff81111561091557600080fd5b610921878288016107ae565b95989497509550505050565b60008060006040848603121561094257600080fd5b61094b84610839565b9250602084013567ffffffffffffffff81111561096757600080fd5b610973868287016107ae565b9497909650939450505050565b600181811c9082168061099457607f821691505b6020821081036109b457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b601f821115610a1a57600081815260208120601f850160051c810160208610156109f75750805b601f850160051c820191505b81811015610a1657828155600101610a03565b5050505b505050565b67ffffffffffffffff831115610a3757610a376109ba565b610a4b83610a458354610980565b836109d0565b6000601f841160018114610a7f5760008515610a675750838201355b600019600387901b1c1916600186901b178355610ad9565b600083815260209020601f19861690835b82811015610ab05786850135825560209485019460019092019101610a90565b5086821015610acd5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b604081526000610af36040830186610894565b8281036020840152838152838560208301376000602085830101526020601f19601f860116820101915050949350505050565b600082601f830112610b3757600080fd5b813567ffffffffffffffff80821115610b5257610b526109ba565b604051601f8301601f19908116603f01168101908282118183101715610b7a57610b7a6109ba565b81604052838152866020858801011115610b9357600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060808587031215610bc957600080fd5b843567ffffffffffffffff80821115610be157600080fd5b610bed88838901610b26565b95506020870135915080821115610c0357600080fd5b610c0f88838901610b26565b94506040870135915080821115610c2557600080fd5b610c3188838901610b26565b93506060870135915080821115610c4757600080fd5b50610c5487828801610b26565b91505092959194509250565b60008451610c72818460208901610870565b845190830190610c86818360208901610870565b8451910190610c99818360208801610870565b0195945050505050565b60008251610cb5818460208701610870565b9190910192915050565b600060208284031215610cd157600080fd5b5051919050565b60008351610cea818460208801610870565b9190910191825250602001919050565b83815260006020606081840152610d146060840186610894565b838103604085015260008554610d2981610980565b80845260018281168015610d445760018114610d5e57610d8c565b60ff1984168688015282151560051b860187019450610d8c565b896000528660002060005b84811015610d845781548882018a0152908301908801610d69565b870188019550505b50929a9950505050505050505050565b600060208284031215610dae57600080fd5b815180151581146107a757600080fd5b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610deb57610deb610dbe565b92915050565b634e487b7160e01b600052601260045260246000fd5b600082610e1657610e16610df1565b500490565b600082610e2a57610e2a610df1565b500690565b600060018201610e4157610e41610dbe565b506001019056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5fa164736f6c6343000813000a", + "devdoc": { + "kind": "dev", + "methods": { + "supportsInterface(bytes4)": { + "details": "Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 312, + "contract": "contracts/validators/p256/WebauthnValidator.sol:WebauthnValidator", + "label": "pks", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_address,t_bytes_storage)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bytes_storage": { + "encoding": "bytes", + "label": "bytes", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_bytes_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bytes)", + "numberOfBytes": "32", + "value": "t_bytes_storage" + } + } + } +} \ No newline at end of file diff --git a/deployments/iotex_testnet/solcInputs/b23988587d28d82ed6484bc5aecdcd50.json b/deployments/iotex_testnet/solcInputs/b23988587d28d82ed6484bc5aecdcd50.json new file mode 100644 index 0000000..98eafcc --- /dev/null +++ b/deployments/iotex_testnet/solcInputs/b23988587d28d82ed6484bc5aecdcd50.json @@ -0,0 +1,61 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "contracts/common/Contants.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nlibrary Contants {\n address internal constant SENTINEL = address(0x1);\n\n uint256 internal constant SIG_VALIDATION_FAILED = 1;\n}\n" + }, + "contracts/interfaces/IValidator.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nimport \"./Metadata.sol\";\n\ninterface IValidator is Metadata {\n function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)\n external\n payable\n returns (uint256 validationData);\n\n function validCaller(address caller, bytes calldata data) external view returns (bool);\n\n function enable(bytes calldata data) external payable;\n}\n" + }, + "contracts/interfaces/Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\ninterface Metadata is IERC165 {\n function NAME() external view returns (string memory);\n function VERSION() external view returns (string memory);\n}\n" + }, + "contracts/validators/BaseValidator.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nimport \"../interfaces/IValidator.sol\";\n\nabstract contract BaseValidator is IValidator {\n function supportsInterface(bytes4 interfaceId) external pure returns (bool) {\n return interfaceId == type(IValidator).interfaceId;\n }\n}\n" + }, + "contracts/validators/p256/Base64.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n uint256 newlength = data.length * 8 / 6;\n if (data.length % 6 > 0) {\n newlength++;\n }\n string memory result = new string(newlength);\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n // let targetLength := add(resultPtr, newlength)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {} {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1)\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1)\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1)\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1)\n }\n }\n\n return result;\n }\n}\n" + }, + "contracts/validators/p256/ISecp256r1.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\ninterface ISecp256r1 {\n function validateSignature(bytes32 message, bytes calldata signature, bytes calldata publicKey)\n external\n view\n returns (bool);\n}\n" + }, + "contracts/validators/p256/P256Validator.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nimport \"../../common/Contants.sol\";\nimport \"../BaseValidator.sol\";\nimport \"./ISecp256r1.sol\";\nimport \"./Base64.sol\";\n\ncontract P256Validator is BaseValidator {\n string public constant override NAME = \"P256 Validator\";\n string public constant override VERSION = \"0.0.1\";\n\n event PkChanged(address indexed account, bytes oldPk, bytes newPk);\n\n ISecp256r1 public immutable impl;\n mapping(address => bytes) public pks;\n\n constructor(ISecp256r1 _impl) {\n impl = _impl;\n }\n\n function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)\n external\n payable\n override\n returns (uint256 validationData)\n {\n if (impl.validateSignature(sha256(abi.encode(userOpHash)), signature, pks[account])) {\n return 0;\n }\n return Contants.SIG_VALIDATION_FAILED;\n }\n\n function enable(bytes calldata data) external payable override {\n bytes memory old = pks[msg.sender];\n pks[msg.sender] = data;\n emit PkChanged(msg.sender, old, data);\n }\n\n function validCaller(address, bytes calldata) external pure override returns (bool) {\n revert(\"not implemented\");\n }\n}\n" + }, + "contracts/validators/p256/WebauthnValidator.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nimport \"../../common/Contants.sol\";\nimport \"../BaseValidator.sol\";\nimport \"./ISecp256r1.sol\";\nimport \"./Base64.sol\";\n\ncontract WebauthnValidator is BaseValidator {\n string public constant override NAME = \"Webauthn Validator\";\n string public constant override VERSION = \"0.0.1\";\n\n event PkChanged(address indexed account, bytes oldPk, bytes newPk);\n\n ISecp256r1 public immutable impl;\n mapping(address => bytes) public pks;\n\n constructor(ISecp256r1 _impl) {\n impl = _impl;\n }\n\n function validateSignature(address account, bytes32 userOpHash, bytes calldata signature)\n external\n payable\n override\n returns (uint256 validationData)\n {\n bytes memory sig;\n bytes32 messageHash;\n {\n (\n bytes memory realSig,\n bytes memory authenticatorData,\n string memory clientDataJSONPre,\n string memory clientDataJSONPost\n ) = abi.decode(signature, (bytes, bytes, string, string));\n\n string memory clientDataJSON =\n string.concat(clientDataJSONPre, Base64.encode(bytes.concat(userOpHash)), clientDataJSONPost);\n bytes32 clientDataHash = sha256(bytes(clientDataJSON));\n messageHash = sha256(bytes.concat(authenticatorData, clientDataHash));\n sig = realSig;\n }\n\n if (impl.validateSignature(messageHash, sig, pks[account])) {\n return 0;\n }\n return Contants.SIG_VALIDATION_FAILED;\n }\n\n function enable(bytes calldata data) external payable override {\n bytes memory old = pks[msg.sender];\n pks[msg.sender] = data;\n emit PkChanged(msg.sender, old, data);\n }\n\n function validCaller(address, bytes calldata) external pure override returns (bool) {\n revert(\"not implemented\");\n }\n}\n" + } + }, + "settings": { + "viaIR": false, + "optimizer": { + "enabled": true, + "runs": 800 + }, + "metadata": { + "bytecodeHash": "none", + "useLiteralContent": true + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + } + } +} \ No newline at end of file