diff --git a/.github/workflows/forge.yml b/.github/workflows/forge.yml index 147dc15..82914b6 100644 --- a/.github/workflows/forge.yml +++ b/.github/workflows/forge.yml @@ -24,4 +24,6 @@ jobs: run: forge build - name: Run Forge tests - run: forge test --fork-url https://rpc.ankr.com/polygon_mumbai -vvvv \ No newline at end of file + env: + ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} + run: forge test -vvvv \ No newline at end of file diff --git a/.gitignore b/.gitignore index 136b6d7..5cc712b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ lib .hardhat/contracts # Deployment files -**deployments/test.json +deployments/test.json +**deployments/test/*.json **/tmp/* !**/tmp/example.json diff --git a/.gitmodules b/.gitmodules index 888d42d..690924b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "lib/forge-std"] path = lib/forge-std url = https://github.com/foundry-rs/forge-std +[submodule "lib/openzeppelin-contracts"] + path = lib/openzeppelin-contracts + url = https://github.com/OpenZeppelin/openzeppelin-contracts diff --git a/.hardhat/README.md b/.hardhat/README.md new file mode 100644 index 0000000..45f7a72 --- /dev/null +++ b/.hardhat/README.md @@ -0,0 +1,69 @@ +
+
+ Logo + +

+ Sismo Connect Solidity +

+ +

+ Made by Sismo +

+ +

+ + + + + + + + + +

+
+ + +Sismo Connect Solidity is a Solidity library that allows you to verify the zk-proofs of your Sismo Connect Application onchain and simplify the use of the [sismo-connect-onchain-verifier](https://github.com/sismo-core/sismo-connect-onchain-verifier). + +Here is the link to the full documentation of the library: [Sismo Connect Solidity Library](https://docs.sismo.io/build-with-sismo-connect/technical-documentation/solidity) + +You can learn more on Sismo Connect [here](https://docs.sismo.io/sismo-docs/build-with-sismo-connect/getting-started). + +### Prerequisites + +- [Node.js](https://nodejs.org/en/download/) >= 18.15.0 (Latest LTS version) +- [Yarn](https://classic.yarnpkg.com/en/docs/install) + +## Usage + +### Installation + +```bash +# install the package +yarn add @sismo-core/sismo-connect-solidity +``` + +### Import the library +In your solidity file: + +```solidity +import {SismoConnect} from "@sismo-core/sismo-connect-solidity/contracts/SismoConnectLib.sol"; +``` + +You will find here how to use the library: [Sismo Connect Solidity Library](https://docs.sismo.io/build-with-sismo-connect/technical-documentation/solidity) + +## License + +Distributed under the MIT License. + +## Contribute + +Please, feel free to open issues, PRs or simply provide feedback! + +## Contact + +Send us a message in [Telegram](https://builders.sismo.io/) or [Discord](https://discord.gg/sismo) + +
+bottom diff --git a/.hardhat/package.json b/.hardhat/package.json new file mode 100644 index 0000000..4c45bbd --- /dev/null +++ b/.hardhat/package.json @@ -0,0 +1,25 @@ +{ + "name": "@sismo-core/sismo-connect-solidity", + "description": "Sismo Connect Library", + "version": "0.0.21", + "scripts": { + "prepare": "mkdir -p contracts; cp -r ../src/* contracts" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/sismo-core/sismo-connect-solidity.git" + }, + "keywords": [ + "solidity", + "ethereum", + "smart", + "contracts" + ], + "author": "Sismo ", + "license": "MIT", + "bugs": { + "url": "https://github.com/sismo-core/sismo-connect-solidity/issues" + }, + "homepage": "https://github.com/sismo-core/sismo-connect-solidity#readme", + "main": "index.js" +} diff --git a/deployments/base-goerli.json b/deployments/base-goerli.json new file mode 100644 index 0000000..caec925 --- /dev/null +++ b/deployments/base-goerli.json @@ -0,0 +1,6 @@ +{ + "authRequestBuilder": "0xD4339e6d873b584FFfeACceE4CcB8Bf31Cd96ebb", + "claimRequestBuilder": "0xF03dA119efEc165DbDc15D593aB455810C7fEd74", + "requestBuilder": "0x0bB5c193aa815F7815aB8e854A87E041519CD2ad", + "signatureBuilder": "0xc8F165a3B4CfB7CD2Ae92A582F17b0d7EB3BcE11" +} \ No newline at end of file diff --git a/deployments/base.json b/deployments/base.json new file mode 100644 index 0000000..ab52036 --- /dev/null +++ b/deployments/base.json @@ -0,0 +1,6 @@ +{ + "authRequestBuilder": "0x8D090172DA53A21D27E7B651ab6E7D9334Ea0783", + "claimRequestBuilder": "0x1B05f16686396398F16f8916A032D738005126b7", + "requestBuilder": "0x40e208f4815Ce25b32BeEEC7415C6CA9424a898F", + "signatureBuilder": "0x1e7a99e06Ca2C1A63330eC2df8D4fC15EfDa4C55" +} diff --git a/foundry.toml b/foundry.toml index 4d9fd31..c94bbbf 100644 --- a/foundry.toml +++ b/foundry.toml @@ -3,15 +3,23 @@ optimizer_runs = 1000000 verbosity = 1 libs = ["lib"] fs_permissions = [{ access = "read-write", path = "./"}] +ffi = true bytecode_hash="none" - -[fmt] -ignore = ["test/libs/SimoConnectLib.t.sol"] +solc_version="0.8.19" [rpc_endpoints] -polygon = "${RPC_URL}" -gnosis = "${RPC_URL}" -goerli = "${RPC_URL}" -mumbai = "${RPC_URL}" -mainnet = "${RPC_URL}" +arbitrum_one = "https://arb-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}" +arbitrum_goerli = "https://arb-goerli.g.alchemy.com/v2/${ALCHEMY_API_KEY}" +base = "https://mainnet.base.org" +base_goerli = "https://goerli.base.org" +goerli = "https://eth-goerli.g.alchemy.com/v2/${ALCHEMY_API_KEY}" +gnosis = "https://rpc.gnosischain.com" +localhost = "http://localhost:8545" +mainnet = "https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}" +mumbai = "https://polygon-mumbai.g.alchemy.com/v2/${ALCHEMY_API_KEY}" +optimism = "https://opt-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}" +optimism_goerli = "https://opt-goerli.g.alchemy.com/v2/${ALCHEMY_API_KEY}" +polygon = "https://polygon-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}" +scroll_testnet_goerli = "https://alpha-rpc.scroll.io/l2" +sepolia = "https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}" diff --git a/lib/openzeppelin-contracts b/lib/openzeppelin-contracts new file mode 160000 index 0000000..d00acef --- /dev/null +++ b/lib/openzeppelin-contracts @@ -0,0 +1 @@ +Subproject commit d00acef4059807535af0bd0dd0ddf619747a044b diff --git a/package.json b/package.json index 44afc70..3544517 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "prettier-plugin-solidity": "^1.0.0-beta.13" }, "scripts": { - "lint": "prettier --write **.sol", - "setup-fork": "./script/bash/setup-fork.sh" + "test": "forge test", + "save-deployments": "./script/bash/save-deployments.sh", + "lint": "prettier --write **.sol" } } diff --git a/remappings.txt b/remappings.txt index 83fbb69..13b8148 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1 +1,2 @@ -forge-std/=lib/forge-std/src/ \ No newline at end of file +forge-std/=lib/forge-std/src/ +@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ \ No newline at end of file diff --git a/script/BaseConfig.sol b/script/BaseConfig.sol new file mode 100644 index 0000000..c7cbc61 --- /dev/null +++ b/script/BaseConfig.sol @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import {Script} from "forge-std/Script.sol"; +import "forge-std/console.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; + +struct DeploymentConfig { + address authRequestBuilder; + address claimRequestBuilder; + address requestBuilder; + address signatureBuilder; +} + +contract BaseDeploymentConfig is Script { + DeploymentConfig public config; + + string public _chainName; + bool public _checkIfEmpty; + + address immutable SISMO_ADDRESSES_PROVIDER_V2 = 0x3Cd5334eB64ebBd4003b72022CC25465f1BFcEe6; + address immutable ZERO_ADDRESS = 0x0000000000000000000000000000000000000000; + + error ChainNameNotFound(string chainName); + + function _setConfig(string memory chainName) internal { + if ( + _compareStrings(chainName, "mainnet") || + _compareStrings(chainName, "gnosis") || + _compareStrings(chainName, "polygon") || + _compareStrings(chainName, "optimism") || + _compareStrings(chainName, "arbitrum-one") || + _compareStrings(chainName, "base") || + _compareStrings(chainName, "testnet-goerli") || + _compareStrings(chainName, "testnet-sepolia") || + _compareStrings(chainName, "testnet-mumbai") || + _compareStrings(chainName, "optimism-goerli") || + _compareStrings(chainName, "arbitrum-goerli") || + _compareStrings(chainName, "base-goerli") || + _compareStrings(chainName, "scroll-testnet-goerli") || + _compareStrings(chainName, "staging-goerli") || + _compareStrings(chainName, "staging-mumbai") || + _compareStrings(chainName, "test") + ) { + config = _readDeploymentConfig( + string.concat(vm.projectRoot(), "/deployments/", chainName, ".json") + ); + } else { + revert ChainNameNotFound(chainName); + } + } + + function _readDeploymentConfig( + string memory filePath + ) internal view returns (DeploymentConfig memory) { + string memory file = _tryReadingFile(filePath); + return + DeploymentConfig({ + authRequestBuilder: _tryReadingAddressFromFileAtKey(file, ".authRequestBuilder"), + claimRequestBuilder: _tryReadingAddressFromFileAtKey(file, ".claimRequestBuilder"), + requestBuilder: _tryReadingAddressFromFileAtKey(file, ".requestBuilder"), + signatureBuilder: _tryReadingAddressFromFileAtKey(file, ".signatureBuilder") + }); + } + + function _tryReadingFile(string memory filePath) internal view returns (string memory) { + try vm.readFile(filePath) returns (string memory file) { + return file; + } catch { + return ""; + } + } + + function _tryReadingAddressFromFileAtKey( + string memory file, + string memory key + ) internal view returns (address) { + try vm.parseJson(file, key) returns (bytes memory encodedAddress) { + return + keccak256(encodedAddress) == keccak256(abi.encodePacked((""))) + ? address(0) + : abi.decode(encodedAddress, (address)); + } catch { + return ZERO_ADDRESS; + } + } + + function _saveDeploymentConfig(string memory chainName) internal { + _createFolderIfItDoesNotExists(string.concat(vm.projectRoot(), "/deployments")); + _createFolderIfItDoesNotExists(string.concat(vm.projectRoot(), "/deployments/tmp")); + _createFolderIfItDoesNotExists(string.concat(vm.projectRoot(), "/deployments/tmp/", chainName)); + + vm.serializeAddress(chainName, "authRequestBuilder", address(config.authRequestBuilder)); + vm.serializeAddress(chainName, "claimRequestBuilder", address(config.claimRequestBuilder)); + vm.serializeAddress(chainName, "requestBuilder", address(config.requestBuilder)); + string memory finalJson = vm.serializeAddress( + chainName, + "signatureBuilder", + address(config.signatureBuilder) + ); + + vm.writeJson( + finalJson, + string.concat(vm.projectRoot(), "/deployments/tmp/", chainName, "/run-latest.json") + ); + } + + function _createFolderIfItDoesNotExists(string memory folderPath) internal { + string[] memory inputs = new string[](3); + inputs[0] = "mkdir"; + inputs[1] = "-p"; + inputs[2] = folderPath; + vm.ffi(inputs); + } + + function _compareStrings(string memory a, string memory b) internal pure returns (bool) { + return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b)))); + } +} diff --git a/script/DeployLibraries.s.sol b/script/DeployLibraries.s.sol new file mode 100644 index 0000000..fd341d8 --- /dev/null +++ b/script/DeployLibraries.s.sol @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.17; + +import "forge-std/Script.sol"; +import "forge-std/console.sol"; +import {BaseDeploymentConfig, DeploymentConfig} from "script/BaseConfig.sol"; +import {IAddressesProvider} from "src/interfaces/IAddressesProvider.sol"; +import {AuthRequestBuilder} from "src/utils/AuthRequestBuilder.sol"; +import {ClaimRequestBuilder} from "src/utils/ClaimRequestBuilder.sol"; +import {SignatureBuilder} from "src/utils/SignatureBuilder.sol"; +import {RequestBuilder} from "src/utils/RequestBuilder.sol"; + +/** + * @title DeployLibraries Script + * @notice To test this script locally, run: + * in a first terminal: `anvil --fork-url https://rpc.ankr.com/polygon_mumbai` + * in a second terminal: `cast rpc anvil_impersonateAccount 0xbb8fca8f2381cfeede5d7541d7bf76343ef6c67b` + * and finally: `CHAIN_NAME=test forge script DeployLibraries --rpc-url localhost --sender 0xbb8fca8f2381cfeede5d7541d7bf76343ef6c67b --unlocked -vvvv` + * You should see that the libraries are being deployed and successfully set in the AddressesProvider contract. + * You can then run the `yarn save-deployments` command to save the deployment addresses in the `deployments` folder. You will see the libraries addresses in the `deployments/test/run-latest.json` file. + */ + +contract DeployLibraries is Script, BaseDeploymentConfig { + struct DeployedLibraries { + AuthRequestBuilder authRequestBuilder; + ClaimRequestBuilder claimRequestBuilder; + SignatureBuilder signatureBuilder; + RequestBuilder requestBuilder; + } + + function run() public { + runFor(vm.envString("CHAIN_NAME")); + } + + function runFor(string memory chainName) public returns (DeploymentConfig memory) { + console.log("Run for CHAIN_NAME:", chainName); + console.log("Deployer:", msg.sender); + + vm.startBroadcast(); + + _setConfig({chainName: chainName}); + + // deploy external libraries + DeployedLibraries memory deployedLibraries; + deployedLibraries.authRequestBuilder = _deployAuthRequestBuilder(); + deployedLibraries.claimRequestBuilder = _deployClaimRequestBuilder(); + deployedLibraries.signatureBuilder = _deploySignatureBuilder(); + deployedLibraries.requestBuilder = _deployRequestBuilder(); + + // update deployment config with deployed libraries addresses + // and save it in `deployments` folder + // only for a successful broadcast + config = DeploymentConfig({ + authRequestBuilder: address(deployedLibraries.authRequestBuilder), + claimRequestBuilder: address(deployedLibraries.claimRequestBuilder), + signatureBuilder: address(deployedLibraries.signatureBuilder), + requestBuilder: address(deployedLibraries.requestBuilder) + }); + vm.stopBroadcast(); + _saveDeploymentConfig(chainName); + + return config; + } + + function _deployAuthRequestBuilder() private returns (AuthRequestBuilder) { + address authRequestBuilderAddress = config.authRequestBuilder; + if (authRequestBuilderAddress != address(0)) { + console.log("Using existing authrequestBuilder:", authRequestBuilderAddress); + return AuthRequestBuilder(authRequestBuilderAddress); + } + AuthRequestBuilder authRequestBuilder = new AuthRequestBuilder(); + console.log("authRequestBuilder Deployed:", address(authRequestBuilder)); + return authRequestBuilder; + } + + function _deployClaimRequestBuilder() private returns (ClaimRequestBuilder) { + address claimRequestBuilderAddress = config.claimRequestBuilder; + if (claimRequestBuilderAddress != address(0)) { + console.log("Using existing claimRequestBuilder:", claimRequestBuilderAddress); + return ClaimRequestBuilder(claimRequestBuilderAddress); + } + ClaimRequestBuilder claimRequestBuilder = new ClaimRequestBuilder(); + console.log("claimRequestBuilder Deployed:", address(claimRequestBuilder)); + return claimRequestBuilder; + } + + function _deploySignatureBuilder() private returns (SignatureBuilder) { + address signatureBuilderAddress = config.signatureBuilder; + if (signatureBuilderAddress != address(0)) { + console.log("Using existing signatureBuilder:", signatureBuilderAddress); + return SignatureBuilder(signatureBuilderAddress); + } + SignatureBuilder signatureBuilder = new SignatureBuilder(); + console.log("signatureBuilder Deployed:", address(signatureBuilder)); + return signatureBuilder; + } + + function _deployRequestBuilder() private returns (RequestBuilder) { + address requestBuilderAddress = config.requestBuilder; + if (requestBuilderAddress != address(0)) { + console.log("Using existing requestBuilder:", requestBuilderAddress); + return RequestBuilder(requestBuilderAddress); + } + RequestBuilder requestBuilder = new RequestBuilder(); + console.log("requestBuilder Deployed:", address(requestBuilder)); + return requestBuilder; + } +} diff --git a/script/bash/save-deployments.sh b/script/bash/save-deployments.sh new file mode 100755 index 0000000..007c555 --- /dev/null +++ b/script/bash/save-deployments.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +source_folder="$PWD/deployments/tmp" +destination_root="$PWD/deployments" + +# Find all subfolders containing JSON files and process them +find "$source_folder" -type f -name "*.json" | while read -r json_file; do + subfolder=$(dirname "$json_file") + subfolder_name=$(basename "$subfolder") + destination_folder="$destination_root/$subfolder_name" + + # Find the latest JSON file in the subfolder + latest_file=$(ls -t "$subfolder"/*.json | head -n 1) + + if [ -n "$latest_file" ]; then + # Copy the latest JSON file to the destination folder to keep track of the latest deployment + cp "$latest_file" "$destination_root/$subfolder_name.json" + else + echo "No matching files found in $subfolder_name." + fi +done \ No newline at end of file diff --git a/script/utils/SetAddressesProvider.s.sol b/script/utils/SetAddressesProvider.s.sol new file mode 100644 index 0000000..1d2737b --- /dev/null +++ b/script/utils/SetAddressesProvider.s.sol @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "forge-std/Script.sol"; +import "forge-std/console.sol"; + +import {IAddressesProvider} from "src/interfaces/IAddressesProvider.sol"; +import {BaseDeploymentConfig, DeploymentConfig} from "script/BaseConfig.sol"; + +contract SetAddressesProvider is Script, BaseDeploymentConfig { + struct DeployedLibrary { + address addr; + string name; + } + + // useful variables to set libraries addresses in AddressesProvider in batch + address[] public contractAddresses; + string[] public contractNames; + + function run() external { + runFor(vm.envString("CHAIN_NAME")); + } + + function runFor(string memory _chainName) public { + console.log("Run for CHAIN_NAME:", _chainName); + console.log("Sender:", msg.sender); + + vm.startBroadcast(); + _setConfig({chainName: _chainName}); + + // associate libraries addresses to names + DeployedLibrary[] memory deployedLibrariesArray = new DeployedLibrary[](4); + deployedLibrariesArray[0] = DeployedLibrary({ + addr: address(config.authRequestBuilder), + name: "authRequestBuilder-v1.1" + }); + deployedLibrariesArray[1] = DeployedLibrary({ + addr: address(config.claimRequestBuilder), + name: "claimRequestBuilder-v1.1" + }); + deployedLibrariesArray[2] = DeployedLibrary({ + addr: address(config.signatureBuilder), + name: "signatureBuilder-v1.1" + }); + deployedLibrariesArray[3] = DeployedLibrary({ + addr: address(config.requestBuilder), + name: "requestBuilder-v1.1" + }); + + // update addresses provider with deployed libraries addresses + _setLibrariesAddresses(deployedLibrariesArray); + + vm.stopBroadcast(); + } + + function _setLibrariesAddresses(DeployedLibrary[] memory deployedLibrariesArray) private { + console.log("== Updating Addresses Provider =="); + IAddressesProvider sismoAddressProvider = IAddressesProvider(SISMO_ADDRESSES_PROVIDER_V2); + + for (uint256 i = 0; i < deployedLibrariesArray.length; i++) { + DeployedLibrary memory deployedLibrary = deployedLibrariesArray[i]; + address currentContractAddress = sismoAddressProvider.get(deployedLibrary.name); + + if (currentContractAddress != deployedLibrary.addr) { + console.log( + "current contract address for", + deployedLibrary.name, + "is different. Updating address to", + deployedLibrary.addr + ); + // save address to update in batch after + contractAddresses.push(deployedLibrary.addr); + contractNames.push(deployedLibrary.name); + } else { + console.log( + "current contract address for", + deployedLibrary.name, + "is already the expected one. skipping update" + ); + } + } + + if (contractAddresses.length > 0) { + console.log("Updating Addresses Provider in batch..."); + sismoAddressProvider.setBatch(contractAddresses, contractNames); + } + } +} diff --git a/src/SismoConnectLib.sol b/src/SismoConnectLib.sol index e8a4b43..f74ef6b 100644 --- a/src/SismoConnectLib.sol +++ b/src/SismoConnectLib.sol @@ -1,13 +1,14 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; -import {RequestBuilder, SismoConnectRequest, SismoConnectResponse, SismoConnectConfig} from "./utils/RequestBuilder.sol"; -import {AuthRequestBuilder, AuthRequest, Auth, VerifiedAuth, AuthType} from "./utils/AuthRequestBuilder.sol"; -import {ClaimRequestBuilder, ClaimRequest, Claim, VerifiedClaim, ClaimType} from "./utils/ClaimRequestBuilder.sol"; -import {SignatureBuilder, SignatureRequest, Signature} from "./utils/SignatureBuilder.sol"; -import {VaultConfig} from "./utils/Structs.sol"; -import {ISismoConnectVerifier, SismoConnectVerifiedResult} from "./interfaces/ISismoConnectVerifier.sol"; import {IAddressesProvider} from "./interfaces/IAddressesProvider.sol"; +import {ISismoConnectVerifier, SismoConnectVerifiedResult} from "./interfaces/ISismoConnectVerifier.sol"; +import {AuthRequestBuilder, AuthRequest, AuthType} from "./utils/AuthRequestBuilder.sol"; +import {ClaimRequestBuilder, ClaimRequest, ClaimType} from "./utils/ClaimRequestBuilder.sol"; +import {SignatureBuilder, SignatureRequest} from "./utils/SignatureBuilder.sol"; +import {RequestBuilder, AuthRequest, ClaimRequest, SignatureRequest, SismoConnectRequest} from "./utils/RequestBuilder.sol"; + +import {Auth, VerifiedAuth, Claim, VerifiedClaim, Signature, SismoConnectResponse, SismoConnectConfig, VaultConfig} from "./utils/Structs.sol"; import {SismoConnectHelper} from "./utils/SismoConnectHelper.sol"; contract SismoConnect { diff --git a/src/interfaces/IBaseVerifier.sol b/src/interfaces/IBaseVerifier.sol deleted file mode 100644 index 777d8fd..0000000 --- a/src/interfaces/IBaseVerifier.sol +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.17; - -import {SismoConnectProof, VerifiedAuth, VerifiedClaim} from "../utils/Structs.sol"; - -interface IBaseVerifier { - function verify( - bytes16 appId, - bytes16 namespace, - bool isImpersonationMode, - bytes memory signedMessage, - SismoConnectProof memory sismoConnectProof - ) external returns (VerifiedAuth memory, VerifiedClaim memory); -} diff --git a/src/utils/AuthBuilder.sol b/src/utils/AuthBuilder.sol index 02822f7..0cf52c1 100644 --- a/src/utils/AuthBuilder.sol +++ b/src/utils/AuthBuilder.sol @@ -11,40 +11,7 @@ library AuthBuilder { bool public constant DEFAULT_AUTH_IS_SELECTABLE_BY_USER = true; bytes public constant DEFAULT_AUTH_EXTRA_DATA = ""; - function build( - AuthType authType, - bool isAnon, - uint256 userId, - bool isSelectableByUser, - bytes memory extraData - ) external pure returns (Auth memory) { - return - Auth({ - authType: authType, - isAnon: isAnon, - userId: userId, - isSelectableByUser: isSelectableByUser, - extraData: extraData - }); - } - - function build( - AuthType authType, - bool isAnon, - uint256 userId, - bytes memory extraData - ) external pure returns (Auth memory) { - return - Auth({ - authType: authType, - isAnon: isAnon, - userId: userId, - isSelectableByUser: DEFAULT_AUTH_IS_SELECTABLE_BY_USER, - extraData: extraData - }); - } - - function build(AuthType authType) external pure returns (Auth memory) { + function build(AuthType authType) internal pure returns (Auth memory) { return Auth({ authType: authType, @@ -55,18 +22,7 @@ library AuthBuilder { }); } - function build(AuthType authType, bool isAnon) external pure returns (Auth memory) { - return - Auth({ - authType: authType, - isAnon: isAnon, - userId: DEFAULT_AUTH_USER_ID, - isSelectableByUser: DEFAULT_AUTH_IS_SELECTABLE_BY_USER, - extraData: DEFAULT_AUTH_EXTRA_DATA - }); - } - - function build(AuthType authType, uint256 userId) external pure returns (Auth memory) { + function build(AuthType authType, uint256 userId) internal pure returns (Auth memory) { return Auth({ authType: authType, @@ -77,27 +33,12 @@ library AuthBuilder { }); } - function build(AuthType authType, bytes memory extraData) external pure returns (Auth memory) { - return - Auth({ - authType: authType, - isAnon: DEFAULT_AUTH_IS_ANON, - userId: DEFAULT_AUTH_USER_ID, - isSelectableByUser: DEFAULT_AUTH_IS_SELECTABLE_BY_USER, - extraData: extraData - }); - } - - function build( - AuthType authType, - bool isAnon, - uint256 userId - ) external pure returns (Auth memory) { + function build(AuthType authType, bool isAnon) internal pure returns (Auth memory) { return Auth({ authType: authType, isAnon: isAnon, - userId: userId, + userId: DEFAULT_AUTH_USER_ID, isSelectableByUser: DEFAULT_AUTH_IS_SELECTABLE_BY_USER, extraData: DEFAULT_AUTH_EXTRA_DATA }); @@ -106,45 +47,14 @@ library AuthBuilder { function build( AuthType authType, bool isAnon, - bytes memory extraData - ) external pure returns (Auth memory) { + uint256 userId + ) internal pure returns (Auth memory) { return Auth({ authType: authType, isAnon: isAnon, - userId: DEFAULT_AUTH_USER_ID, - isSelectableByUser: DEFAULT_AUTH_IS_SELECTABLE_BY_USER, - extraData: extraData - }); - } - - function build( - AuthType authType, - uint256 userId, - bytes memory extraData - ) external pure returns (Auth memory) { - return - Auth({ - authType: authType, - isAnon: DEFAULT_AUTH_IS_ANON, userId: userId, isSelectableByUser: DEFAULT_AUTH_IS_SELECTABLE_BY_USER, - extraData: extraData - }); - } - - function build( - AuthType authType, - bool isAnon, - uint256 userId, - bool isSelectableByUser - ) external pure returns (Auth memory) { - return - Auth({ - authType: authType, - isAnon: isAnon, - userId: userId, - isSelectableByUser: isSelectableByUser, extraData: DEFAULT_AUTH_EXTRA_DATA }); } diff --git a/src/utils/AuthMatchingLib.sol b/src/utils/AuthMatchingLib.sol deleted file mode 100644 index a1f90a9..0000000 --- a/src/utils/AuthMatchingLib.sol +++ /dev/null @@ -1,100 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.17; - -import "./Structs.sol"; - -// The role of this library is to check for a given AuthRequest if there is a matching Auth in the response -// It returns a level of matching between the AuthRequest and the Auth in the response -// The level of matching is a number between 0 and 7 (000 to 111 in binary) -// The level of matching is calculated by adding the following values: -// 1 if the authType in the AuthRequest is the same as the authType in the Auth -// 2 if the isAnon in the AuthRequest is the same as the isAnon in the Auth -// 4 if the userId in the AuthRequest is the same as the userId in the Auth -// The level of matching is then used to determine if the AuthRequest is fulfilled or not -library AuthMatchingLib { - error AuthInRequestNotFoundInResponse( - uint8 requestAuthType, - bool requestIsAnon, - uint256 requestUserId, - bytes requestExtraData - ); - error AuthIsAnonAndUserIdNotFound(bool requestIsAnon, uint256 requestUserId); - error AuthTypeAndUserIdNotFound(uint8 requestAuthType, uint256 requestUserId); - error AuthUserIdNotFound(uint256 requestUserId); - error AuthTypeAndIsAnonNotFound(uint8 requestAuthType, bool requestIsAnon); - error AuthIsAnonNotFound(bool requestIsAnon); - error AuthTypeNotFound(uint8 requestAuthType); - - // Check if the AuthRequest is fulfilled by the Auth in the response - // and return the level of matching between the AuthRequest and the Auth in the response - function _matchLevel( - Auth memory auth, - AuthRequest memory authRequest - ) internal pure returns (uint8) { - uint8 matchingPropertiesLevel = 0; - - if (auth.authType == authRequest.authType) { - matchingPropertiesLevel += 1; // 001 - } - if (auth.isAnon == authRequest.isAnon) { - matchingPropertiesLevel += 2; // 010 - } - - if (authRequest.authType == AuthType.VAULT) { - // If authType is Vault the user can't choose a particular userId - // It will be always defined as userId = Hash(VaultSecret, AppId) - // There is then no specific constraint on the isSelectableByUser and userId properties) - matchingPropertiesLevel += 4; // 100 - } else if ((authRequest.isSelectableByUser == false) && (auth.userId == authRequest.userId)) { - // if the userId in the auth request can NOT be chosen by the user when generating the proof (isSelectableByUser == true) - // we check if the userId of the auth in the request matches the userId of the auth in the response - matchingPropertiesLevel += 4; // 100 - } else if (authRequest.isSelectableByUser == true) { - // if the userId in the auth request can be chosen by the user when generating the proof (isSelectableByUser == true) - // we dont check if the userId of the auth in the request matches the userId of the auth in the response - // the property is considered as matching - matchingPropertiesLevel += 4; // 100 - } - - return matchingPropertiesLevel; - } - - function handleAuthErrors(uint8 maxMatchingProperties, AuthRequest memory auth) public pure { - // if the maxMatchingProperties is equal to 7 (111 in bits), it means that the auth in the request matches with one of the auths in the response - // otherwise, we can look at the binary representation of the maxMatchingProperties to know which properties are not matching and throw an error (the 0 bits represent the properties that are not matching) - if (maxMatchingProperties == 0) { - // 000 - // no property of the auth in the request matches with any property of the auths in the response - revert AuthInRequestNotFoundInResponse( - uint8(auth.authType), - auth.isAnon, - auth.userId, - auth.extraData - ); - } else if (maxMatchingProperties == 1) { - // 001 - // only the authType property of the auth in the request matches with one of the auths in the response - revert AuthIsAnonAndUserIdNotFound(auth.isAnon, auth.userId); - } else if (maxMatchingProperties == 2) { - // 010 - // only the isAnon property of the auth in the request matches with one of the auths in the response - revert AuthTypeAndUserIdNotFound(uint8(auth.authType), auth.userId); - } else if (maxMatchingProperties == 3) { - // 011 - // only the authType and isAnon properties of the auth in the request match with one of the auths in the response - revert AuthUserIdNotFound(auth.userId); - } else if (maxMatchingProperties == 4) { - // 100 - // only the userId property of the auth in the request matches with one of the auths in the response - revert AuthTypeAndIsAnonNotFound(uint8(auth.authType), auth.isAnon); - } else if (maxMatchingProperties == 5) { - // 101 - // only the authType and userId properties of the auth in the request matches with one of the auths in the response - revert AuthIsAnonNotFound(auth.isAnon); - } else if (maxMatchingProperties == 6) { - // 110 - // only the isAnon and userId properties of the auth in the request matches with one of the auths in the response - revert AuthTypeNotFound(uint8(auth.authType)); - } - } -} diff --git a/src/utils/ClaimBuilder.sol b/src/utils/ClaimBuilder.sol index bab321f..0f23c0a 100644 --- a/src/utils/ClaimBuilder.sol +++ b/src/utils/ClaimBuilder.sol @@ -11,44 +11,7 @@ library ClaimBuilder { bool public constant DEFAULT_CLAIM_IS_SELECTABLE_BY_USER = true; bytes public constant DEFAULT_CLAIM_EXTRA_DATA = ""; - function build( - bytes16 groupId, - bytes16 groupTimestamp, - uint256 value, - ClaimType claimType, - bool isSelectableByUser, - bytes memory extraData - ) external pure returns (Claim memory) { - return - Claim({ - claimType: claimType, - groupId: groupId, - groupTimestamp: groupTimestamp, - value: value, - isSelectableByUser: isSelectableByUser, - extraData: extraData - }); - } - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - uint256 value, - ClaimType claimType, - bytes memory extraData - ) external pure returns (Claim memory) { - return - Claim({ - claimType: claimType, - groupId: groupId, - groupTimestamp: groupTimestamp, - value: value, - isSelectableByUser: DEFAULT_CLAIM_IS_SELECTABLE_BY_USER, - extraData: extraData - }); - } - - function build(bytes16 groupId) external pure returns (Claim memory) { + function build(bytes16 groupId) internal pure returns (Claim memory) { return Claim({ groupId: groupId, @@ -60,7 +23,7 @@ library ClaimBuilder { }); } - function build(bytes16 groupId, bytes16 groupTimestamp) external pure returns (Claim memory) { + function build(bytes16 groupId, bytes16 groupTimestamp) internal pure returns (Claim memory) { return Claim({ groupId: groupId, @@ -72,19 +35,7 @@ library ClaimBuilder { }); } - function build(bytes16 groupId, uint256 value) external pure returns (Claim memory) { - return - Claim({ - groupId: groupId, - groupTimestamp: DEFAULT_CLAIM_GROUP_TIMESTAMP, - value: value, - claimType: DEFAULT_CLAIM_TYPE, - isSelectableByUser: DEFAULT_CLAIM_IS_SELECTABLE_BY_USER, - extraData: DEFAULT_CLAIM_EXTRA_DATA - }); - } - - function build(bytes16 groupId, ClaimType claimType) external pure returns (Claim memory) { + function build(bytes16 groupId, ClaimType claimType) internal pure returns (Claim memory) { return Claim({ groupId: groupId, @@ -96,39 +47,11 @@ library ClaimBuilder { }); } - function build(bytes16 groupId, bytes memory extraData) external pure returns (Claim memory) { - return - Claim({ - groupId: groupId, - groupTimestamp: DEFAULT_CLAIM_GROUP_TIMESTAMP, - value: DEFAULT_CLAIM_VALUE, - claimType: DEFAULT_CLAIM_TYPE, - isSelectableByUser: DEFAULT_CLAIM_IS_SELECTABLE_BY_USER, - extraData: extraData - }); - } - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - uint256 value - ) external pure returns (Claim memory) { - return - Claim({ - groupId: groupId, - groupTimestamp: groupTimestamp, - value: value, - claimType: DEFAULT_CLAIM_TYPE, - isSelectableByUser: DEFAULT_CLAIM_IS_SELECTABLE_BY_USER, - extraData: DEFAULT_CLAIM_EXTRA_DATA - }); - } - function build( bytes16 groupId, bytes16 groupTimestamp, ClaimType claimType - ) external pure returns (Claim memory) { + ) internal pure returns (Claim memory) { return Claim({ groupId: groupId, @@ -139,136 +62,4 @@ library ClaimBuilder { extraData: DEFAULT_CLAIM_EXTRA_DATA }); } - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - bytes memory extraData - ) external pure returns (Claim memory) { - return - Claim({ - groupId: groupId, - groupTimestamp: groupTimestamp, - value: DEFAULT_CLAIM_VALUE, - claimType: DEFAULT_CLAIM_TYPE, - isSelectableByUser: DEFAULT_CLAIM_IS_SELECTABLE_BY_USER, - extraData: extraData - }); - } - - function build( - bytes16 groupId, - uint256 value, - ClaimType claimType - ) external pure returns (Claim memory) { - return - Claim({ - groupId: groupId, - groupTimestamp: DEFAULT_CLAIM_GROUP_TIMESTAMP, - value: value, - claimType: claimType, - isSelectableByUser: DEFAULT_CLAIM_IS_SELECTABLE_BY_USER, - extraData: DEFAULT_CLAIM_EXTRA_DATA - }); - } - - function build( - bytes16 groupId, - uint256 value, - bytes memory extraData - ) external pure returns (Claim memory) { - return - Claim({ - groupId: groupId, - groupTimestamp: DEFAULT_CLAIM_GROUP_TIMESTAMP, - value: value, - claimType: DEFAULT_CLAIM_TYPE, - isSelectableByUser: DEFAULT_CLAIM_IS_SELECTABLE_BY_USER, - extraData: extraData - }); - } - - function build( - bytes16 groupId, - ClaimType claimType, - bytes memory extraData - ) external pure returns (Claim memory) { - return - Claim({ - groupId: groupId, - groupTimestamp: DEFAULT_CLAIM_GROUP_TIMESTAMP, - value: DEFAULT_CLAIM_VALUE, - claimType: claimType, - isSelectableByUser: DEFAULT_CLAIM_IS_SELECTABLE_BY_USER, - extraData: extraData - }); - } - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - uint256 value, - ClaimType claimType - ) external pure returns (Claim memory) { - return - Claim({ - groupId: groupId, - groupTimestamp: groupTimestamp, - value: value, - claimType: claimType, - isSelectableByUser: DEFAULT_CLAIM_IS_SELECTABLE_BY_USER, - extraData: DEFAULT_CLAIM_EXTRA_DATA - }); - } - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - uint256 value, - bytes memory extraData - ) external pure returns (Claim memory) { - return - Claim({ - groupId: groupId, - groupTimestamp: groupTimestamp, - value: value, - claimType: DEFAULT_CLAIM_TYPE, - isSelectableByUser: DEFAULT_CLAIM_IS_SELECTABLE_BY_USER, - extraData: extraData - }); - } - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - ClaimType claimType, - bytes memory extraData - ) external pure returns (Claim memory) { - return - Claim({ - groupId: groupId, - groupTimestamp: groupTimestamp, - value: DEFAULT_CLAIM_VALUE, - claimType: claimType, - isSelectableByUser: DEFAULT_CLAIM_IS_SELECTABLE_BY_USER, - extraData: extraData - }); - } - - function build( - bytes16 groupId, - uint256 value, - ClaimType claimType, - bytes memory extraData - ) external pure returns (Claim memory) { - return - Claim({ - groupId: groupId, - groupTimestamp: DEFAULT_CLAIM_GROUP_TIMESTAMP, - value: value, - claimType: claimType, - isSelectableByUser: DEFAULT_CLAIM_IS_SELECTABLE_BY_USER, - extraData: extraData - }); - } } diff --git a/src/utils/ClaimMatchingLib.sol b/src/utils/ClaimMatchingLib.sol deleted file mode 100644 index 693f5d3..0000000 --- a/src/utils/ClaimMatchingLib.sol +++ /dev/null @@ -1,87 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.17; - -import "./Structs.sol"; - -library ClaimMatchingLib { - error ClaimInRequestNotFoundInResponse( - uint8 responseClaimType, - bytes16 responseClaimGroupId, - bytes16 responseClaimGroupTimestamp, - uint256 responseClaimValue, - bytes responseExtraData - ); - error ClaimGroupIdAndGroupTimestampNotFound( - bytes16 requestClaimGroupId, - bytes16 requestClaimGroupTimestamp - ); - error ClaimTypeAndGroupTimestampNotFound( - uint8 requestClaimType, - bytes16 requestClaimGroupTimestamp - ); - error ClaimGroupTimestampNotFound(bytes16 requestClaimGroupTimestamp); - error ClaimTypeAndGroupIdNotFound(uint8 requestClaimType, bytes16 requestClaimGroupId); - error ClaimGroupIdNotFound(bytes16 requestClaimGroupId); - error ClaimTypeNotFound(uint8 requestClaimType); - - // Check if the AuthRequest is fulfilled by the Auth in the response - // and return the level of matching between the AuthRequest and the Auth in the response - function _matchLevel( - Claim memory claim, - ClaimRequest memory claimRequest - ) internal pure returns (uint8) { - uint8 matchingPropertiesLevel = 0; - - if (claim.claimType == claimRequest.claimType) { - matchingPropertiesLevel += 1; // 001 - } - if (claim.groupId == claimRequest.groupId) { - matchingPropertiesLevel += 2; // 010 - } - if (claim.groupTimestamp == claimRequest.groupTimestamp) { - matchingPropertiesLevel += 4; // 100 - } - - return matchingPropertiesLevel; - } - - function handleClaimErrors(uint8 maxMatchingProperties, ClaimRequest memory claim) public pure { - // if the maxMatchingProperties is equal to 7 (111 in bits), it means that the claim in the request matches with one of the claims in the response - // otherwise, we can look at the binary representation of the maxMatchingProperties to know which properties are not matching and throw an error (the 0 bits represent the properties that are not matching) - if (maxMatchingProperties == 0) { - // 000 - // no property of the claim in the request matches with any property of the claims in the response - revert ClaimInRequestNotFoundInResponse( - uint8(claim.claimType), - claim.groupId, - claim.groupTimestamp, - claim.value, - claim.extraData - ); - } else if (maxMatchingProperties == 1) { - // 001 - // only the claimType property of the claim in the request matches with one of the claims in the response - revert ClaimGroupIdAndGroupTimestampNotFound(claim.groupId, claim.groupTimestamp); - } else if (maxMatchingProperties == 2) { - // 010 - // only the groupId property of the claim in the request matches with one of the claims in the response - revert ClaimTypeAndGroupTimestampNotFound(uint8(claim.claimType), claim.groupTimestamp); - } else if (maxMatchingProperties == 3) { - // 011 - // only the claimType and groupId properties of the claim in the request match with one of the claims in the response - revert ClaimGroupTimestampNotFound(claim.groupTimestamp); - } else if (maxMatchingProperties == 4) { - // 100 - // only the groupTimestamp property of the claim in the request matches with one of the claims in the response - revert ClaimTypeAndGroupIdNotFound(uint8(claim.claimType), claim.groupId); - } else if (maxMatchingProperties == 5) { - // 101 - // only the claimType and groupTimestamp properties of the claim in the request matches with one of the claims in the response - revert ClaimGroupIdNotFound(claim.groupId); - } else if (maxMatchingProperties == 6) { - // 110 - // only the groupId and groupTimestamp properties of the claim in the request matches with one of the claims in the response - revert ClaimTypeNotFound(uint8(claim.claimType)); - } - } -} diff --git a/src/utils/Fmt.sol b/src/utils/Fmt.sol index 05279c2..1743dc7 100644 --- a/src/utils/Fmt.sol +++ b/src/utils/Fmt.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; -import "./Structs.sol"; import "forge-std/console.sol"; +import "./Structs.sol"; library fmt { function printAuthRequest(AuthRequest memory auth, string memory indication) external view { diff --git a/src/utils/SismoConnectProofBuilder.sol b/src/utils/SismoConnectProofBuilder.sol index 70e88f0..55b69c0 100644 --- a/src/utils/SismoConnectProofBuilder.sol +++ b/src/utils/SismoConnectProofBuilder.sol @@ -10,33 +10,12 @@ library ProofBuilder { function build( Auth memory auth, - Claim memory claim, - bytes memory proofData - ) external pure returns (SismoConnectProof memory) { - Auth[] memory auths = new Auth[](1); - auths[0] = auth; - Claim[] memory claims = new Claim[](1); - claims[0] = claim; - return - SismoConnectProof({ - auths: auths, - claims: claims, - proofData: proofData, - provingScheme: DEFAULT_PROOF_PROVING_SCHEME, - extraData: DEFAULT_PROOF_EXTRA_DATA - }); - } - - function build( - Auth memory auth, - Claim memory claim, bytes memory proofData, bytes32 provingScheme - ) external pure returns (SismoConnectProof memory) { + ) internal pure returns (SismoConnectProof memory) { Auth[] memory auths = new Auth[](1); auths[0] = auth; - Claim[] memory claims = new Claim[](1); - claims[0] = claim; + Claim[] memory claims = new Claim[](0); return SismoConnectProof({ auths: auths, @@ -50,7 +29,7 @@ library ProofBuilder { function build( Auth memory auth, bytes memory proofData - ) external pure returns (SismoConnectProof memory) { + ) internal pure returns (SismoConnectProof memory) { Auth[] memory auths = new Auth[](1); auths[0] = auth; Claim[] memory claims = new Claim[](0); @@ -64,28 +43,10 @@ library ProofBuilder { }); } - function build( - Auth memory auth, - bytes memory proofData, - bytes32 provingScheme - ) external pure returns (SismoConnectProof memory) { - Auth[] memory auths = new Auth[](1); - auths[0] = auth; - Claim[] memory claims = new Claim[](0); - return - SismoConnectProof({ - auths: auths, - claims: claims, - proofData: proofData, - provingScheme: provingScheme, - extraData: DEFAULT_PROOF_EXTRA_DATA - }); - } - function build( Claim memory claim, bytes memory proofData - ) external pure returns (SismoConnectProof memory) { + ) internal pure returns (SismoConnectProof memory) { Auth[] memory auths = new Auth[](0); Claim[] memory claims = new Claim[](1); claims[0] = claim; @@ -103,7 +64,7 @@ library ProofBuilder { Claim memory claim, bytes memory proofData, bytes32 provingScheme - ) external pure returns (SismoConnectProof memory) { + ) internal pure returns (SismoConnectProof memory) { Auth[] memory auths = new Auth[](0); Claim[] memory claims = new Claim[](1); claims[0] = claim; @@ -116,35 +77,4 @@ library ProofBuilder { extraData: DEFAULT_PROOF_EXTRA_DATA }); } - - function build( - Auth[] memory auths, - Claim[] memory claims, - bytes memory proofData - ) external pure returns (SismoConnectProof memory) { - return - SismoConnectProof({ - auths: auths, - claims: claims, - proofData: proofData, - provingScheme: DEFAULT_PROOF_PROVING_SCHEME, - extraData: DEFAULT_PROOF_EXTRA_DATA - }); - } - - function build( - Auth[] memory auths, - Claim[] memory claims, - bytes memory proofData, - bytes32 provingScheme - ) external pure returns (SismoConnectProof memory) { - return - SismoConnectProof({ - auths: auths, - claims: claims, - proofData: proofData, - provingScheme: provingScheme, - extraData: DEFAULT_PROOF_EXTRA_DATA - }); - } } diff --git a/test/BaseTest.t.sol b/test/BaseTest.t.sol new file mode 100644 index 0000000..6432615 --- /dev/null +++ b/test/BaseTest.t.sol @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import {Test} from "forge-std/Test.sol"; +import {IAddressesProvider} from "src/interfaces/IAddressesProvider.sol"; +import {AddressesProviderMock} from "test/mocks/AddressesProviderMock.sol"; +import {SismoConnectVerifierMock} from "test/mocks/SismoConnectVerifierMock.sol"; +import {AuthRequestBuilder} from "src/utils/AuthRequestBuilder.sol"; +import {ClaimRequestBuilder} from "src/utils/ClaimRequestBuilder.sol"; +import {SignatureBuilder} from "src/utils/SignatureBuilder.sol"; +import {RequestBuilder} from "src/utils/RequestBuilder.sol"; + +contract BaseTest is Test { + address immutable user1 = vm.addr(1); + address immutable user2 = vm.addr(2); + address immutable owner = vm.addr(3); + address public immutable SISMO_ADDRESSES_PROVIDER_V2 = 0x3Cd5334eB64ebBd4003b72022CC25465f1BFcEe6; + + SismoConnectVerifierMock sismoConnectVerifier; + + // external libraries + AuthRequestBuilder authRequestBuilder; + ClaimRequestBuilder claimRequestBuilder; + SignatureBuilder signatureBuilder; + RequestBuilder requestBuilder; + + function setUp() public virtual { + AddressesProviderMock addressesProviderMock = new AddressesProviderMock(); + sismoConnectVerifier = new SismoConnectVerifierMock(); + + // external libraries + authRequestBuilder = new AuthRequestBuilder(); + claimRequestBuilder = new ClaimRequestBuilder(); + signatureBuilder = new SignatureBuilder(); + requestBuilder = new RequestBuilder(); + + vm.etch(SISMO_ADDRESSES_PROVIDER_V2, address(addressesProviderMock).code); + + IAddressesProvider(SISMO_ADDRESSES_PROVIDER_V2).set( + address(sismoConnectVerifier), + string("sismoConnectVerifier-v1.2") + ); + IAddressesProvider(SISMO_ADDRESSES_PROVIDER_V2).set( + address(authRequestBuilder), + string("authRequestBuilder-v1.1") + ); + IAddressesProvider(SISMO_ADDRESSES_PROVIDER_V2).set( + address(claimRequestBuilder), + string("claimRequestBuilder-v1.1") + ); + IAddressesProvider(SISMO_ADDRESSES_PROVIDER_V2).set( + address(signatureBuilder), + string("signatureBuilder-v1.1") + ); + IAddressesProvider(SISMO_ADDRESSES_PROVIDER_V2).set( + address(requestBuilder), + string("requestBuilder-v1.1") + ); + } +} diff --git a/test/CheatSheet.t.sol b/test/CheatSheet.t.sol deleted file mode 100644 index dcf5a8c..0000000 --- a/test/CheatSheet.t.sol +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: Unlicense -pragma solidity ^0.8.17; - -import "forge-std/console.sol"; -import "src/utils/Fmt.sol"; -import {SismoConnect, RequestBuilder, ClaimRequestBuilder} from "src/SismoConnectLib.sol"; -import {CheatSheet} from "test/misc/CheatSheet.sol"; -import "src/utils/Structs.sol"; -import {AuthBuilder} from "src/utils/AuthBuilder.sol"; -import {ClaimBuilder} from "src/utils/ClaimBuilder.sol"; -import {BaseTest} from "test/base/BaseTest.t.sol"; - -contract CheatSheetTest is BaseTest { - CheatSheet cheatsheet; - - function setUp() public { - cheatsheet = new CheatSheet(); - } - - function test_CheatSheet() public { - _registerTreeRoot(6019938179908949948260031779305182307740658158839075528652774771326767878672); - bytes - memory responseBytes = hex"000000000000000000000000000000000000000000000000000000000000002032403ced4b65f2079eda77c84e7d2be600000000000000000000000000000000b8e2054f8a912367e38a22ce773328ff000000000000000000000000000000007369736d6f2d636f6e6e6563742d76312e31000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d49206c6f7665205369736d6f2100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000ac00000000000000000000000000000000000000000000000000000000000000f80000000000000000000000000000000000000000000000000000000000000144000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000001de000000000000000000000000000000000000000000000000000000000000022c000000000000000000000000000000000000000000000000000000000000027a00000000000000000000000000000000000000000000000000000000000002c8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c02ee756e8d291546c67b5573b9b751b5bd5a0dbcede35464ef2a6e2c14f11b033151164d686f667393f18dcd27584954f2126998bcbed6ed9b9982cd99069bb830d2e1f84055faad2b66fd81c5db45b47356df5f8a3e3c3f852b63ffb83579b25221a09032e42863c6847ff2dd1ad2843628b7cae34ce0eee41c2c95829526ba611abc4b47a83f51174c44304a3ec7fc5e0a4d2661c6e0516f1f932c5258d788a14165f2fac0ff540383b5d74113f799dc98b5e6bc9cad1d8c1706b8606ff7d400877d9fc97b985ab302afe17621dd1ede1379dc2671aeb791d104097ce7a2b7c2d27c3487bda0b24a491c70c021aee29840c77400e3612e6959cd78c1d29e55000000000000000000000000000000000000000000000000000000000000000001304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000008ab1760889f26cbbf33a75fd2cf1696bfccdc9e600000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c024d4b21c846468fc5e45041225279dbaf181db1d30c0ca47ba531e2139d9eaf7280d33b782823298589f29aaba714eea5acb96ebe2826de93f633d7f3c0a008f2f32d3204f8911a2bcfa70a0ef4e197b1807f8cfbb23f8e5686d79ccce4a40a10d7cf559488b27861bd1cc1b63275ccdceb49daaf8639ee099df558ceec868ed0edc00ae97888c6e213a4922f25c33e2e9de1d9a84f65101e071ac07297799eb2ca5e5cc67ee3d6c3a747ee9f0da812d8cbcb477a162dcabc40860092b8e4985049dded4313ca1c7fd8c2bb2341dc239b4c0b7db930ecc7e2b849e5dcdfe9317247dc2c6229691441432bffb6228a40d4096290a347bed1a215bf4203b6932a80000000000000000000000008ab1760889f26cbbf33a75fd2cf1696bfccdc9e61304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a4c94a6091545e40fc9c3e0982aec8942e282f3800000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c005e9a85d4b9401511669228989a3ff0c30b5b9f459e900fc75d4ab9a70c49ef80e46b75f5cf3bccbf05d7af71f87fe8d132b7f85a1607b0bfd6e4feaa8213f9f1063f2f84a7ce96e52f5e43003dfab677a74c1ec96a1d626225a4033cde26ebc0e54e534d6de2002f1a08033821a7fd348fd0f9dae7e85e0796f76319ff8c8e5251c6201cecdbd21885dd4d341227cdbf8f7f5693146166d99192c0ada581d5924b9ebe2e3dd193f95bbfc462a64bddcce25b799936a919452a704138a60c35d1534cb185dc6762a446321ad3b0ac40720cde123c86d8ada6ed050b0c106adc81ee271099e4702a5925e134d668eea626c19b220a2c39dd16d0400168d99d791000000000000000000000000a4c94a6091545e40fc9c3e0982aec8942e282f381304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000100100000000000000000000000000003577409700000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c0137081498c847bdc10ace33d22949bfc73b674d4812b66a8f53e878ddffc190f0cda340c783fd25566dfd14394dcc8fc9e7af60237bbec04d70b097721f7e6e70e0998b7010de2546274bb5c03238e5ffd2340c319ba85327f11e8dd0279f1f217e1c040a49739304d4025d7c42d97f2b41102d4b504b49693666d6fffae1ea5279e58b6b2a415acd5db0706921a85985d348386637463751a7de73448ac35fd215517307d716502bc580dff5ba4c8f484eeb7a1f2f9cc69f49052a09f6887b70803efb5635d81e2f07eb7ae6024bcd4ffd2b927209865e183747523f7d274c51464ceea457eb61b7c2a132177ec531842ceb568a51fe6a4e145a0f9a564a0ee00000000000000000000000010010000000000000000000000000000357740971304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100300000000000000000000000000087560811000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c01cab87335090f31f2c858c45dbe40ac1e3fd5eda4b584bbc8b8784991a5c9f91041986364178d5d6a6a9cfbe96e6679111feff038be558c436df97c113d8f10e25b99ceb0082c9df5bb7e90739e1c1f4d4588bae1169c88c5422356294e86b7e0b43cb521b0b664462993aea9666d18a84e6684afeed6ba49b0b42402b67685e0b82bfa1c7724f214cd6fd624e7300ab4372f955ebfd9b489aa935ed5e074eb2239b65a6f9f51888891d69f57ce2d4a6fd1a1594d77090edf526d16242feb4a2157bec5129edd6e86f43d73f12b2561250a8835cfa5eb1533f1a15d5d1513ca11129beec3cd8288b1beb42352734cb93173f72679402a51db226dbe1a01ce49900000000000000000000000010030000000000000000000000000008756081101304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000fae674b6cba3ff2f8ce2114defb200b1000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c0068a54cba7e80eea17652e5399bac0f373a37289e19e4990f03b14f5304ba97b0e86c7b9ff626dad18a91068c36cfaca3b4bba8c23ccbd8aa89a50478632bb3808dac983625c650c8ee73594fd9b6cc609696db35f213f4efa3c7355436c61d9273d66565e35cd47df9763521fcb24813b0070b920aa7d13206d3f541540a4542ff6e85db5be75a22c067551f70000275568339f0e67155907ce6aaacdd9c35120e1c6f0752cb5565b7324847eadc5b568b60b356976f6194b59cddd32f72bcd0c60c6907df2d4e1dfc7fd7cafb77170d74deed3b60f4565d8814ad3345c489d2073030d081ad0615e2898c77db05842544e08d1909daffd4b1f51af41d0c1a600000000000000000000000000000000000000000000000000000000000000001304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d85210223889be50de6309c4a51edd039aa1fb882c9964a746581ff319bbe982debcf82efc4cc7c03398856dbf08377861fb15549f5a9137456a615d4da264e7d69cd4000000000000000000000000000000000000000000000000000000000000000108f0ec7865abde5ef350b4bd682b46dfa35deafb12d4cd29ac96341c4ffffffb000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000001cde61966decb8600dfd0749bd371f12000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c02c7c25b4657897bdb2bc62112bdac39f1fcb4fd090b44a73b9e17125754d0f9a26321b26cb19ac752eb7f7557ef0b868d9e1c0cb22a6f3354d8bf1eae8efb02f2ea24f5c4265ed8439dfa93a3742164e91bad77e6fee1b2f88ecd7c58fbe802027f44df7403fb133ce8cc8c5fd23b458c4bc53c455727e28d753bfea20f1445d2182c405df59bec7da832b42cfa3edbbd48bdf42dbfb073950d13ee7b0a55f1c1d4eb48a63d9d4f67c61a932a830101e76b501cd1145ffc755d8d5450b554bbd2fbd2b04120d8ef1e5bd290b00ff4a25a917bccfa03f13da4f70e7d30ac792932e716a0f4c76aa9a197419c2125257cfcfd36fd4e7c7de28c145ec429e3c5a1700000000000000000000000000000000000000000000000000000000000000001304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d852101e7a3215d4d02e734fa653c5ca96357521ac260e6ba94a1f05c413b0143e15bd2113caea8c11ac1bdcde3d297ebd9f24df376b1ae881a18e62e49c81b5db8267000000000000000000000000000000000000000000000000000000000000000f1cde61966decb8600dfd0749bd371f126c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002fae674b6cba3ff2f8ce2114defb200b1000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c0107ecc33ddbb094a870b4f300a5fff992ce214effaf8e441b1d3de2d2b9ae0a012842d6a54fd89bc48444701e99eb26114f4bf767490bb13d0446f214c55ce7603ecc0efc47b9d2fe6683d856ddc141d234da6e80845263c4bcc1e823443da430c50c00649710842967c9755f99bafc7219a19fad38cce29f1bcf1316c1469061c0b6468c29704188ddece490bd2723cc392b4ca7b1f6501c6469236cb535bf61df114f50ba48448088c440823c7cf811003b2c1707f124d8ab2b262c7400c982b14db09cfabca6f7fd817457ae68a882cbd72c01839cc326408e938e3deb0140323af36a396c8b906ecfda2d92e82383e4693cef14d94a2b2b77f4b61b3859000000000000000000000000000000000000000000000000000000000000000001304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d85210223889be50de6309c4a51edd039aa1fb882c9964a746581ff319bbe982debcf82efc4cc7c03398856dbf08377861fb15549f5a9137456a615d4da264e7d69cd4000000000000000000000000000000000000000000000000000000000000000a08f0ec7865abde5ef350b4bd682b46dfa35deafb12d4cd29ac96341c4ffffffb000000000000000000000000000000000000000000000000000000000000000110915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000fae674b6cba3ff2f8ce2114defb200b1000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c02699914aaa5bb1b11b49261603cd894aee490c39b8ca5ea5c1625f05c60c3e2e2e4bef13a3cc0df3f3dc1bf5d601b699f4c2d94b1ca2b62622f91874f3a600832f057ff2148e63bc50db8c9f049e33929d195610f8b8a826d75941d2ef7c46ef1a108ab29c16b6498990fa5767f4e3594648c444a71dd16924366d03e1f31a9813f954aaf7916663320a9baa8de31cb14f3e4ce8fb7fc88d7ae2356f8d91404f1c21b77322002fdfcea7df847cf31f4dc7c4485d535392f4583aa67eb63bfcd214ca04a230eca28910992acf54cb9682f8b7a4240b193ccdd7ac081181e9ee3f1fbfc685affa356338b832c8c49dc2d33cafb950af2377e2ea73e53cc101020400000000000000000000000000000000000000000000000000000000000000001304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d85210223889be50de6309c4a51edd039aa1fb882c9964a746581ff319bbe982debcf82efc4cc7c03398856dbf08377861fb15549f5a9137456a615d4da264e7d69cd4000000000000000000000000000000000000000000000000000000000000000108f0ec7865abde5ef350b4bd682b46dfa35deafb12d4cd29ac96341c4ffffffb000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000001cde61966decb8600dfd0749bd371f12000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001900000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c01376d89c862093d8af4faece2845d584a7f5adbce6415f91185445053066db272b55dfb2d1f4d34239c3dde1e396bec29e5a1398dc9cc589a1c4a01dc6b5a190038bbde989bdaa41ae06c00e806e8b05698557a1ee2b7bcba05173cb72e5a22b2b4b2be01439457de5fbee80ca58c442b0a98239810cd611ab1db95e2806d81a194d33e4750fa3d1dc0417bc8c620935c888ad3a5af607fc4ccf21af83b539980c8017f171ea205708d7d16dd2d6968682c92a4f6aa60c4a2b397849c064f1d71f2c626c4108ab3566301144a75f0964791e8770d014da3c6b986cadc296763d19d3935c9924bd88b558920f376f4cd31833d1f69dcaa8b747bd8fab8a83305300000000000000000000000000000000000000000000000000000000000000001304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d852101e7a3215d4d02e734fa653c5ca96357521ac260e6ba94a1f05c413b0143e15bd2113caea8c11ac1bdcde3d297ebd9f24df376b1ae881a18e62e49c81b5db826700000000000000000000000000000000000000000000000000000000000000191cde61966decb8600dfd0749bd371f126c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - - cheatsheet.verifySismoConnectResponse(responseBytes); - } -} diff --git a/test/base/BaseTest.t.sol b/test/base/BaseTest.t.sol deleted file mode 100644 index cbe85c2..0000000 --- a/test/base/BaseTest.t.sol +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.17; - -import "forge-std/Test.sol"; -import "forge-std/console.sol"; -import {IAddressesProvider} from "src/SismoConnectLib.sol"; - -interface IAvailableRootsRegistry { - event RegisteredRoot(uint256 root); - - function registerRoot(uint256 root) external; - - function owner() external view returns (address); -} - -contract BaseTest is Test { - IAddressesProvider sismoAddressesProvider = - IAddressesProvider(0x3Cd5334eB64ebBd4003b72022CC25465f1BFcEe6); - IAvailableRootsRegistry availableRootsRegistry; - - function _registerTreeRoot(uint256 root) internal { - // get availableRootsRegistry from the sismoAddressesProvider - availableRootsRegistry = IAvailableRootsRegistry( - sismoAddressesProvider.get("sismoConnectAvailableRootsRegistry") - ); - address rootsRegistryOwner = availableRootsRegistry.owner(); - // prank to the rootsRegistryOwner - vm.startPrank(rootsRegistryOwner); - availableRootsRegistry.registerRoot(root); - vm.stopPrank(); - } -} diff --git a/test/fork/Fork.t.sol b/test/fork/Fork.t.sol new file mode 100644 index 0000000..cf35343 --- /dev/null +++ b/test/fork/Fork.t.sol @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "forge-std/Test.sol"; +import "forge-std/console.sol"; +import {IAddressesProvider, AuthRequestBuilder, ClaimRequestBuilder, SignatureBuilder, RequestBuilder} from "src/SismoConnectLib.sol"; + +interface IAvailableRootsRegistry { + event RegisteredRoot(uint256 root); + + function registerRoot(uint256 root) external; + + function owner() external view returns (address); +} + +contract ForkTest is Test { + IAddressesProvider sismoAddressesProvider; + IAvailableRootsRegistry availableRootsRegistry; + + AuthRequestBuilder authRequestBuilder; + ClaimRequestBuilder claimRequestBuilder; + SignatureBuilder signatureBuilder; + RequestBuilder requestBuilder; + + function setUp() public virtual { + vm.createSelectFork({urlOrAlias: "mainnet"}); + + sismoAddressesProvider = IAddressesProvider(0x3Cd5334eB64ebBd4003b72022CC25465f1BFcEe6); + availableRootsRegistry = IAvailableRootsRegistry( + sismoAddressesProvider.get(string("sismoConnectAvailableRootsRegistry")) + ); + + authRequestBuilder = AuthRequestBuilder( + sismoAddressesProvider.get(string("authRequestBuilder-v1.1")) + ); + claimRequestBuilder = ClaimRequestBuilder( + sismoAddressesProvider.get(string("claimRequestBuilder-v1.1")) + ); + signatureBuilder = SignatureBuilder( + sismoAddressesProvider.get(string("signatureBuilder-v1.1")) + ); + requestBuilder = RequestBuilder(sismoAddressesProvider.get(string("requestBuilder-v1.1"))); + } + + function _registerTreeRoot(uint256 root) internal { + address rootsRegistryOwner = availableRootsRegistry.owner(); + // prank to the rootsRegistryOwner + vm.startPrank(rootsRegistryOwner); + availableRootsRegistry.registerRoot(root); + vm.stopPrank(); + } +} diff --git a/test/fork/SismoConnectE2E.t.sol b/test/fork/SismoConnectE2E.t.sol new file mode 100644 index 0000000..b7d141a --- /dev/null +++ b/test/fork/SismoConnectE2E.t.sol @@ -0,0 +1,357 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "forge-std/console.sol"; +import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import {ForkTest} from "./Fork.t.sol"; +import {CheatSheet} from "test/misc/CheatSheet.sol"; +import {Proofs} from "./proofs/Proofs.sol"; +import {ResponseBuilder, ResponseWithoutProofs} from "test/utils/ResponseBuilderLib.sol"; +import {SismoConnectHarness} from "test/harness/SismoConnectHarness.sol"; +import {UpgradeableExample} from "test/misc/UpgradeableExample.sol"; +import {ZKDropERC721} from "test/misc/ZKDropERC721.sol"; +import {AuthBuilder} from "src/utils/AuthBuilder.sol"; +import {ClaimBuilder} from "src/utils/ClaimBuilder.sol"; +import "src/utils/Structs.sol"; +import "src/utils/Fmt.sol"; + +// E2E tests for SismoConnect Solidity Library +// These tests are fork tests made with proofs generated from the Vault App + +contract SismoConnectE2E_ForkTest is ForkTest { + using ResponseBuilder for SismoConnectResponse; + using ResponseBuilder for ResponseWithoutProofs; + + SismoConnectHarness sismoConnect; + address user = 0x7def1d6D28D6bDa49E69fa89aD75d160BEcBa3AE; + + // default values for tests + bytes16 public DEFAULT_APP_ID = 0x11b1de449c6c4adb0b5775b3868b28b3; + bytes16 public DEFAULT_NAMESPACE = bytes16(keccak256("main")); + bytes32 public DEFAULT_VERSION = bytes32("sismo-connect-v1.1"); + bytes public DEFAULT_SIGNED_MESSAGE = abi.encode(user); + + bool public DEFAULT_IS_IMPERSONATION_MODE = false; + + ResponseWithoutProofs public DEFAULT_RESPONSE = + ResponseBuilder + .emptyResponseWithoutProofs() + .withAppId(DEFAULT_APP_ID) + .withVersion(DEFAULT_VERSION) + .withNamespace(DEFAULT_NAMESPACE) + .withSignedMessage(DEFAULT_SIGNED_MESSAGE); + + ClaimRequest claimRequest; + AuthRequest authRequest; + SignatureRequest signature; + Proofs proofs; + + bytes16 immutable APP_ID_ZK_DROP = 0x11b1de449c6c4adb0b5775b3868b28b3; + bytes16 immutable SISMO_CONTRIBUTORS_GROUP_ID = 0xe9ed316946d3d98dfcd829a53ec9822e; + ZKDropERC721 zkdrop; + + CheatSheet cheatsheet; + + function setUp() public virtual override { + ForkTest.setUp(); + + sismoConnect = new SismoConnectHarness(DEFAULT_APP_ID, DEFAULT_IS_IMPERSONATION_MODE); + claimRequest = sismoConnect.exposed_buildClaim({groupId: 0xe9ed316946d3d98dfcd829a53ec9822e}); + authRequest = sismoConnect.exposed_buildAuth({authType: AuthType.VAULT}); + signature = sismoConnect.exposed_buildSignature({message: abi.encode(user)}); + proofs = new Proofs(); + + zkdrop = new ZKDropERC721({ + appId: APP_ID_ZK_DROP, + groupId: SISMO_CONTRIBUTORS_GROUP_ID, + name: "ZKDrop test", + symbol: "test", + baseTokenURI: "https://test.com" + }); + console.log("ZkDrop contract deployed at", address(zkdrop)); + + cheatsheet = new CheatSheet(); + + _registerTreeRoot(proofs.getRoot()); + } + + function testFork_SismoConnectLibWithOnlyClaimAndMessage() public view { + (, bytes memory responseEncoded) = proofs.getResponseWithOneClaimAndSignature(); + + sismoConnect.exposed_verify({ + responseBytes: responseEncoded, + request: requestBuilder.build({ + claim: sismoConnect.exposed_buildClaim({groupId: 0xe9ed316946d3d98dfcd829a53ec9822e}), + signature: sismoConnect.exposed_buildSignature({message: abi.encode(user)}) + }) + }); + } + + function testFork_SismoConnectLibWithTwoClaimsAndMessage() public view { + (, bytes memory responseEncoded) = proofs.getResponseWithTwoClaimsAndSignature(); + + ClaimRequest[] memory claims = new ClaimRequest[](2); + claims[0] = sismoConnect.exposed_buildClaim({groupId: 0xe9ed316946d3d98dfcd829a53ec9822e}); + claims[1] = sismoConnect.exposed_buildClaim({groupId: 0x02d241fdb9d4330c564ffc0a36af05f6}); + + sismoConnect.exposed_verify({ + responseBytes: responseEncoded, + request: requestBuilder.build({ + claims: claims, + signature: sismoConnect.exposed_buildSignature({message: abi.encode(user)}) + }) + }); + } + + function testFork_SismoConnectLibWithOnlyOneAuth() public { + (, bytes memory responseEncoded) = proofs.getResponseWithOnlyOneAuthAndMessage(); + + SismoConnectRequest memory request = requestBuilder.build({ + auth: sismoConnect.exposed_buildAuth({authType: AuthType.VAULT}), + signature: signature + }); + + SismoConnectVerifiedResult memory verifiedResult = sismoConnect.exposed_verify( + responseEncoded, + request + ); + assertTrue(verifiedResult.auths[0].userId != 0); + } + + function testFork_SismoConnectLibWithClaimAndAuth() public { + (, bytes memory responseEncoded) = proofs.getResponseWithOneClaimOneAuthAndOneMessage(); + SismoConnectRequest memory request = requestBuilder.build({ + auth: sismoConnect.exposed_buildAuth({authType: AuthType.VAULT}), + claim: sismoConnect.exposed_buildClaim({groupId: 0xe9ed316946d3d98dfcd829a53ec9822e}), + signature: signature + }); + + SismoConnectVerifiedResult memory verifiedResult = sismoConnect.exposed_verify( + responseEncoded, + request + ); + assertTrue(verifiedResult.auths[0].userId != 0); + } + + function testFork_ClaimAndAuthWithSignedMessageZKDROP() public { + // address that reverts if not modulo SNARK_FIELD after hashing the signedMessage for the circuit + // should keep this address for testing purposes + user = 0x7def1d6D28D6bDa49E69fa89aD75d160BEcBa3AE; + + // proof of membership for user in group 0xe9ed316946d3d98dfcd829a53ec9822e + // vault ownership + // signedMessage: 0x7def1d6D28D6bDa49E69fa89aD75d160BEcBa3AE + bytes + memory responseEncoded = hex"000000000000000000000000000000000000000000000000000000000000002011b1de449c6c4adb0b5775b3868b28b300000000000000000000000000000000b8e2054f8a912367e38a22ce773328ff000000000000000000000000000000007369736d6f2d636f6e6e6563742d76312e31000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000200000000000000000000000007def1d6d28d6bda49e69fa89ad75d160becba3ae00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c00e13d5898f45a0578526ca3d9048c9a0ed6a6dc6af46118f330a10c2bd905a180a5606df9b8c074aa82aa92fba759f79bfe2ea93b120f88477fc2506071e07932953767a6bba7cde1264cd886e85f97233cf12dec2cdf5ee8f3d295a1c603ee200a14357ed867808c4c9cfdd3eadbaaccab985c3c98563eb9bd97f0ae4a86dfb1854e21c9405301c914a1bcd93e827f34bcedb21419c5edcf2c022a719da63262a905da8df1c751d7aa8761ca691f950011a9016f152e06d67a076f72547002b1af4e79cb9e150f94bfb43b295ee3eba90f4f21c096cbda50215e37d86b095920d953743b8c045b0d4342370648b1f9444ce5c706602f20d2df4a2139997ee4b000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000e9ed316946d3d98dfcd829a53ec9822e000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c02f1f6f738b95cb3ad82c8d6f9d3f76542a489959b5c54da7d9d7b48413136b580dcd5851ffe286e00cbcdb644972e2f98b96772258f243160c501fa350a98282301793ae676f391ef110b70c0fd3286c5f2679582cbb3371792174af6f1c78490851df3f5b6054ab215fd07ad52bcaac91e7a342611126ec56ceed3ce47a756e066fea74f29aba48ed861174b8adb71406661e423e19a9c49df73c8b2b868d3d2c9fe708d9654b09e0ae44948b81d3970118e6bc771ca258f79a5047bfac8e8c2bd36792147ed1c1e4d5bea0ccc70abc636b98e49aa89f3b857673b3cac2cad809c1face7ad71275738dd61ca3683d1edb5d6acea0b177ddcf7771ff8758f057000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d8521004f81599b826fa9b715033e76e5b2fdda881352a9b61360022e30ee33ddccad90744e9b92802056c722ac4b31612e1b1de544d5b99481386b162a0b59862e0850000000000000000000000000000000000000000000000000000000000000001285bf79dc20d58e71b9712cb38c420b9cb91d3438c8e3dbaf07829b03ffffffc0000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a5000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + zkdrop.claimWithSismoConnect(responseEncoded, user); + } + + function testFork_TwoClaimsOneVaultAuthWithSignature() public view { + ClaimRequest[] memory claims = new ClaimRequest[](2); + claims[0] = claimRequestBuilder.build({groupId: 0xe9ed316946d3d98dfcd829a53ec9822e}); + claims[1] = claimRequestBuilder.build({groupId: 0x02d241fdb9d4330c564ffc0a36af05f6}); + + AuthRequest[] memory auths = new AuthRequest[](1); + auths[0] = authRequestBuilder.build({authType: AuthType.VAULT}); + + SismoConnectRequest memory request = requestBuilder.build({ + claims: claims, + auths: auths, + signature: signature + }); + + (, bytes memory responseEncoded) = proofs.getResponseWithTwoClaimsOneAuthAndOneSignature(); + + SismoConnectVerifiedResult memory verifiedResult = sismoConnect.exposed_verify({ + responseBytes: responseEncoded, + request: request + }); + console.log("Claims in Verified result: %s", verifiedResult.claims.length); + } + + function testFork_ThreeClaimsOneVaultAuthWithSignatureOneClaimOptional() public view { + ClaimRequest[] memory claims = new ClaimRequest[](3); + claims[0] = claimRequestBuilder.build({groupId: 0xe9ed316946d3d98dfcd829a53ec9822e}); + claims[1] = claimRequestBuilder.build({groupId: 0x02d241fdb9d4330c564ffc0a36af05f6}); + claims[2] = claimRequestBuilder.build({ + groupId: 0x42c768bb8ae79e4c5c05d3b51a4ec74a, + isOptional: true, + isSelectableByUser: false + }); + + AuthRequest[] memory auths = new AuthRequest[](1); + auths[0] = authRequestBuilder.build({authType: AuthType.VAULT}); + + SismoConnectRequest memory request = requestBuilder.build({ + claims: claims, + auths: auths, + signature: signature + }); + + (, bytes memory responseEncoded) = proofs.getResponseWithTwoClaimsOneAuthAndOneSignature(); + + SismoConnectVerifiedResult memory verifiedResult = sismoConnect.exposed_verify({ + responseBytes: responseEncoded, + request: request + }); + console.log("Claims in Verified result: %s", verifiedResult.claims.length); + } + + function testFork_ThreeClaimsOneVaultAuthOneTwitterAuthWithSignatureOneClaimOptional() + public + view + { + ClaimRequest[] memory claims = new ClaimRequest[](3); + claims[0] = claimRequestBuilder.build({groupId: 0xe9ed316946d3d98dfcd829a53ec9822e}); + claims[1] = claimRequestBuilder.build({groupId: 0x02d241fdb9d4330c564ffc0a36af05f6}); + claims[2] = claimRequestBuilder.build({ + groupId: 0x42c768bb8ae79e4c5c05d3b51a4ec74a, + isOptional: true, + isSelectableByUser: false + }); + + AuthRequest[] memory auths = new AuthRequest[](2); + auths[0] = authRequestBuilder.build({authType: AuthType.VAULT}); + auths[1] = authRequestBuilder.build({ + authType: AuthType.TWITTER, + isOptional: true, + isSelectableByUser: true + }); + + SismoConnectRequest memory request = requestBuilder.build({ + claims: claims, + auths: auths, + signature: signature + }); + + (, bytes memory responseEncoded) = proofs.getResponseWithTwoClaimsOneAuthAndOneSignature(); + + SismoConnectVerifiedResult memory verifiedResult = sismoConnect.exposed_verify({ + responseBytes: responseEncoded, + request: request + }); + console.log("Claims in Verified result: %s", verifiedResult.claims.length); + } + + function testFork_OneClaimOneOptionalTwitterAuthOneGithubAuthWithSignature() public view { + ClaimRequest[] memory claims = new ClaimRequest[](1); + claims[0] = claimRequestBuilder.build({groupId: 0xe9ed316946d3d98dfcd829a53ec9822e}); + + AuthRequest[] memory auths = new AuthRequest[](2); + auths[0] = authRequestBuilder.build({authType: AuthType.GITHUB}); + auths[1] = authRequestBuilder.build({ + authType: AuthType.TWITTER, + isOptional: true, + isSelectableByUser: true + }); + + SismoConnectRequest memory request = requestBuilder.build({ + claims: claims, + auths: auths, + signature: signature + }); + + bytes + memory responseEncoded = hex"000000000000000000000000000000000000000000000000000000000000002011b1de449c6c4adb0b5775b3868b28b300000000000000000000000000000000b8e2054f8a912367e38a22ce773328ff000000000000000000000000000000007369736d6f2d636f6e6e6563742d76312e31000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000200000000000000000000000007def1d6d28d6bda49e69fa89ad75d160becba3ae00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000009e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000100100000000000000000000000000009999037000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c01f5237cda37ca2237bfa10de427ae030eeec24a6ce9d8d1131b15f7fcb5f168f2cd27a37a8cecf4a922e209910d04ab67165610d401aeb8d3f9c8b4a6f81239425860952ce7cdf52b06c6f7861e10ab049b8df45c18b1fec6230c1bb9d5744fe1cc5acd00634a05a6dbf82f95b338f2d71fb3c88ec5219b2b8c98bea55a4dd3014d0a71a383a1e1d31902460cf0fa23c528be517436887dd4b82af41d6ab09c2062c4454dca040336cda21c314f5bc213f0b917908a89c5b0c1b2db31b8953ba1e1b07dbd0f19bec715b1aa331f632c258d9e084e309972550004c05f6340d732ca967c1ff768dd26409f9f987b9522fad5c4112f203a9b93119fadc85e30c9a000000000000000000000000100100000000000000000000000000009999037009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000100200000000000000000000000000288480976500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c0254797b44b8f3a253c02e3b84c8694458a8d498c2592e7b36c965519fc92503400c58413e606342362077d258766e55fc09135bdcb933e11db23bdcdce4ad23c2828525ef73b62575d2f2e6a471349e28e3ca63bc6b542bd6a0c8a3995750deb2da5fc828781d6aa5c5993bc43cb1e58cf6ddb8353503efc0d8f927956c9ec871dc864a6441d35fd9b774ac4a5380933666f6ad7c9e1ef1f1b24b87037fa2f5513ac71eaa4f51ddcf248dafff8e6c8205cabafcfacab21b7adb98167e9c5bb5f2aea54095c0246922547be93dce8b8e3fd87d4c5399d67377e63d9b90a30195025918b506c8d12293e48f224acddf120e8f890fe851bb9ba178b642beb4ded23000000000000000000000000100200000000000000000000000000288480976509f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000e9ed316946d3d98dfcd829a53ec9822e000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c025f517407b6ea0ed90092fefb10a570a25e5c769acb42b98671e5ecc381a01bc26f2a04c85eec86c263e919be89ed6bae72fff9267e25674b0b1242f68c9722601dc85685a7d3423f9b1a3b63ef08a76379118fb1eb29821acd8165ae8e1d12f0528e916f26707be18a37f1c8f0a2792a5891d340438d6221cb137614c8b5b7520c0d1e29393509cbd8822cd8f5278e8a4203ca6baf007f5328b5abe9e175d802d3ecc77bb73e2f85b32033405a3dbe0920ac3a318bd329fc1b410e22f98f518269b9554c33dbc905c5f210d9555ca2b166733c814e904bd21ea298e2894ae6b0251474f760ccc6c335321cc4fb58f6d858ac6d6de7c2670a93148f9d3a1b060000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d8521004f81599b826fa9b715033e76e5b2fdda881352a9b61360022e30ee33ddccad90744e9b92802056c722ac4b31612e1b1de544d5b99481386b162a0b59862e0850000000000000000000000000000000000000000000000000000000000000001285bf79dc20d58e71b9712cb38c420b9cb91d3438c8e3dbaf07829b03ffffffc0000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a5000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + + SismoConnectVerifiedResult memory verifiedResult = sismoConnect.exposed_verify({ + responseBytes: responseEncoded, + request: request + }); + console.log("Claims in Verified result: %s", verifiedResult.claims.length); + } + + function testFork_GitHubAuth() public view { + (, bytes memory encodedResponse) = proofs.getResponseWithGitHubAuth(); + + SismoConnectRequest memory request = requestBuilder.build({ + auth: sismoConnect.exposed_buildAuth({authType: AuthType.GITHUB}), + signature: signature + }); + + sismoConnect.exposed_verify({responseBytes: encodedResponse, request: request}); + } + + function testFork_GitHubAuthWithoutSignature() public view { + (, bytes memory encodedResponse) = proofs.getResponseWithGitHubAuthWithoutSignature(); + + SismoConnectRequest memory request = requestBuilder.build({ + auth: sismoConnect.exposed_buildAuth({authType: AuthType.GITHUB}) + }); + + sismoConnect.exposed_verify({responseBytes: encodedResponse, request: request}); + } + + function testFork_withProxy() public { + SignatureRequest memory signatureRequest = sismoConnect.exposed_buildSignature({ + message: abi.encode(user) + }); + + UpgradeableExample sismoConnectImplem = new UpgradeableExample( + DEFAULT_APP_ID, + DEFAULT_IS_IMPERSONATION_MODE, + 0xe9ed316946d3d98dfcd829a53ec9822e + ); + + TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy( + address(sismoConnectImplem), + address(1), + abi.encodeWithSelector( + sismoConnectImplem.initialize.selector, + bytes16(0xe9ed316946d3d98dfcd829a53ec9822e) + ) + ); + + UpgradeableExample upgradeable = UpgradeableExample(address(proxy)); + + (, bytes memory responseEncoded) = proofs.getResponseWithOneClaimAndSignature(); + + upgradeable.exposed_verify({responseBytes: responseEncoded, signature: signatureRequest}); + + // add an additional groupId in the contract + upgradeable.addGroupId({groupId: 0xff7653240feecd7448150005a95ac86b}); + + // verify again + // it should throw since the response is the same but another claim request is required + vm.expectRevert( + abi.encodeWithSignature( + "ClaimGroupIdNotFound(bytes16)", + bytes16(0xff7653240feecd7448150005a95ac86b) + ) + ); + upgradeable.exposed_verify({responseBytes: responseEncoded, signature: signatureRequest}); + } + + function testFork_RevertWithInvalidSismoIdentifier() public { + (SismoConnectResponse memory response, ) = proofs.getResponseWithGitHubAuthWithoutSignature(); + + // specify in the response that the proof comes from a telegram ownership + // but the proof is actually a github ownership + response.proofs[0].auths[0].authType = AuthType.TELEGRAM; + + // request a telegram proof of ownership + SismoConnectRequest memory request = requestBuilder.build({ + auth: sismoConnect.exposed_buildAuth({authType: AuthType.TELEGRAM}) + }); + + vm.expectRevert( + abi.encodeWithSignature( + "InvalidSismoIdentifier(bytes32,uint8)", + 0x0000000000000000000000001001000000000000000000000000000099990370, + 4 + ) + ); + sismoConnect.exposed_verify({responseBytes: abi.encode(response), request: request}); + } + + function testFork_CheatSheet() public view { + bytes memory responseBytes = proofs.getCheatSheetResponse(); + cheatsheet.verifySismoConnectResponse(responseBytes); + } + + // helpers + + function emptyResponse() private pure returns (SismoConnectResponse memory) { + return ResponseBuilder.empty(); + } +} diff --git a/test/fork/proofs/Proofs.sol b/test/fork/proofs/Proofs.sol new file mode 100644 index 0000000..b88334a --- /dev/null +++ b/test/fork/proofs/Proofs.sol @@ -0,0 +1,270 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "forge-std/console.sol"; +import {ResponseBuilder} from "test/utils/ResponseBuilderLib.sol"; +import "src/utils/Structs.sol"; +import {AuthBuilder} from "src/utils/AuthBuilder.sol"; +import {ClaimBuilder} from "src/utils/ClaimBuilder.sol"; +import {ProofBuilder} from "src/utils/SismoConnectProofBuilder.sol"; + +contract Proofs { + using ResponseBuilder for SismoConnectResponse; + + // default value for Claim + bytes16 public constant DEFAULT_CLAIM_GROUP_TIMESTAMP = bytes16("latest"); + uint256 public constant DEFAULT_CLAIM_VALUE = 1; + bytes16 public constant DEFAULT_CLAIM_GROUP_ID = ""; + ClaimType public constant DEFAULT_CLAIM_TYPE = ClaimType.GTE; + bytes public constant DEFAULT_CLAIM_EXTRA_DATA = ""; + + // default values for Auth + bool public constant DEFAULT_AUTH_ANON_MODE = false; + uint256 public constant DEFAULT_AUTH_USER_ID = 0; + bytes public constant DEFAULT_AUTH_EXTRA_DATA = ""; + + // default values for MessageSignature + bytes public constant DEFAULT_MESSAGE_SIGNATURE_REQUEST = "MESSAGE_SELECTED_BY_USER"; + + // default value for appId + bytes16 public constant DEFAULT_APP_ID = 0x11b1de449c6c4adb0b5775b3868b28b3; + // default value for namespace + bytes16 public constant DEFAULT_NAMESPACE = bytes16(keccak256("main")); + + // default value for version + bytes32 public constant DEFAULT_VERSION = bytes32("sismo-connect-v1.1"); + + // default proving scheme + bytes32 public constant DEFAULT_PROVING_SCHEME = bytes32("hydra-s3.1"); + + function getEdDSAPubKey() public pure returns (uint256[2] memory) { + return [ + 0x07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb9, + 0x20706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa + ]; + } + + function getImpersonationEdDSAPubKey() public pure returns (uint256[2] memory) { + return [ + 0x1801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b, + 0x057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b + ]; + } + + function getRoot() public pure returns (uint256) { + return 0x0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d85210; + } + + // simple sismoConnect with 1 claim + function getResponseWithOneClaimAndSignature() + external + pure + returns (SismoConnectResponse memory response, bytes memory responseAsBytes) + { + return ( + ResponseBuilder + .empty() + .withAppId(DEFAULT_APP_ID) + .withNamespace(DEFAULT_NAMESPACE) + .withVersion(DEFAULT_VERSION) + .withClaim({ + claim: ClaimBuilder.build({groupId: 0xe9ed316946d3d98dfcd829a53ec9822e}), + proofData: hex"2f9bbf1553b98848be543f1a3e0ac887c82d8927fc89e59e4bc0f46500b2f53803054cf63a56f54ee3116729939d5c285e4d6e0f2881f30b0d2c1ee2811ada090b5870dde9d003024c21122e122eac3d53aa9fc116159bf3385fce8fe194485f062384d38ebaac2bc59c1e74a86ab2b516b97a66df4160d6429bea6513d1942c291277ee22a603133f26d18b754867d40c059405a380252d30e8e1b6784c15a80770eee902fba2468672835e68512d6e2be18308e65b2ed62ddf8462877d70b002d8b41e2ebffee6ea7a520b4245211834c44c9ae158f18bfd52f922c8c7b70e2489f6b7d34333f5b5cf3482df7106cf69e8847284ef2fe00e227f2c52ab0d5b000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d8521004f81599b826fa9b715033e76e5b2fdda881352a9b61360022e30ee33ddccad90744e9b92802056c722ac4b31612e1b1de544d5b99481386b162a0b59862e0850000000000000000000000000000000000000000000000000000000000000001285bf79dc20d58e71b9712cb38c420b9cb91d3438c8e3dbaf07829b03ffffffc0000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000", + provingScheme: DEFAULT_PROVING_SCHEME + }) + .withSignedMessage({signedMessage: abi.encode(0x7def1d6D28D6bDa49E69fa89aD75d160BEcBa3AE)}), + // response as bytes + hex"000000000000000000000000000000000000000000000000000000000000002011b1de449c6c4adb0b5775b3868b28b300000000000000000000000000000000b8e2054f8a912367e38a22ce773328ff000000000000000000000000000000007369736d6f2d636f6e6e6563742d76312e31000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000200000000000000000000000007def1d6d28d6bda49e69fa89ad75d160becba3ae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000e9ed316946d3d98dfcd829a53ec9822e000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c02f9bbf1553b98848be543f1a3e0ac887c82d8927fc89e59e4bc0f46500b2f53803054cf63a56f54ee3116729939d5c285e4d6e0f2881f30b0d2c1ee2811ada090b5870dde9d003024c21122e122eac3d53aa9fc116159bf3385fce8fe194485f062384d38ebaac2bc59c1e74a86ab2b516b97a66df4160d6429bea6513d1942c291277ee22a603133f26d18b754867d40c059405a380252d30e8e1b6784c15a80770eee902fba2468672835e68512d6e2be18308e65b2ed62ddf8462877d70b002d8b41e2ebffee6ea7a520b4245211834c44c9ae158f18bfd52f922c8c7b70e2489f6b7d34333f5b5cf3482df7106cf69e8847284ef2fe00e227f2c52ab0d5b000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d8521004f81599b826fa9b715033e76e5b2fdda881352a9b61360022e30ee33ddccad90744e9b92802056c722ac4b31612e1b1de544d5b99481386b162a0b59862e0850000000000000000000000000000000000000000000000000000000000000001285bf79dc20d58e71b9712cb38c420b9cb91d3438c8e3dbaf07829b03ffffffc0000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a5000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ); + } + + // simple sismoConnect with 2 claims + function getResponseWithTwoClaimsAndSignature() + external + pure + returns (SismoConnectResponse memory response, bytes memory responseAsBytes) + { + Claim memory claim = ClaimBuilder.build({groupId: 0xe9ed316946d3d98dfcd829a53ec9822e}); + + Claim memory claimTwo = ClaimBuilder.build({groupId: 0x02d241fdb9d4330c564ffc0a36af05f6}); + + SismoConnectProof[] memory proofs = new SismoConnectProof[](2); + proofs[0] = ProofBuilder.build({ + claim: claim, + proofData: hex"112a90db82673ac2dc9d3b0c94fe4bdec60c54fc1f2fb9db24fd778939b0bc571e844e09218e08edf85ded69c70cf173b3973d1dc1861084214ed990f4a8940112e22fb69156b526f5d9205bdfb86fac13465ca6417e8d8358ec16ac9da5f3bc29bb9877f10cd882a788e79d10d60cb1c26a95f6fcfaac914b86f4e929bb29a6019aaf53837786c4cc6d4d94cb551fde1bfda52bd4baf84f5b7b683d6beb55d12f8826b3051c6766f1112dc12ee1121423f694d2549d87b2db3909e2db042f642a4e82e7ea049f01792bb8dd9db687c19aa2e63b47fb32d5bd61a808433cbd3028639724873b9591f0e850c0edfcfb854509f41f8b8e1f6247bf3338b795069a000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d8521004f81599b826fa9b715033e76e5b2fdda881352a9b61360022e30ee33ddccad90744e9b92802056c722ac4b31612e1b1de544d5b99481386b162a0b59862e0850000000000000000000000000000000000000000000000000000000000000001285bf79dc20d58e71b9712cb38c420b9cb91d3438c8e3dbaf07829b03ffffffc0000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000" + }); + proofs[1] = ProofBuilder.build({ + claim: claimTwo, + proofData: hex"1abb9a37eb98d68e994f4bcfd45b784ca2d6b4aa6d2aa77f5245681cafc79b82165e8c16c944d1a943a58fbf32a7be7c641a30d94c53e4d18695740c8a4b15cd06f95c66190ba95f2f4366f8c1b7582f8f9cfc4690674086cca42b1c55cb65b60c34dccd92e5fa17c49de842eb8e3bd70c09a1fba7e3e44e2543d280353b6dd919d06da5a98df5667bf2a41cc00329afc1aa0b2c1f9907539b2a784bb79f68bc0f5d9af52436adf7a02d1645eaa3f46e42e8c6944dba7c0dc94c2e4f3be3a86d164267c480df8bd1aca9195c89f2c6d06c13629aa41c3726f06d833a078781721317c863b582112f085883b36cd4f8e48288f0d2c02739a0a45ff6311a693e9e000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d852100f1d1d7e673892c9109c8b536253aa86d1d9dbd317ee37e71f22391e3a9fa5b3138cc656a4ed3352a074f68b57d684b33506d71ef40054fa928402c4897d14b8000000000000000000000000000000000000000000000000000000000000000102d241fdb9d4330c564ffc0a36af05f66c6174657374000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000" + }); + + return ( + SismoConnectResponse({ + appId: 0x11b1de449c6c4adb0b5775b3868b28b3, + namespace: bytes16(keccak256("main")), + version: bytes32("sismo-connect-v1.1"), + signedMessage: abi.encode(0x7def1d6D28D6bDa49E69fa89aD75d160BEcBa3AE), + proofs: proofs + }), + // response as bytes + hex"000000000000000000000000000000000000000000000000000000000000002011b1de449c6c4adb0b5775b3868b28b300000000000000000000000000000000b8e2054f8a912367e38a22ce773328ff000000000000000000000000000000007369736d6f2d636f6e6e6563742d76312e31000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000200000000000000000000000007def1d6d28d6bda49e69fa89ad75d160becba3ae00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000e9ed316946d3d98dfcd829a53ec9822e000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c0112a90db82673ac2dc9d3b0c94fe4bdec60c54fc1f2fb9db24fd778939b0bc571e844e09218e08edf85ded69c70cf173b3973d1dc1861084214ed990f4a8940112e22fb69156b526f5d9205bdfb86fac13465ca6417e8d8358ec16ac9da5f3bc29bb9877f10cd882a788e79d10d60cb1c26a95f6fcfaac914b86f4e929bb29a6019aaf53837786c4cc6d4d94cb551fde1bfda52bd4baf84f5b7b683d6beb55d12f8826b3051c6766f1112dc12ee1121423f694d2549d87b2db3909e2db042f642a4e82e7ea049f01792bb8dd9db687c19aa2e63b47fb32d5bd61a808433cbd3028639724873b9591f0e850c0edfcfb854509f41f8b8e1f6247bf3338b795069a000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d8521004f81599b826fa9b715033e76e5b2fdda881352a9b61360022e30ee33ddccad90744e9b92802056c722ac4b31612e1b1de544d5b99481386b162a0b59862e0850000000000000000000000000000000000000000000000000000000000000001285bf79dc20d58e71b9712cb38c420b9cb91d3438c8e3dbaf07829b03ffffffc0000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000002d241fdb9d4330c564ffc0a36af05f6000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c01abb9a37eb98d68e994f4bcfd45b784ca2d6b4aa6d2aa77f5245681cafc79b82165e8c16c944d1a943a58fbf32a7be7c641a30d94c53e4d18695740c8a4b15cd06f95c66190ba95f2f4366f8c1b7582f8f9cfc4690674086cca42b1c55cb65b60c34dccd92e5fa17c49de842eb8e3bd70c09a1fba7e3e44e2543d280353b6dd919d06da5a98df5667bf2a41cc00329afc1aa0b2c1f9907539b2a784bb79f68bc0f5d9af52436adf7a02d1645eaa3f46e42e8c6944dba7c0dc94c2e4f3be3a86d164267c480df8bd1aca9195c89f2c6d06c13629aa41c3726f06d833a078781721317c863b582112f085883b36cd4f8e48288f0d2c02739a0a45ff6311a693e9e000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d852100f1d1d7e673892c9109c8b536253aa86d1d9dbd317ee37e71f22391e3a9fa5b3138cc656a4ed3352a074f68b57d684b33506d71ef40054fa928402c4897d14b8000000000000000000000000000000000000000000000000000000000000000102d241fdb9d4330c564ffc0a36af05f66c6174657374000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a5000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ); + } + + // simple sismoConnect with only auth + function getResponseWithOnlyOneAuthAndMessage() + external + pure + returns (SismoConnectResponse memory response, bytes memory responseAsBytes) + { + Auth memory auth = AuthBuilder.build({authType: AuthType.VAULT}); + + SismoConnectProof[] memory proofs = new SismoConnectProof[](1); + proofs[0] = ProofBuilder.build({ + auth: auth, + proofData: hex"138e0d99b4b1fff0128090b63d69da3ccb11b3241ede465119fe13e614e3995f21125ff7d8ff5acdd47a6955c78ecaa079fd4089399f4a92a427e15c3281d8660754ae52a95639d42f53c8b81ed49303a85734b3b9e95e338601ed84c2e8c9920828518d257cb789012f6b2f2c211b02e1062e6623b5aa50dd136eac4fc937ab2dcec087dbeeb3bfe12e255cb5751f6c2f4015a9017cd2f6fbf4a46dcba74eb6290e64a13eaae874d6f6cce1368495dadf20dd5adfb2c801d5cabafa2d078ede270724551d579b5c3d73744a96a8e8a723339d504ac50c71f0a005dca32868d20cdbe42ab4a27fa33ff7388dc1322ce5a2eb2cccf11aaa67a6a755f4ed3d2f1f000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d2ab71fb864979b71106135acfa84afc1d756cda74f8f258896f896b4864f025630423b4c502f1cd4179a425723bf1e15c843733af2ecdee9aef6a0451ef2db7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018202c14c40a8bc84b8fc8748836190f53fc45c66ad969c7bfa2a91afdd1ad8d01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + }); + + return ( + SismoConnectResponse({ + appId: 0x11b1de449c6c4adb0b5775b3868b28b3, + namespace: bytes16(keccak256("main")), + version: bytes32("sismo-connect-v1.1"), + signedMessage: abi.encode(0x7def1d6D28D6bDa49E69fa89aD75d160BEcBa3AE), + proofs: proofs + }), + // response as bytes + hex"000000000000000000000000000000000000000000000000000000000000002011b1de449c6c4adb0b5775b3868b28b300000000000000000000000000000000b8e2054f8a912367e38a22ce773328ff000000000000000000000000000000007369736d6f2d636f6e6e6563742d76312e31000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000200000000000000000000000007def1d6d28d6bda49e69fa89ad75d160becba3ae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000118202c14c40a8bc84b8fc8748836190f53fc45c66ad969c7bfa2a91afdd1ad8d00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c0138e0d99b4b1fff0128090b63d69da3ccb11b3241ede465119fe13e614e3995f21125ff7d8ff5acdd47a6955c78ecaa079fd4089399f4a92a427e15c3281d8660754ae52a95639d42f53c8b81ed49303a85734b3b9e95e338601ed84c2e8c9920828518d257cb789012f6b2f2c211b02e1062e6623b5aa50dd136eac4fc937ab2dcec087dbeeb3bfe12e255cb5751f6c2f4015a9017cd2f6fbf4a46dcba74eb6290e64a13eaae874d6f6cce1368495dadf20dd5adfb2c801d5cabafa2d078ede270724551d579b5c3d73744a96a8e8a723339d504ac50c71f0a005dca32868d20cdbe42ab4a27fa33ff7388dc1322ce5a2eb2cccf11aaa67a6a755f4ed3d2f1f000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d2ab71fb864979b71106135acfa84afc1d756cda74f8f258896f896b4864f025630423b4c502f1cd4179a425723bf1e15c843733af2ecdee9aef6a0451ef2db7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018202c14c40a8bc84b8fc8748836190f53fc45c66ad969c7bfa2a91afdd1ad8d01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ); + } + + // simple sismoConnect with one claim and one auth + function getResponseWithOneClaimOneAuthAndOneMessage() + external + pure + returns (SismoConnectResponse memory response, bytes memory responseAsBytes) + { + Claim memory claim = ClaimBuilder.build({groupId: 0xe9ed316946d3d98dfcd829a53ec9822e}); + + Auth memory auth = AuthBuilder.build({authType: AuthType.VAULT}); + + SismoConnectProof[] memory proofs = new SismoConnectProof[](2); + proofs[0] = ProofBuilder.build({ + claim: claim, + proofData: hex"0ca19971a2d025de05de77c2f1aeda6cc57424c7ac7b3237c90cdcd84412077a1886754c486cae08ea652c173ae1870debef85a80d95d6725e0b37256d695584107aa68653fb67722e07237654af11107d299618a7f312421c62522c76ba51d308540f29626f1443da6c11e54622b23222339ea6da09f8ac77ec315693f24b132925ca9016386c891aa3bac9797a9b43a3313bfd98629d6fb95d2417ae5534e0001017552d3d3e8911f5e5aa4384d8a6e1dfb385e585667626d0aeb9b0c8c95326d41320eb53032f108cf48fcbf17ecf166979272210647d09153113c56871fc165bc6274afbc88352572cfb118bda16a7ba1b99f24c37d1bd31c10f6b4d7607000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d8521004f81599b826fa9b715033e76e5b2fdda881352a9b61360022e30ee33ddccad90744e9b92802056c722ac4b31612e1b1de544d5b99481386b162a0b59862e0850000000000000000000000000000000000000000000000000000000000000001285bf79dc20d58e71b9712cb38c420b9cb91d3438c8e3dbaf07829b03ffffffc0000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000" + }); + proofs[1] = ProofBuilder.build({ + auth: auth, + proofData: hex"2dc5aba5f01c9d989e252e7c14662c0140e0e03cf7e646528c252d423cc72f1f03189aff86d2a4c1a5e14b886f75f51b4210087de5cab5fd39b5567f27eff9902adcb81f9e9f6739d563c61ea80f1602455def27a07a90bbaf1df87b1c01b89621c37053f086bf8b57446a88e15b5501f00a756fcfa57cbc4f3776a930de2b9102137447707533080a013ebde8fb887f8576cdcb9d65c4ed06422e3721c30eb11ebc69e9c11e192ca5c0b392492ad413dd7095705b9e66758dd39aed176511fa23ec1761e651c6d9cd300c48ba1daa3abc5a5c0df7ebbe2338d0bcf53fb2600015d397326c95eadd529aaafd249d9d8288f2aa83635311dda3dc2a1b81cd4c1c000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + }); + + return ( + SismoConnectResponse({ + appId: 0x11b1de449c6c4adb0b5775b3868b28b3, + namespace: bytes16(keccak256("main")), + version: bytes32("sismo-connect-v1.1"), + signedMessage: abi.encode(0x7def1d6D28D6bDa49E69fa89aD75d160BEcBa3AE), + proofs: proofs + }), + // response as bytes + hex"000000000000000000000000000000000000000000000000000000000000002011b1de449c6c4adb0b5775b3868b28b300000000000000000000000000000000b8e2054f8a912367e38a22ce773328ff000000000000000000000000000000007369736d6f2d636f6e6e6563742d76312e31000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000200000000000000000000000007def1d6d28d6bda49e69fa89ad75d160becba3ae00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c02dc5aba5f01c9d989e252e7c14662c0140e0e03cf7e646528c252d423cc72f1f03189aff86d2a4c1a5e14b886f75f51b4210087de5cab5fd39b5567f27eff9902adcb81f9e9f6739d563c61ea80f1602455def27a07a90bbaf1df87b1c01b89621c37053f086bf8b57446a88e15b5501f00a756fcfa57cbc4f3776a930de2b9102137447707533080a013ebde8fb887f8576cdcb9d65c4ed06422e3721c30eb11ebc69e9c11e192ca5c0b392492ad413dd7095705b9e66758dd39aed176511fa23ec1761e651c6d9cd300c48ba1daa3abc5a5c0df7ebbe2338d0bcf53fb2600015d397326c95eadd529aaafd249d9d8288f2aa83635311dda3dc2a1b81cd4c1c000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000e9ed316946d3d98dfcd829a53ec9822e000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c00ca19971a2d025de05de77c2f1aeda6cc57424c7ac7b3237c90cdcd84412077a1886754c486cae08ea652c173ae1870debef85a80d95d6725e0b37256d695584107aa68653fb67722e07237654af11107d299618a7f312421c62522c76ba51d308540f29626f1443da6c11e54622b23222339ea6da09f8ac77ec315693f24b132925ca9016386c891aa3bac9797a9b43a3313bfd98629d6fb95d2417ae5534e0001017552d3d3e8911f5e5aa4384d8a6e1dfb385e585667626d0aeb9b0c8c95326d41320eb53032f108cf48fcbf17ecf166979272210647d09153113c56871fc165bc6274afbc88352572cfb118bda16a7ba1b99f24c37d1bd31c10f6b4d7607000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d8521004f81599b826fa9b715033e76e5b2fdda881352a9b61360022e30ee33ddccad90744e9b92802056c722ac4b31612e1b1de544d5b99481386b162a0b59862e0850000000000000000000000000000000000000000000000000000000000000001285bf79dc20d58e71b9712cb38c420b9cb91d3438c8e3dbaf07829b03ffffffc0000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a5000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ); + } + + function getResponseWithTwoClaimsOneAuthAndOneSignature() + external + pure + returns (SismoConnectResponse memory response, bytes memory responseAsBytes) + { + Claim memory claim = ClaimBuilder.build({groupId: 0xe9ed316946d3d98dfcd829a53ec9822e}); + + Claim memory claimTwo = ClaimBuilder.build({groupId: 0x02d241fdb9d4330c564ffc0a36af05f6}); + + Auth memory auth = AuthBuilder.build({authType: AuthType.VAULT}); + + SismoConnectProof[] memory proofs = new SismoConnectProof[](3); + proofs[0] = ProofBuilder.build({ + claim: claim, + proofData: hex"2d53f40dfd231e94db1a1d5759818fb65788cc5a586dd52a87086c6ef52c2ea5067f9e6672e0fad253a4fe3884a9474a86f76c452ffb70ce828f49ff271c157a212abb5dd8ad3ebe98c1df40799e224a0b6a91af68f97531f8987abd58abc3a10f93cb8848bbe50947bbc22b5c97b388ba7998cd532c20da56567f476b1e76a31105d06e1f880f4048a98a4df35b275375f27e6044dbb2cf04ccacdbe07b823e28afe9c052d68931c22f0e0fa54431072857eab1835faa2d675021facea397ca28d2278d4aa71184d6240498c2b30cad7270f561f8322338e7b93259560e7b6a1560ee42f01bc475cc1f4791f9cabd2c9061e1f4545030271fe81b0c076cb4e4000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d8521004f81599b826fa9b715033e76e5b2fdda881352a9b61360022e30ee33ddccad90744e9b92802056c722ac4b31612e1b1de544d5b99481386b162a0b59862e0850000000000000000000000000000000000000000000000000000000000000001285bf79dc20d58e71b9712cb38c420b9cb91d3438c8e3dbaf07829b03ffffffc0000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000" + }); + + proofs[1] = ProofBuilder.build({ + claim: claimTwo, + proofData: hex"05b949d85f762a54b7400547132026c5d0995d671297872ebfb3dbac1917659f2755fb3f4599b1be254b810f9c973d8d539e56fb599f9d024508b5940a4334ab2368727d07b8fbaa568f5fa27a4cda0c0160243a010f1efcc0db7a6973b247620569ef4735403a355f762108a4d140aa0dc4b2333b8542438953e6f72dc57cce10c14af2d6f21dbcfe917df6e872277a928e5bc2760f3fc4e6a59466089cb23b2b1ecda73e41abed5fe373923efc6a5724a8a865f829d600afc22ad5a846b02a203c58db94f189f5e9d0805f37c30de93e0af2dc930fc138d20cc4b0655df11f0ef8a2c8bbec2d701c5ebb5caf18a04847748c43ef52efd9422effa8b23651fd000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d852100f1d1d7e673892c9109c8b536253aa86d1d9dbd317ee37e71f22391e3a9fa5b3138cc656a4ed3352a074f68b57d684b33506d71ef40054fa928402c4897d14b8000000000000000000000000000000000000000000000000000000000000000102d241fdb9d4330c564ffc0a36af05f66c6174657374000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000" + }); + + proofs[2] = ProofBuilder.build({ + auth: auth, + proofData: hex"2225b3a9e7f6ddd7774daf4578d38ba58a6d21db07b86ea3852d3e89157cba4200e73eae485f989e2a1a06c0c1b2567c38dd018a25bca5dbc8fdbab9e4bdf7990e94589641fead66343771f10429363a94cae1f25110153e6ed60be3e4aaec302c969077aa9383e862faa80d7399079c627a948c924fcfcae04f8191bb5f164d0253c2b4562cbed45c8d7a0bff785b7157101e957d912882f20a9e91b4a514b80269193c78b666a71cf497bf03d82a1a5938e01ad372cdea3deefb00450a5b1416fe1a4cef14962a2d79f59caedee4ad4a9420ae09b4b0971e59582fb254ddcc2c4a231ac34c6fb2caaeb8a558c1e30c26411503878185bd82728c6193e4ff4f000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + }); + + return ( + SismoConnectResponse({ + appId: 0x11b1de449c6c4adb0b5775b3868b28b3, + namespace: bytes16(keccak256("main")), + version: bytes32("sismo-connect-v1.1"), + signedMessage: abi.encode(0x7def1d6D28D6bDa49E69fa89aD75d160BEcBa3AE), + proofs: proofs + }), + // response as bytes + hex"000000000000000000000000000000000000000000000000000000000000002011b1de449c6c4adb0b5775b3868b28b300000000000000000000000000000000b8e2054f8a912367e38a22ce773328ff000000000000000000000000000000007369736d6f2d636f6e6e6563742d76312e31000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000200000000000000000000000007def1d6d28d6bda49e69fa89ad75d160becba3ae0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000005400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000ee000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c02225b3a9e7f6ddd7774daf4578d38ba58a6d21db07b86ea3852d3e89157cba4200e73eae485f989e2a1a06c0c1b2567c38dd018a25bca5dbc8fdbab9e4bdf7990e94589641fead66343771f10429363a94cae1f25110153e6ed60be3e4aaec302c969077aa9383e862faa80d7399079c627a948c924fcfcae04f8191bb5f164d0253c2b4562cbed45c8d7a0bff785b7157101e957d912882f20a9e91b4a514b80269193c78b666a71cf497bf03d82a1a5938e01ad372cdea3deefb00450a5b1416fe1a4cef14962a2d79f59caedee4ad4a9420ae09b4b0971e59582fb254ddcc2c4a231ac34c6fb2caaeb8a558c1e30c26411503878185bd82728c6193e4ff4f000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000100200000000000000000000000000288480976500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c00d3916fb92997fc6d11ceac7618482759bbdee5134e9d90baf116ba3519c9ac003ddc52962996f3fba4559612dab2325a5b0955dcea7b47acca0cf09ec11077715d0c7554341e472f609caae810b38873fe00309bb2d45ec9a832d3495e4036a2522e15d49a09c52652fef43746de58ec7b1fd7b184c865c83e1388e094271b409ba20579e2d04accd56eb8e8a491ab9b4d34f99bfc72cd440617da672eed9051ee6ceeeeb8a777900d022714aff12d1226c32ce7878959335314ce025fcc1cd2e67c2299cf9706fe81e750b7169ac0997b670a655c3141cc3848a6c36262aa1268cc791f070169f6130083246044546114360f7717fc47a4038c470c2b0eb71000000000000000000000000100200000000000000000000000000288480976509f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000e9ed316946d3d98dfcd829a53ec9822e000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c02d53f40dfd231e94db1a1d5759818fb65788cc5a586dd52a87086c6ef52c2ea5067f9e6672e0fad253a4fe3884a9474a86f76c452ffb70ce828f49ff271c157a212abb5dd8ad3ebe98c1df40799e224a0b6a91af68f97531f8987abd58abc3a10f93cb8848bbe50947bbc22b5c97b388ba7998cd532c20da56567f476b1e76a31105d06e1f880f4048a98a4df35b275375f27e6044dbb2cf04ccacdbe07b823e28afe9c052d68931c22f0e0fa54431072857eab1835faa2d675021facea397ca28d2278d4aa71184d6240498c2b30cad7270f561f8322338e7b93259560e7b6a1560ee42f01bc475cc1f4791f9cabd2c9061e1f4545030271fe81b0c076cb4e4000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d8521004f81599b826fa9b715033e76e5b2fdda881352a9b61360022e30ee33ddccad90744e9b92802056c722ac4b31612e1b1de544d5b99481386b162a0b59862e0850000000000000000000000000000000000000000000000000000000000000001285bf79dc20d58e71b9712cb38c420b9cb91d3438c8e3dbaf07829b03ffffffc0000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000002d241fdb9d4330c564ffc0a36af05f6000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c005b949d85f762a54b7400547132026c5d0995d671297872ebfb3dbac1917659f2755fb3f4599b1be254b810f9c973d8d539e56fb599f9d024508b5940a4334ab2368727d07b8fbaa568f5fa27a4cda0c0160243a010f1efcc0db7a6973b247620569ef4735403a355f762108a4d140aa0dc4b2333b8542438953e6f72dc57cce10c14af2d6f21dbcfe917df6e872277a928e5bc2760f3fc4e6a59466089cb23b2b1ecda73e41abed5fe373923efc6a5724a8a865f829d600afc22ad5a846b02a203c58db94f189f5e9d0805f37c30de93e0af2dc930fc138d20cc4b0655df11f0ef8a2c8bbec2d701c5ebb5caf18a04847748c43ef52efd9422effa8b23651fd000000000000000000000000000000000000000000000000000000000000000009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d852100f1d1d7e673892c9109c8b536253aa86d1d9dbd317ee37e71f22391e3a9fa5b3138cc656a4ed3352a074f68b57d684b33506d71ef40054fa928402c4897d14b8000000000000000000000000000000000000000000000000000000000000000102d241fdb9d4330c564ffc0a36af05f66c6174657374000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a5000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ); + } + + function getResponseWithGitHubAuth() + external + pure + returns (SismoConnectResponse memory response, bytes memory responseAsBytes) + { + Auth memory auth = AuthBuilder.build({authType: AuthType.GITHUB}); + + SismoConnectProof[] memory proofs = new SismoConnectProof[](1); + proofs[0] = ProofBuilder.build({ + auth: auth, + proofData: hex"0dac2cbf2a79fbf0685feb4decc19d488741ab490e3a1d9bc7f188b117650cd81acd802e6ed6a5c7d1b82b43238e6c6b9ccc5ba466aa7a2edcf11916374b410f06acfd9ce499c4798e90170cd4ae34163e98f57c011b96ee4cab4a48e2bf276c01431be40bbdfa36bea2306300b12b33d5848b3ac2d537697b7bb49d20eadb09222be62294cfe98a8d9fc397d96a3d76b1baf55644ebcad35c9b29be6a0a6c542bb5308742a9bea4ff29f1732cfc0b1ac496dd7e2ab7f2f6f4e7760700cab6e4166218b204613db523550412311a5f58d3090138c70c38ba402c61bedd4fcaf1202bc490be5cab53595dc1359743004bc48c6db6fa7a9bb80c65cdc3d28fea54000000000000000000000000100100000000000000000000000000009999037009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" + }); + + return ( + SismoConnectResponse({ + appId: 0x11b1de449c6c4adb0b5775b3868b28b3, + namespace: bytes16(keccak256("main")), + version: bytes32("sismo-connect-v1.1"), + signedMessage: abi.encode(0x7def1d6D28D6bDa49E69fa89aD75d160BEcBa3AE), + proofs: proofs + }), + // response as bytes + hex"000000000000000000000000000000000000000000000000000000000000002011b1de449c6c4adb0b5775b3868b28b300000000000000000000000000000000b8e2054f8a912367e38a22ce773328ff000000000000000000000000000000007369736d6f2d636f6e6e6563742d76312e31000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000200000000000000000000000007def1d6d28d6bda49e69fa89ad75d160becba3ae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000100100000000000000000000000000009999037000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c00dac2cbf2a79fbf0685feb4decc19d488741ab490e3a1d9bc7f188b117650cd81acd802e6ed6a5c7d1b82b43238e6c6b9ccc5ba466aa7a2edcf11916374b410f06acfd9ce499c4798e90170cd4ae34163e98f57c011b96ee4cab4a48e2bf276c01431be40bbdfa36bea2306300b12b33d5848b3ac2d537697b7bb49d20eadb09222be62294cfe98a8d9fc397d96a3d76b1baf55644ebcad35c9b29be6a0a6c542bb5308742a9bea4ff29f1732cfc0b1ac496dd7e2ab7f2f6f4e7760700cab6e4166218b204613db523550412311a5f58d3090138c70c38ba402c61bedd4fcaf1202bc490be5cab53595dc1359743004bc48c6db6fa7a9bb80c65cdc3d28fea54000000000000000000000000100100000000000000000000000000009999037009f60d972df499264335faccfc437669a97ea2b6c97a1a7ddf3f0105eda34b1d07f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000" + ); + } + + function getResponseWithGitHubAuthWithoutSignature() + external + pure + returns (SismoConnectResponse memory response, bytes memory responseAsBytes) + { + Auth memory auth = AuthBuilder.build({authType: AuthType.GITHUB}); + + SismoConnectProof[] memory proofs = new SismoConnectProof[](1); + proofs[0] = ProofBuilder.build({ + auth: auth, + proofData: hex"14aa96fb34414b749bb4610bace69a3d3e9ed4b1af6137f7d1a3270590c696bb0074dc54bfd774a3185b445f2b1013bcefb8d8d1b98b186611829ae9ac59a44407b6fa1abaafa92b207d2bed2139ff1a6cd05f56ac2167f89a6b3a3180eceebb107f09ef3f109f1ac13560ed255b5605e340964f5fd6b96ae9e62634cd219d51233f679d2011810af86b8da940f2e3b8ba38716d0ab63a8aa6944c13dd6ec40d0c36d09c76572cc1dfffd527ca60c1828642782322a49ef6df921f0a57ecc65f2706ff429747a7b1dd72643a24dc9be189b0461f155fe5479bde1f78609fece82331e429f79401e878e826c36ada7d85053e00226dd49e6e76fb76ff7b2e43490000000000000000000000001001000000000000000000000000000099990370000000000000000000000000000000000000000000000000000000000000000007f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" + }); + + return ( + SismoConnectResponse({ + appId: 0x11b1de449c6c4adb0b5775b3868b28b3, + namespace: bytes16(keccak256("main")), + version: bytes32("sismo-connect-v1.1"), + signedMessage: "", + proofs: proofs + }), + // response as bytes + hex"000000000000000000000000000000000000000000000000000000000000002011b1de449c6c4adb0b5775b3868b28b300000000000000000000000000000000b8e2054f8a912367e38a22ce773328ff000000000000000000000000000000007369736d6f2d636f6e6e6563742d76312e31000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000100100000000000000000000000000009999037000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c014aa96fb34414b749bb4610bace69a3d3e9ed4b1af6137f7d1a3270590c696bb0074dc54bfd774a3185b445f2b1013bcefb8d8d1b98b186611829ae9ac59a44407b6fa1abaafa92b207d2bed2139ff1a6cd05f56ac2167f89a6b3a3180eceebb107f09ef3f109f1ac13560ed255b5605e340964f5fd6b96ae9e62634cd219d51233f679d2011810af86b8da940f2e3b8ba38716d0ab63a8aa6944c13dd6ec40d0c36d09c76572cc1dfffd527ca60c1828642782322a49ef6df921f0a57ecc65f2706ff429747a7b1dd72643a24dc9be189b0461f155fe5479bde1f78609fece82331e429f79401e878e826c36ada7d85053e00226dd49e6e76fb76ff7b2e43490000000000000000000000001001000000000000000000000000000099990370000000000000000000000000000000000000000000000000000000000000000007f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000" + ); + } + + function getCheatSheetResponse() external pure returns (bytes memory) { + return + hex"000000000000000000000000000000000000000000000000000000000000002032403ced4b65f2079eda77c84e7d2be600000000000000000000000000000000b8e2054f8a912367e38a22ce773328ff000000000000000000000000000000007369736d6f2d636f6e6e6563742d76312e31000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d49206c6f7665205369736d6f2100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000ac00000000000000000000000000000000000000000000000000000000000000f80000000000000000000000000000000000000000000000000000000000000144000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000001de000000000000000000000000000000000000000000000000000000000000022c000000000000000000000000000000000000000000000000000000000000027a00000000000000000000000000000000000000000000000000000000000002c8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c02ee756e8d291546c67b5573b9b751b5bd5a0dbcede35464ef2a6e2c14f11b033151164d686f667393f18dcd27584954f2126998bcbed6ed9b9982cd99069bb830d2e1f84055faad2b66fd81c5db45b47356df5f8a3e3c3f852b63ffb83579b25221a09032e42863c6847ff2dd1ad2843628b7cae34ce0eee41c2c95829526ba611abc4b47a83f51174c44304a3ec7fc5e0a4d2661c6e0516f1f932c5258d788a14165f2fac0ff540383b5d74113f799dc98b5e6bc9cad1d8c1706b8606ff7d400877d9fc97b985ab302afe17621dd1ede1379dc2671aeb791d104097ce7a2b7c2d27c3487bda0b24a491c70c021aee29840c77400e3612e6959cd78c1d29e55000000000000000000000000000000000000000000000000000000000000000001304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000008ab1760889f26cbbf33a75fd2cf1696bfccdc9e600000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c024d4b21c846468fc5e45041225279dbaf181db1d30c0ca47ba531e2139d9eaf7280d33b782823298589f29aaba714eea5acb96ebe2826de93f633d7f3c0a008f2f32d3204f8911a2bcfa70a0ef4e197b1807f8cfbb23f8e5686d79ccce4a40a10d7cf559488b27861bd1cc1b63275ccdceb49daaf8639ee099df558ceec868ed0edc00ae97888c6e213a4922f25c33e2e9de1d9a84f65101e071ac07297799eb2ca5e5cc67ee3d6c3a747ee9f0da812d8cbcb477a162dcabc40860092b8e4985049dded4313ca1c7fd8c2bb2341dc239b4c0b7db930ecc7e2b849e5dcdfe9317247dc2c6229691441432bffb6228a40d4096290a347bed1a215bf4203b6932a80000000000000000000000008ab1760889f26cbbf33a75fd2cf1696bfccdc9e61304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a4c94a6091545e40fc9c3e0982aec8942e282f3800000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c005e9a85d4b9401511669228989a3ff0c30b5b9f459e900fc75d4ab9a70c49ef80e46b75f5cf3bccbf05d7af71f87fe8d132b7f85a1607b0bfd6e4feaa8213f9f1063f2f84a7ce96e52f5e43003dfab677a74c1ec96a1d626225a4033cde26ebc0e54e534d6de2002f1a08033821a7fd348fd0f9dae7e85e0796f76319ff8c8e5251c6201cecdbd21885dd4d341227cdbf8f7f5693146166d99192c0ada581d5924b9ebe2e3dd193f95bbfc462a64bddcce25b799936a919452a704138a60c35d1534cb185dc6762a446321ad3b0ac40720cde123c86d8ada6ed050b0c106adc81ee271099e4702a5925e134d668eea626c19b220a2c39dd16d0400168d99d791000000000000000000000000a4c94a6091545e40fc9c3e0982aec8942e282f381304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000100100000000000000000000000000003577409700000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c0137081498c847bdc10ace33d22949bfc73b674d4812b66a8f53e878ddffc190f0cda340c783fd25566dfd14394dcc8fc9e7af60237bbec04d70b097721f7e6e70e0998b7010de2546274bb5c03238e5ffd2340c319ba85327f11e8dd0279f1f217e1c040a49739304d4025d7c42d97f2b41102d4b504b49693666d6fffae1ea5279e58b6b2a415acd5db0706921a85985d348386637463751a7de73448ac35fd215517307d716502bc580dff5ba4c8f484eeb7a1f2f9cc69f49052a09f6887b70803efb5635d81e2f07eb7ae6024bcd4ffd2b927209865e183747523f7d274c51464ceea457eb61b7c2a132177ec531842ceb568a51fe6a4e145a0f9a564a0ee00000000000000000000000010010000000000000000000000000000357740971304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100300000000000000000000000000087560811000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c01cab87335090f31f2c858c45dbe40ac1e3fd5eda4b584bbc8b8784991a5c9f91041986364178d5d6a6a9cfbe96e6679111feff038be558c436df97c113d8f10e25b99ceb0082c9df5bb7e90739e1c1f4d4588bae1169c88c5422356294e86b7e0b43cb521b0b664462993aea9666d18a84e6684afeed6ba49b0b42402b67685e0b82bfa1c7724f214cd6fd624e7300ab4372f955ebfd9b489aa935ed5e074eb2239b65a6f9f51888891d69f57ce2d4a6fd1a1594d77090edf526d16242feb4a2157bec5129edd6e86f43d73f12b2561250a8835cfa5eb1533f1a15d5d1513ca11129beec3cd8288b1beb42352734cb93173f72679402a51db226dbe1a01ce49900000000000000000000000010030000000000000000000000000008756081101304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000fae674b6cba3ff2f8ce2114defb200b1000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c0068a54cba7e80eea17652e5399bac0f373a37289e19e4990f03b14f5304ba97b0e86c7b9ff626dad18a91068c36cfaca3b4bba8c23ccbd8aa89a50478632bb3808dac983625c650c8ee73594fd9b6cc609696db35f213f4efa3c7355436c61d9273d66565e35cd47df9763521fcb24813b0070b920aa7d13206d3f541540a4542ff6e85db5be75a22c067551f70000275568339f0e67155907ce6aaacdd9c35120e1c6f0752cb5565b7324847eadc5b568b60b356976f6194b59cddd32f72bcd0c60c6907df2d4e1dfc7fd7cafb77170d74deed3b60f4565d8814ad3345c489d2073030d081ad0615e2898c77db05842544e08d1909daffd4b1f51af41d0c1a600000000000000000000000000000000000000000000000000000000000000001304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d85210223889be50de6309c4a51edd039aa1fb882c9964a746581ff319bbe982debcf82efc4cc7c03398856dbf08377861fb15549f5a9137456a615d4da264e7d69cd4000000000000000000000000000000000000000000000000000000000000000108f0ec7865abde5ef350b4bd682b46dfa35deafb12d4cd29ac96341c4ffffffb000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000001cde61966decb8600dfd0749bd371f12000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c02c7c25b4657897bdb2bc62112bdac39f1fcb4fd090b44a73b9e17125754d0f9a26321b26cb19ac752eb7f7557ef0b868d9e1c0cb22a6f3354d8bf1eae8efb02f2ea24f5c4265ed8439dfa93a3742164e91bad77e6fee1b2f88ecd7c58fbe802027f44df7403fb133ce8cc8c5fd23b458c4bc53c455727e28d753bfea20f1445d2182c405df59bec7da832b42cfa3edbbd48bdf42dbfb073950d13ee7b0a55f1c1d4eb48a63d9d4f67c61a932a830101e76b501cd1145ffc755d8d5450b554bbd2fbd2b04120d8ef1e5bd290b00ff4a25a917bccfa03f13da4f70e7d30ac792932e716a0f4c76aa9a197419c2125257cfcfd36fd4e7c7de28c145ec429e3c5a1700000000000000000000000000000000000000000000000000000000000000001304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d852101e7a3215d4d02e734fa653c5ca96357521ac260e6ba94a1f05c413b0143e15bd2113caea8c11ac1bdcde3d297ebd9f24df376b1ae881a18e62e49c81b5db8267000000000000000000000000000000000000000000000000000000000000000f1cde61966decb8600dfd0749bd371f126c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002fae674b6cba3ff2f8ce2114defb200b1000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c0107ecc33ddbb094a870b4f300a5fff992ce214effaf8e441b1d3de2d2b9ae0a012842d6a54fd89bc48444701e99eb26114f4bf767490bb13d0446f214c55ce7603ecc0efc47b9d2fe6683d856ddc141d234da6e80845263c4bcc1e823443da430c50c00649710842967c9755f99bafc7219a19fad38cce29f1bcf1316c1469061c0b6468c29704188ddece490bd2723cc392b4ca7b1f6501c6469236cb535bf61df114f50ba48448088c440823c7cf811003b2c1707f124d8ab2b262c7400c982b14db09cfabca6f7fd817457ae68a882cbd72c01839cc326408e938e3deb0140323af36a396c8b906ecfda2d92e82383e4693cef14d94a2b2b77f4b61b3859000000000000000000000000000000000000000000000000000000000000000001304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d85210223889be50de6309c4a51edd039aa1fb882c9964a746581ff319bbe982debcf82efc4cc7c03398856dbf08377861fb15549f5a9137456a615d4da264e7d69cd4000000000000000000000000000000000000000000000000000000000000000a08f0ec7865abde5ef350b4bd682b46dfa35deafb12d4cd29ac96341c4ffffffb000000000000000000000000000000000000000000000000000000000000000110915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000fae674b6cba3ff2f8ce2114defb200b1000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c02699914aaa5bb1b11b49261603cd894aee490c39b8ca5ea5c1625f05c60c3e2e2e4bef13a3cc0df3f3dc1bf5d601b699f4c2d94b1ca2b62622f91874f3a600832f057ff2148e63bc50db8c9f049e33929d195610f8b8a826d75941d2ef7c46ef1a108ab29c16b6498990fa5767f4e3594648c444a71dd16924366d03e1f31a9813f954aaf7916663320a9baa8de31cb14f3e4ce8fb7fc88d7ae2356f8d91404f1c21b77322002fdfcea7df847cf31f4dc7c4485d535392f4583aa67eb63bfcd214ca04a230eca28910992acf54cb9682f8b7a4240b193ccdd7ac081181e9ee3f1fbfc685affa356338b832c8c49dc2d33cafb950af2377e2ea73e53cc101020400000000000000000000000000000000000000000000000000000000000000001304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d85210223889be50de6309c4a51edd039aa1fb882c9964a746581ff319bbe982debcf82efc4cc7c03398856dbf08377861fb15549f5a9137456a615d4da264e7d69cd4000000000000000000000000000000000000000000000000000000000000000108f0ec7865abde5ef350b4bd682b46dfa35deafb12d4cd29ac96341c4ffffffb000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000001cde61966decb8600dfd0749bd371f12000000000000000000000000000000006c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001900000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c01376d89c862093d8af4faece2845d584a7f5adbce6415f91185445053066db272b55dfb2d1f4d34239c3dde1e396bec29e5a1398dc9cc589a1c4a01dc6b5a190038bbde989bdaa41ae06c00e806e8b05698557a1ee2b7bcba05173cb72e5a22b2b4b2be01439457de5fbee80ca58c442b0a98239810cd611ab1db95e2806d81a194d33e4750fa3d1dc0417bc8c620935c888ad3a5af607fc4ccf21af83b539980c8017f171ea205708d7d16dd2d6968682c92a4f6aa60c4a2b397849c064f1d71f2c626c4108ab3566301144a75f0964791e8770d014da3c6b986cadc296763d19d3935c9924bd88b558920f376f4cd31833d1f69dcaa8b747bd8fab8a83305300000000000000000000000000000000000000000000000000000000000000001304dc6e4c90bc43f257c55a1c5ec90070d73f4356bca95b502a7bbc28d13a071801b584700a740f9576cc7e83745895452edc518a9ce60b430e1272fc4eb93b057cf80de4f8dd3e4c56f948f40c28c3acbeca71ef9f825597bf8cc059f1238b0d4f2a0d3c9c82fbdb9f118c948baa9d8c0b2f467855c6b4cb43a95631d852101e7a3215d4d02e734fa653c5ca96357521ac260e6ba94a1f05c413b0143e15bd2113caea8c11ac1bdcde3d297ebd9f24df376b1ae881a18e62e49c81b5db826700000000000000000000000000000000000000000000000000000000000000191cde61966decb8600dfd0749bd371f126c617465737400000000000000000000000000000000000000000000000000000000000000000000000000000000000010915e40a7c9ce7f97e81541c24893b4f714de4794fc4a3c71898cb9f25bb55f0fe61c3a8c717465050c08081b2efe7d66020da96e00293df4c354c783d06b6b000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + } +} diff --git a/test/harness/SismoConnectHarness.sol b/test/harness/SismoConnectHarness.sol new file mode 100644 index 0000000..b0067cc --- /dev/null +++ b/test/harness/SismoConnectHarness.sol @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "src/SismoConnectLib.sol"; + +// This contract is used to expose internal functions of SismoConnect for testing purposes +// It is NOT deployed in production +// see: https://book.getfoundry.sh/tutorials/best-practices?highlight=coverage#test-harnesses +contract SismoConnectHarness is SismoConnect { + constructor( + bytes16 appId, + bool isImpersonationMode + ) SismoConnect(buildConfig(appId, isImpersonationMode)) {} + + function exposed_buildClaim(bytes16 groupId) external view returns (ClaimRequest memory) { + return buildClaim(groupId); + } + + function exposed_buildAuth(AuthType authType) external view returns (AuthRequest memory) { + return buildAuth(authType); + } + + function exposed_buildAuth( + AuthType authType, + bool isAnon + ) external view returns (AuthRequest memory) { + return buildAuth({authType: authType, isAnon: isAnon}); + } + + function exposed_buildAuth( + AuthType authType, + bool isOptional, + bool isSelectableByUser + ) external view returns (AuthRequest memory) { + return + buildAuth({ + authType: authType, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser + }); + } + + function exposed_buildAuth( + AuthType authType, + uint256 userId + ) external view returns (AuthRequest memory) { + return buildAuth({authType: authType, userId: userId}); + } + + function exposed_buildAuth( + AuthType authType, + bool isSelectableByUser, + bool isOptional, + uint256 userId + ) external view returns (AuthRequest memory) { + return + buildAuth({ + authType: authType, + isSelectableByUser: isSelectableByUser, + isOptional: isOptional, + userId: userId + }); + } + + function exposed_buildSignature( + bytes memory message + ) external view returns (SignatureRequest memory) { + return buildSignature(message); + } + + function exposed_verify( + bytes memory responseBytes, + ClaimRequest memory claim + ) external view returns (SismoConnectVerifiedResult memory) { + return verify({responseBytes: responseBytes, claim: claim}); + } + + function exposed_verify( + bytes memory responseBytes, + ClaimRequest memory claim, + bytes16 namespace + ) external view returns (SismoConnectVerifiedResult memory) { + return verify({responseBytes: responseBytes, claim: claim, namespace: namespace}); + } + + function exposed_verify( + bytes memory responseBytes, + ClaimRequest memory claim, + SignatureRequest memory signature + ) external view returns (SismoConnectVerifiedResult memory) { + return verify({responseBytes: responseBytes, claim: claim, signature: signature}); + } + + function exposed_verify( + bytes memory responseBytes, + AuthRequest memory auth, + SignatureRequest memory signature + ) external view returns (SismoConnectVerifiedResult memory) { + return verify({responseBytes: responseBytes, auth: auth, signature: signature}); + } + + function exposed_verify( + bytes memory responseBytes, + SismoConnectRequest memory request + ) external view returns (SismoConnectVerifiedResult memory) { + return verify({responseBytes: responseBytes, request: request}); + } +} diff --git a/test/misc/UpgradeableExample.sol b/test/misc/UpgradeableExample.sol new file mode 100644 index 0000000..8ef608d --- /dev/null +++ b/test/misc/UpgradeableExample.sol @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; +import "src/SismoConnectLib.sol"; + +contract UpgradeableExample is SismoConnect, Initializable { + bytes16[] private _groupIds; + + constructor( + bytes16 appId, + bool isImpersonationMode, + bytes16 groupId + ) SismoConnect(buildConfig(appId, isImpersonationMode)) { + initialize(groupId); + } + + function initialize(bytes16 groupId) public initializer { + _groupIds.push(groupId); + } + + function addGroupId(bytes16 groupId) public { + _groupIds.push(groupId); + } + + function getGroupIds() public view returns (bytes16[] memory) { + return _groupIds; + } + + function exposed_buildSignature( + bytes memory message + ) external view returns (SignatureRequest memory) { + return buildSignature(message); + } + + function exposed_verify( + bytes memory responseBytes, + SignatureRequest memory signature + ) external view returns (SismoConnectVerifiedResult memory) { + ClaimRequest[] memory claims = new ClaimRequest[](_groupIds.length); + for (uint256 i = 0; i < _groupIds.length; i++) { + claims[i] = buildClaim(_groupIds[i]); + } + return verify({responseBytes: responseBytes, claims: claims, signature: signature}); + } +} diff --git a/test/misc/ZKDropERC721.sol b/test/misc/ZKDropERC721.sol new file mode 100644 index 0000000..87281a3 --- /dev/null +++ b/test/misc/ZKDropERC721.sol @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "src/SismoConnectLib.sol"; +import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; + +contract ZKDropERC721 is ERC721, SismoConnect { + using SismoConnectHelper for SismoConnectVerifiedResult; + + bytes16 public immutable GROUP_ID; + + string private _baseTokenURI; + + event BaseTokenURIChanged(string baseTokenURI); + + constructor( + string memory name, + string memory symbol, + string memory baseTokenURI, + bytes16 appId, + bytes16 groupId + ) ERC721(name, symbol) SismoConnect(buildConfig(appId)) { + GROUP_ID = groupId; + _setBaseTokenURI(baseTokenURI); + } + + function claimWithSismoConnect(bytes memory response, address to) public { + SismoConnectVerifiedResult memory result = verify({ + responseBytes: response, + auth: buildAuth({authType: AuthType.VAULT}), + claim: buildClaim({groupId: GROUP_ID}), + signature: buildSignature({message: abi.encode(to)}) + }); + + uint256 tokenId = result.getUserId(AuthType.VAULT); + _mint(to, tokenId); + } + + function transferWithSismoConnect(bytes memory response, address to) public { + SismoConnectVerifiedResult memory result = verify({ + responseBytes: response, + auth: buildAuth({authType: AuthType.VAULT}), + claim: buildClaim({groupId: GROUP_ID}), + signature: buildSignature({message: abi.encode(to)}) + }); + + uint256 tokenId = result.getUserId(AuthType.VAULT); + address from = ownerOf(tokenId); + _transfer(from, to, tokenId); + } + + function tokenURI(uint256) public view virtual override returns (string memory) { + return _baseTokenURI; + } + + function _setBaseTokenURI(string memory baseURI) private { + _baseTokenURI = baseURI; + emit BaseTokenURIChanged(baseURI); + } +} diff --git a/test/mocks/AddressesProviderMock.sol b/test/mocks/AddressesProviderMock.sol new file mode 100644 index 0000000..ea43efe --- /dev/null +++ b/test/mocks/AddressesProviderMock.sol @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +contract AddressesProviderMock { + mapping(bytes32 => address) private _contractAddresses; + string[] private _contractNames; + + /** + * @dev Sets the address of a contract. + * @param contractAddress Address of the contract. + * @param contractName Name of the contract. + */ + function set(address contractAddress, string memory contractName) public { + bytes32 contractNameHash = keccak256(abi.encodePacked(contractName)); + + if (_contractAddresses[contractNameHash] == address(0)) { + _contractNames.push(contractName); + } + + _contractAddresses[contractNameHash] = contractAddress; + } + + /** + * @dev Sets the address of multiple contracts. + * @param contractAddresses Addresses of the contracts. + * @param contractNames Names of the contracts. + */ + function setBatch(address[] calldata contractAddresses, string[] calldata contractNames) public { + require( + contractAddresses.length == contractNames.length, + "AddressesProviderMock: Arrays must be the same length" + ); + + for (uint256 i = 0; i < contractAddresses.length; i++) { + set(contractAddresses[i], contractNames[i]); + } + } + + function get(string memory contractName) public view returns (address) { + bytes32 contractNameHash = keccak256(abi.encodePacked(contractName)); + + return _contractAddresses[contractNameHash]; + } +} diff --git a/test/mocks/SismoConnectVerifierMock.sol b/test/mocks/SismoConnectVerifierMock.sol new file mode 100644 index 0000000..875c960 --- /dev/null +++ b/test/mocks/SismoConnectVerifierMock.sol @@ -0,0 +1,137 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.17; + +import "../../src/interfaces/ISismoConnectVerifier.sol"; + +contract SismoConnectVerifierMock is ISismoConnectVerifier { + uint8 public constant IMPLEMENTATION_VERSION = 1; + bytes32 public immutable SISMO_CONNECT_VERSION = "sismo-connect-v1.1"; + + bool public isProofValid = true; + + // struct to store informations about the number of verified auths and claims returned + // indexes of the first available slot in the arrays of auths and claims are also stored + // this struct is used to avoid stack to deep errors without using via_ir in foundry + struct VerifiedArraysInfos { + uint256 nbOfAuths; // number of verified auths + uint256 nbOfClaims; // number of verified claims + uint256 authsIndex; // index of the first available slot in the array of verified auths + uint256 claimsIndex; // index of the first available slot in the array of verified claims + } + + // Struct holding the verified Auths and Claims from the snark proofs + // This struct is used to avoid stack too deep error + struct VerifiedProofs { + VerifiedAuth[] auths; + VerifiedClaim[] claims; + } + + error InvalidProof(); + + function setIsProofValid(bool _isProofValid) external { + isProofValid = _isProofValid; + } + + function verify( + SismoConnectResponse memory response, + SismoConnectRequest memory, // request + SismoConnectConfig memory // config + ) external view override returns (SismoConnectVerifiedResult memory) { + if (!isProofValid) { + revert InvalidProof(); + } + + uint256 responseProofsArrayLength = response.proofs.length; + VerifiedArraysInfos memory infos = VerifiedArraysInfos({ + nbOfAuths: 0, + nbOfClaims: 0, + authsIndex: 0, + claimsIndex: 0 + }); + + // Count the number of auths and claims in the response + for (uint256 i = 0; i < responseProofsArrayLength; i++) { + infos.nbOfAuths += response.proofs[i].auths.length; + infos.nbOfClaims += response.proofs[i].claims.length; + } + + VerifiedProofs memory verifiedProofs = VerifiedProofs({ + auths: new VerifiedAuth[](infos.nbOfAuths), + claims: new VerifiedClaim[](infos.nbOfClaims) + }); + + for (uint256 i = 0; i < responseProofsArrayLength; i++) { + // we use an external call to getVerifiedAuthAndClaim to avoid stack too deep error (the caller stack is not known by the callee contract) + // in the prod implementation, an external call to a verifier contract is done + // it explains why we don't encounter the stack too deep error in the prod implementation + (VerifiedAuth memory verifiedAuth, VerifiedClaim memory verifiedClaim) = this + .getVerifiedAuthAndClaim({ + appId: response.appId, + namespace: response.namespace, + proof: response.proofs[i] + }); + + // we only want to add the verified auths and claims to the result + // if they are not empty, for that we check the length of the proofData that should always be different from 0 + if (verifiedAuth.proofData.length != 0) { + verifiedProofs.auths[infos.authsIndex] = verifiedAuth; + infos.authsIndex++; + } + if (verifiedClaim.proofData.length != 0) { + verifiedProofs.claims[infos.claimsIndex] = verifiedClaim; + infos.claimsIndex++; + } + } + + return + SismoConnectVerifiedResult({ + appId: response.appId, + namespace: response.namespace, + version: response.version, + auths: verifiedProofs.auths, + claims: verifiedProofs.claims, + signedMessage: response.signedMessage + }); + } + + function getVerifiedAuthAndClaim( + bytes16 appId, + bytes16 namespace, + SismoConnectProof memory proof + ) external pure returns (VerifiedAuth memory, VerifiedClaim memory) { + VerifiedAuth memory verifiedAuth; + VerifiedClaim memory verifiedClaim; + + if (proof.auths.length != 0) { + verifiedAuth = VerifiedAuth({ + authType: proof.auths[0].authType, + isAnon: proof.auths[0].isAnon, + userId: proof.auths[0].userId, + proofData: proof.proofData, + extraData: proof.auths[0].extraData + }); + } + if (proof.claims.length != 0) { + verifiedClaim = VerifiedClaim({ + claimType: proof.claims[0].claimType, + groupId: proof.claims[0].groupId, + groupTimestamp: proof.claims[0].groupTimestamp, + value: proof.claims[0].value, + proofId: uint256( + keccak256( + abi.encodePacked( + proof.claims[0].groupId, + proof.claims[0].groupTimestamp, + appId, + namespace + ) + ) + ), + proofData: proof.proofData, + extraData: proof.claims[0].extraData + }); + } + return (verifiedAuth, verifiedClaim); + } +} diff --git a/test/script/DeployLibraries.t.sol b/test/script/DeployLibraries.t.sol new file mode 100644 index 0000000..b0f6eaf --- /dev/null +++ b/test/script/DeployLibraries.t.sol @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "forge-std/Test.sol"; +import "forge-std/console.sol"; +import {DeployLibraries, DeploymentConfig} from "script/DeployLibraries.s.sol"; +import {SetAddressesProvider} from "script/utils/SetAddressesProvider.s.sol"; +import {AddressesProviderMock} from "test/mocks/AddressesProviderMock.sol"; +import {BaseTest} from "test/BaseTest.t.sol"; +import {IAddressesProvider} from "src/interfaces/IAddressesProvider.sol"; + +contract DeployLibrariesTest is BaseTest { + DeployLibraries deploy; + DeploymentConfig contracts; + SetAddressesProvider setAddressesProvider; + + function setUp() public virtual override { + super.setUp(); + + // clean the deployments/test folder + string[] memory removeFolderInputs = new string[](3); + removeFolderInputs[0] = "rm"; + removeFolderInputs[1] = "-rf"; + removeFolderInputs[2] = string.concat(vm.projectRoot(), "/deployments/test"); + vm.ffi(removeFolderInputs); + + deploy = new DeployLibraries(); + // deploy all libraries by calling the `runFor` function of the DeployLibraries script contract + (bool success, bytes memory result) = address(deploy).delegatecall( + abi.encodeWithSelector(DeployLibraries.runFor.selector, "test") + ); + require(success, "DeployLibraries script did not run successfully!"); + contracts = abi.decode(result, (DeploymentConfig)); + + // save the test config in the `deployments` folder + // so that the libraries addresses are available for the other scripts + string[] memory inputs = new string[](2); + inputs[0] = "yarn"; + inputs[1] = "save-deployments"; + vm.ffi(inputs); + + // set the addresses in the AddressesProvider contract + setAddressesProvider = new SetAddressesProvider(); + (bool success2, ) = address(setAddressesProvider).delegatecall( + abi.encodeWithSelector(SetAddressesProvider.runFor.selector, "test") + ); + require(success2, "SetAddressesProvider script did not run successfully!"); + } + + function testDeployLibraries() public { + // check that the libraries were deployed + // and that the addresses in the AddressesProvider were updated accordingly + assertEq( + address(contracts.authRequestBuilder), + IAddressesProvider(SISMO_ADDRESSES_PROVIDER_V2).get(string("authRequestBuilder-v1.1")) + ); + assertFalse(address(contracts.authRequestBuilder) == address(authRequestBuilder)); + + assertEq( + address(contracts.claimRequestBuilder), + IAddressesProvider(SISMO_ADDRESSES_PROVIDER_V2).get(string("claimRequestBuilder-v1.1")) + ); + assertFalse(address(contracts.claimRequestBuilder) == address(claimRequestBuilder)); + + assertEq( + address(contracts.signatureBuilder), + IAddressesProvider(SISMO_ADDRESSES_PROVIDER_V2).get(string("signatureBuilder-v1.1")) + ); + assertFalse(address(contracts.signatureBuilder) == address(signatureBuilder)); + + assertEq( + address(contracts.requestBuilder), + IAddressesProvider(SISMO_ADDRESSES_PROVIDER_V2).get(string("requestBuilder-v1.1")) + ); + assertFalse(address(contracts.requestBuilder) == address(requestBuilder)); + } +} diff --git a/test/unit/SismoConnect.t.sol b/test/unit/SismoConnect.t.sol new file mode 100644 index 0000000..a286920 --- /dev/null +++ b/test/unit/SismoConnect.t.sol @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import {BaseTest} from "test/BaseTest.t.sol"; +import {SismoConnectHarness} from "test/harness/SismoConnectHarness.sol"; +import "src/utils/Structs.sol"; + +contract SismoConnectTest is BaseTest { + SismoConnectHarness sismoConnect; + + bytes16 public constant DEFAULT_APP_ID = bytes16("default-app-id"); + bool public constant IS_IMPERSONATION_MODE = false; + + function setUp() public virtual override { + BaseTest.setUp(); + + sismoConnect = new SismoConnectHarness({ + appId: DEFAULT_APP_ID, + isImpersonationMode: IS_IMPERSONATION_MODE + }); + } + + function test_RevertWith_EmptyMessageIfSismoConnectResponseIsEmpty() public { + bytes memory responseBytes = hex""; + ClaimRequest memory claimRequest = claimRequestBuilder.build({groupId: bytes16("group-id")}); + // we just expect a revert with an empty responseBytes as far as the decoding will not be successful + vm.expectRevert(); + sismoConnect.exposed_verify({responseBytes: responseBytes, claim: claimRequest}); + } + + function test_RevertWith_InvalidUserIdAndIsSelectableByUserAuthType() public { + // When `userId` is 0, it means the app does not require a specific auth account and the user needs + // to choose the account they want to use for the app. + // When `isSelectableByUser` is true, the user can select the account they want to use. + // The combination of `userId = 0` and `isSelectableByUser = false` does not make sense and should not be used. + + // Here we do expect the revert since we set isSelectableByUser to false + // and we keep the default value for userId which is 0 + // effectivelly triggering the revert + // Note: we use an AuthType different from VAULT to not trigger another revert + vm.expectRevert(abi.encodeWithSignature("InvalidUserIdAndIsSelectableByUserAuthType()")); + sismoConnect.exposed_buildAuth({ + authType: AuthType.GITHUB, + isOptional: false, + isSelectableByUser: false + }); + } + + function test_RevertWith_InvalidUserIdAndAuthType() public { + // When `userId` is 0, it means the app does not require a specific auth account and the user needs + // to choose the account they want to use for the app. + // When `isSelectableByUser` is true, the user can select the account they want to use. + // The combination of `userId = 0` and `isSelectableByUser = false` does not make sense and should not be used. + + // Here we set isSelectableByUser to false but we add a userId different from zero + // while choosing The AuthType VAULT, which does NOT make sense since it states that we allow the user to choose a vault account in his vault + // but in the case of the AuthType VAULT, the account is the vault itself and therefore there is no choice to make + // we should definitely revert based on this reasoning + vm.expectRevert(abi.encodeWithSignature("InvalidUserIdAndAuthType()")); + sismoConnect.exposed_buildAuth({ + authType: AuthType.VAULT, + isOptional: false, + isSelectableByUser: false, + userId: uint256(bytes32("wrong-id")) + }); + } + + function test_verifyValidProof() public view { + bytes + memory responseBytes = hex"000000000000000000000000000000000000000000000000000000000000002011b1de449c6c4adb0b5775b3868b28b300000000000000000000000000000000b8e2054f8a912367e38a22ce773328ff000000000000000000000000000000007369736d6f2d636f6e6e6563742d76312e31000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000100100000000000000000000000000009999037000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c014aa96fb34414b749bb4610bace69a3d3e9ed4b1af6137f7d1a3270590c696bb0074dc54bfd774a3185b445f2b1013bcefb8d8d1b98b186611829ae9ac59a44407b6fa1abaafa92b207d2bed2139ff1a6cd05f56ac2167f89a6b3a3180eceebb107f09ef3f109f1ac13560ed255b5605e340964f5fd6b96ae9e62634cd219d51233f679d2011810af86b8da940f2e3b8ba38716d0ab63a8aa6944c13dd6ec40d0c36d09c76572cc1dfffd527ca60c1828642782322a49ef6df921f0a57ecc65f2706ff429747a7b1dd72643a24dc9be189b0461f155fe5479bde1f78609fece82331e429f79401e878e826c36ada7d85053e00226dd49e6e76fb76ff7b2e43490000000000000000000000001001000000000000000000000000000099990370000000000000000000000000000000000000000000000000000000000000000007f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000"; + ClaimRequest memory claimRequest = claimRequestBuilder.build({groupId: bytes16("group-id")}); + // by default, the sismoConnectVerifier contract is mocked + // the mock will return true for any proof well encoded in the response + sismoConnect.exposed_verify({responseBytes: responseBytes, claim: claimRequest}); + } + + function test_RevertWith_InvalidProof() public { + // set the mock to return the invalid proof error + sismoConnectVerifier.setIsProofValid(false); + + bytes + memory responseBytes = hex"000000000000000000000000000000000000000000000000000000000000002011b1de449c6c4adb0b5775b3868b28b300000000000000000000000000000000b8e2054f8a912367e38a22ce773328ff000000000000000000000000000000007369736d6f2d636f6e6e6563742d76312e31000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a068796472612d73332e310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000100100000000000000000000000000009999037000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c014aa96fb34414b749bb4610bace69a3d3e9ed4b1af6137f7d1a3270590c696bb0074dc54bfd774a3185b445f2b1013bcefb8d8d1b98b186611829ae9ac59a44407b6fa1abaafa92b207d2bed2139ff1a6cd05f56ac2167f89a6b3a3180eceebb107f09ef3f109f1ac13560ed255b5605e340964f5fd6b96ae9e62634cd219d51233f679d2011810af86b8da940f2e3b8ba38716d0ab63a8aa6944c13dd6ec40d0c36d09c76572cc1dfffd527ca60c1828642782322a49ef6df921f0a57ecc65f2706ff429747a7b1dd72643a24dc9be189b0461f155fe5479bde1f78609fece82331e429f79401e878e826c36ada7d85053e00226dd49e6e76fb76ff7b2e43490000000000000000000000001001000000000000000000000000000099990370000000000000000000000000000000000000000000000000000000000000000007f6c5612eb579788478789deccb06cf0eb168e457eea490af754922939ebdb920706798455f90ed993f8dac8075fc1538738a25f0c928da905c0dffd81869fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086297004382ede0550866e3e15fdce4b5b9fa843f0c12fece0fa11cf69ba5ff01935d4d418952220ae0332606f61de2894d8b84c3076e6097ef3746a1ba04a5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000"; + ClaimRequest memory claimRequest = claimRequestBuilder.build({groupId: bytes16("group-id")}); + vm.expectRevert(abi.encodeWithSignature("InvalidProof()")); + sismoConnect.exposed_verify({responseBytes: responseBytes, claim: claimRequest}); + } +} diff --git a/test/utils/ResponseBuilderLib.sol b/test/utils/ResponseBuilderLib.sol new file mode 100644 index 0000000..7b71c93 --- /dev/null +++ b/test/utils/ResponseBuilderLib.sol @@ -0,0 +1,283 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "src/utils/Structs.sol"; +import {ProofBuilder} from "src/utils/SismoConnectProofBuilder.sol"; + +// We introduce an intermediate struct that will not store the proofs +// This is useful to be able to store this struct in the a contract storage +// We will then use different function to add the proofs and build the SismoConnectResponse struct +struct ResponseWithoutProofs { + bytes16 appId; + bytes16 namespace; + bytes32 version; + bytes signedMessage; +} + +// This library aims at building SismoConnectResponse structs with less overhead +// than using the SismoConnectResponse struct directly +// It also allows to build the SismoConnectResponse struct in multiple steps +// by adding the proofs later, ensuring modularity and flexibility in the code +library ResponseBuilder { + ////////////////////////////////// + // Simple Field Initialization // + //////////////////////////////// + + function withAppId( + SismoConnectResponse memory response, + bytes16 appId + ) external pure returns (SismoConnectResponse memory) { + response.appId = appId; + return response; + } + + function withAppId( + ResponseWithoutProofs memory response, + bytes16 appId + ) external pure returns (ResponseWithoutProofs memory) { + response.appId = appId; + return response; + } + + function withVersion( + SismoConnectResponse memory response, + bytes32 version + ) external pure returns (SismoConnectResponse memory) { + response.version = version; + return response; + } + + function withVersion( + ResponseWithoutProofs memory response, + bytes32 version + ) external pure returns (ResponseWithoutProofs memory) { + response.version = version; + return response; + } + + function withNamespace( + SismoConnectResponse memory response, + bytes16 namespace + ) external pure returns (SismoConnectResponse memory) { + response.namespace = namespace; + return response; + } + + function withNamespace( + ResponseWithoutProofs memory response, + bytes16 namespace + ) external pure returns (ResponseWithoutProofs memory) { + response.namespace = namespace; + return response; + } + + function withSignedMessage( + SismoConnectResponse memory response, + bytes memory signedMessage + ) external pure returns (SismoConnectResponse memory) { + response.signedMessage = signedMessage; + return response; + } + + function withSignedMessage( + ResponseWithoutProofs memory response, + bytes memory signedMessage + ) external pure returns (ResponseWithoutProofs memory) { + response.signedMessage = signedMessage; + return response; + } + + ////////////////////////////////// + // Proof Initialization // + //////////////////////////////// + + // the `build` function is used to build a valid Sismo Connect response from a ResponseWithoutProofs struct + // it just adds an empty array of proofs to the ResponseWithoutProofs struct + // it has a public visibility because it is used inside this library to transform a ResponseWithoutProofs struct into a SismoConnectResponse struct + // but it can also be used outside this library to build a SismoConnectResponse struct from a ResponseWithoutProofs struct + function build( + ResponseWithoutProofs memory response + ) public pure returns (SismoConnectResponse memory) { + SismoConnectProof[] memory proofs = new SismoConnectProof[](0); + return + SismoConnectResponse({ + appId: response.appId, + namespace: response.namespace, + version: response.version, + signedMessage: response.signedMessage, + proofs: proofs + }); + } + + function withAuth( + SismoConnectResponse memory response, + Auth memory auth, + bytes memory proofData, + bytes32 provingScheme + ) public pure returns (SismoConnectResponse memory) { + SismoConnectProof[] memory proofs = new SismoConnectProof[](1); + proofs[0] = ProofBuilder.build({ + auth: auth, + proofData: proofData, + provingScheme: provingScheme + }); + response.proofs = proofs; + return response; + } + + function withAuth( + SismoConnectResponse memory response, + Auth memory auth, + bytes memory proofData + ) public pure returns (SismoConnectResponse memory) { + SismoConnectProof[] memory proofs = new SismoConnectProof[](1); + proofs[0] = ProofBuilder.build({auth: auth, proofData: proofData, provingScheme: ""}); + response.proofs = proofs; + return response; + } + + function withAuth( + SismoConnectResponse memory response, + Auth memory auth + ) external pure returns (SismoConnectResponse memory) { + return withAuth(response, auth, ""); + } + + function withAuth( + ResponseWithoutProofs memory response, + Auth memory auth, + bytes memory proofData, + bytes32 provingScheme + ) public pure returns (SismoConnectResponse memory) { + SismoConnectProof[] memory proofs = new SismoConnectProof[](1); + proofs[0] = ProofBuilder.build({ + auth: auth, + proofData: proofData, + provingScheme: provingScheme + }); + SismoConnectResponse memory responseWithProofs = build(response); + responseWithProofs.proofs = proofs; + return responseWithProofs; + } + + function withAuth( + ResponseWithoutProofs memory response, + Auth memory auth, + bytes memory proofData + ) public pure returns (SismoConnectResponse memory) { + SismoConnectProof[] memory proofs = new SismoConnectProof[](1); + proofs[0] = ProofBuilder.build({auth: auth, proofData: proofData, provingScheme: ""}); + SismoConnectResponse memory responseWithProofs = build(response); + responseWithProofs.proofs = proofs; + return responseWithProofs; + } + + function withAuth( + ResponseWithoutProofs memory response, + Auth memory auth, + bytes32 provingScheme + ) public pure returns (SismoConnectResponse memory) { + SismoConnectProof[] memory proofs = new SismoConnectProof[](1); + proofs[0] = ProofBuilder.build({auth: auth, proofData: "", provingScheme: provingScheme}); + SismoConnectResponse memory responseWithProofs = build(response); + responseWithProofs.proofs = proofs; + return responseWithProofs; + } + + function withAuth( + ResponseWithoutProofs memory response, + Auth memory auth + ) external pure returns (SismoConnectResponse memory) { + return withAuth({response: response, auth: auth, proofData: ""}); + } + + function withClaim( + SismoConnectResponse memory response, + Claim memory claim, + bytes memory proofData, + bytes32 provingScheme + ) public pure returns (SismoConnectResponse memory) { + SismoConnectProof[] memory proofs = new SismoConnectProof[](1); + proofs[0] = ProofBuilder.build({ + claim: claim, + proofData: proofData, + provingScheme: provingScheme + }); + response.proofs = proofs; + return response; + } + + function withClaim( + SismoConnectResponse memory response, + Claim memory claim, + bytes memory proofData + ) public pure returns (SismoConnectResponse memory) { + SismoConnectProof[] memory proofs = new SismoConnectProof[](1); + proofs[0] = ProofBuilder.build({claim: claim, proofData: proofData, provingScheme: ""}); + response.proofs = proofs; + return response; + } + + function withClaim( + SismoConnectResponse memory response, + Claim memory claim, + bytes32 provingScheme + ) public pure returns (SismoConnectResponse memory) { + SismoConnectProof[] memory proofs = new SismoConnectProof[](1); + proofs[0] = ProofBuilder.build({claim: claim, proofData: "", provingScheme: provingScheme}); + response.proofs = proofs; + return response; + } + + function withClaim( + SismoConnectResponse memory response, + Claim memory claim + ) external pure returns (SismoConnectResponse memory) { + return withClaim({response: response, claim: claim, proofData: ""}); + } + + function withClaim( + ResponseWithoutProofs memory response, + Claim memory claim, + bytes memory proofData + ) public pure returns (SismoConnectResponse memory) { + SismoConnectProof[] memory proofs = new SismoConnectProof[](1); + proofs[0] = ProofBuilder.build({claim: claim, proofData: proofData}); + SismoConnectResponse memory responseWithProofs = build(response); + responseWithProofs.proofs = proofs; + return responseWithProofs; + } + + function withClaim( + ResponseWithoutProofs memory response, + Claim memory claim + ) external pure returns (SismoConnectResponse memory) { + return withClaim(response, claim, ""); + } + + //////////////////////////////// + // Empty structs // + ////////////////////////////// + + function emptyResponseWithoutProofs() external pure returns (ResponseWithoutProofs memory) { + return + ResponseWithoutProofs({ + appId: bytes16(0), + namespace: bytes16(0), + version: bytes32(0), + signedMessage: "" + }); + } + + function empty() external pure returns (SismoConnectResponse memory) { + SismoConnectProof[] memory proofs = new SismoConnectProof[](0); + return + SismoConnectResponse({ + appId: bytes16(0), + namespace: bytes16(0), + version: bytes32(0), + signedMessage: "", + proofs: proofs + }); + } +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..c942a1e --- /dev/null +++ b/yarn.lock @@ -0,0 +1,53 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@solidity-parser/parser@^0.16.0": + version "0.16.1" + resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.16.1.tgz#f7c8a686974e1536da0105466c4db6727311253c" + integrity sha512-PdhRFNhbTtu3x8Axm0uYpqOy/lODYQK+MlYSgqIsq2L8SFYEHJPHNUiOTAJbDGzNjjr1/n9AcIayxafR/fWmYw== + dependencies: + antlr4ts "^0.5.0-alpha.4" + +antlr4ts@^0.5.0-alpha.4: + version "0.5.0-alpha.4" + resolved "https://registry.yarnpkg.com/antlr4ts/-/antlr4ts-0.5.0-alpha.4.tgz#71702865a87478ed0b40c0709f422cf14d51652a" + integrity sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ== + +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + +prettier-plugin-solidity@^1.0.0-beta.13: + version "1.1.3" + resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.1.3.tgz#9a35124f578404caf617634a8cab80862d726cba" + integrity sha512-fQ9yucPi2sBbA2U2Xjh6m4isUTJ7S7QLc/XDDsktqqxYfTwdYKJ0EnnywXHwCGAaYbQNK+HIYPL1OemxuMsgeg== + dependencies: + "@solidity-parser/parser" "^0.16.0" + semver "^7.3.8" + solidity-comments-extractor "^0.0.7" + +prettier@^2.3.1: + version "2.8.8" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" + integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== + +semver@^7.3.8: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" + +solidity-comments-extractor@^0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz#99d8f1361438f84019795d928b931f4e5c39ca19" + integrity sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw== + +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==