From 84f59ddcfde31bb549063f65b3f8ea19290f3c89 Mon Sep 17 00:00:00 2001 From: bigq Date: Thu, 27 Jul 2023 15:31:48 +0200 Subject: [PATCH] feat: add fork tests --- .github/workflows/forge.yml | 2 +- .gitmodules | 3 + lib/openzeppelin-contracts | 1 + package.json | 1 + remappings.txt | 3 +- src/SismoConnectLib.sol | 24 +- src/interfaces/IAuthRequestBuilder.sol | 94 ----- src/interfaces/IClaimRequestBuilder.sol | 170 --------- src/interfaces/IRequestBuilder.sol | 127 ------- src/interfaces/ISignatureBuilder.sol | 33 -- src/utils/AuthRequestBuilder.sol | 302 ++++++++++++++++ src/utils/ClaimRequestBuilder.sol | 453 ++++++++++++++++++++++++ src/utils/RequestBuilder.sol | 402 +++++++++++++++++++++ src/utils/SignatureBuilder.sol | 87 +++++ src/utils/SismoConnectProofBuilder.sol | 150 ++++++++ test/CheatSheet.t.sol | 26 -- test/base/BaseTest.t.sol | 20 +- test/fork/SismoConnectE2E.t.sol | 352 ++++++++++++++++++ test/fork/proofs/Proofs.sol | 270 ++++++++++++++ test/harness/SismoConnectHarness.sol | 108 ++++++ test/misc/UpgradeableExample.sol | 46 +++ test/misc/ZKDropERC721.sol | 60 ++++ test/utils/ResponseBuilderLib.sol | 283 +++++++++++++++ 23 files changed, 2547 insertions(+), 470 deletions(-) create mode 160000 lib/openzeppelin-contracts delete mode 100644 src/interfaces/IAuthRequestBuilder.sol delete mode 100644 src/interfaces/IClaimRequestBuilder.sol delete mode 100644 src/interfaces/IRequestBuilder.sol delete mode 100644 src/interfaces/ISignatureBuilder.sol create mode 100644 src/utils/AuthRequestBuilder.sol create mode 100644 src/utils/ClaimRequestBuilder.sol create mode 100644 src/utils/RequestBuilder.sol create mode 100644 src/utils/SignatureBuilder.sol create mode 100644 src/utils/SismoConnectProofBuilder.sol delete mode 100644 test/CheatSheet.t.sol create mode 100644 test/fork/SismoConnectE2E.t.sol create mode 100644 test/fork/proofs/Proofs.sol create mode 100644 test/harness/SismoConnectHarness.sol create mode 100644 test/misc/UpgradeableExample.sol create mode 100644 test/misc/ZKDropERC721.sol create mode 100644 test/utils/ResponseBuilderLib.sol diff --git a/.github/workflows/forge.yml b/.github/workflows/forge.yml index 147dc15..0174bb5 100644 --- a/.github/workflows/forge.yml +++ b/.github/workflows/forge.yml @@ -24,4 +24,4 @@ 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 + run: forge test --fork-url https://gateway.tenderly.co/public/polygon-mumbai -vvvv \ No newline at end of file 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/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 fe880b2..68806c9 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "prettier-plugin-solidity": "^1.0.0-beta.13" }, "scripts": { + "test": "forge test --fork-url https://gateway.tenderly.co/public/polygon-mumbai", "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/src/SismoConnectLib.sol b/src/SismoConnectLib.sol index 94b9bf6..f74ef6b 100644 --- a/src/SismoConnectLib.sol +++ b/src/SismoConnectLib.sol @@ -3,10 +3,10 @@ pragma solidity ^0.8.17; import {IAddressesProvider} from "./interfaces/IAddressesProvider.sol"; import {ISismoConnectVerifier, SismoConnectVerifiedResult} from "./interfaces/ISismoConnectVerifier.sol"; -import {IAuthRequestBuilder, AuthRequest, AuthType} from "./interfaces/IAuthRequestBuilder.sol"; -import {IClaimRequestBuilder, ClaimRequest, ClaimType} from "./interfaces/IClaimRequestBuilder.sol"; -import {ISignatureBuilder, SignatureRequest} from "./interfaces/ISignatureBuilder.sol"; -import {IRequestBuilder, AuthRequest, ClaimRequest, SignatureRequest, SismoConnectRequest} from "./interfaces/IRequestBuilder.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"; @@ -20,10 +20,10 @@ contract SismoConnect { ISismoConnectVerifier immutable _sismoConnectVerifier; // external libraries - IAuthRequestBuilder immutable _authRequestBuilder; - IClaimRequestBuilder immutable _claimRequestBuilder; - ISignatureBuilder immutable _signatureBuilder; - IRequestBuilder immutable _requestBuilder; + AuthRequestBuilder immutable _authRequestBuilder; + ClaimRequestBuilder immutable _claimRequestBuilder; + SignatureBuilder immutable _signatureBuilder; + RequestBuilder immutable _requestBuilder; // config bytes16 public immutable APP_ID; @@ -37,16 +37,16 @@ contract SismoConnect { ADDRESSES_PROVIDER_V2.get(string("sismoConnectVerifier-v1.2")) ); // external libraries - _authRequestBuilder = IAuthRequestBuilder( + _authRequestBuilder = AuthRequestBuilder( ADDRESSES_PROVIDER_V2.get(string("authRequestBuilder-v1.1")) ); - _claimRequestBuilder = IClaimRequestBuilder( + _claimRequestBuilder = ClaimRequestBuilder( ADDRESSES_PROVIDER_V2.get(string("claimRequestBuilder-v1.1")) ); - _signatureBuilder = ISignatureBuilder( + _signatureBuilder = SignatureBuilder( ADDRESSES_PROVIDER_V2.get(string("signatureBuilder-v1.1")) ); - _requestBuilder = IRequestBuilder(ADDRESSES_PROVIDER_V2.get(string("requestBuilder-v1.1"))); + _requestBuilder = RequestBuilder(ADDRESSES_PROVIDER_V2.get(string("requestBuilder-v1.1"))); } // public function because it needs to be used by this contract and can be used by other contracts diff --git a/src/interfaces/IAuthRequestBuilder.sol b/src/interfaces/IAuthRequestBuilder.sol deleted file mode 100644 index 02a773d..0000000 --- a/src/interfaces/IAuthRequestBuilder.sol +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.17; - -import {AuthRequest, AuthType} from "../utils/Structs.sol"; - -interface IAuthRequestBuilder { - error InvalidUserIdAndIsSelectableByUserAuthType(); - error InvalidUserIdAndAuthType(); - - function build( - AuthType authType, - bool isAnon, - uint256 userId, - bool isOptional, - bool isSelectableByUser, - bytes memory extraData - ) external pure returns (AuthRequest memory); - - function build( - AuthType authType, - bool isAnon, - uint256 userId, - bytes memory extraData - ) external pure returns (AuthRequest memory); - - function build(AuthType authType) external pure returns (AuthRequest memory); - - function build(AuthType authType, bool isAnon) external pure returns (AuthRequest memory); - - function build(AuthType authType, uint256 userId) external pure returns (AuthRequest memory); - - function build( - AuthType authType, - bytes memory extraData - ) external pure returns (AuthRequest memory); - - function build( - AuthType authType, - bool isAnon, - uint256 userId - ) external pure returns (AuthRequest memory); - - function build( - AuthType authType, - bool isAnon, - bytes memory extraData - ) external pure returns (AuthRequest memory); - - function build( - AuthType authType, - uint256 userId, - bytes memory extraData - ) external pure returns (AuthRequest memory); - - // allow dev to choose for isOptional - // the user is ask to choose isSelectableByUser to avoid the function signature collision - // between build(AuthType authType, bool isOptional) and build(AuthType authType, bool isAnon) - - function build( - AuthType authType, - bool isOptional, - bool isSelectableByUser - ) external pure returns (AuthRequest memory); - - function build( - AuthType authType, - bool isOptional, - bool isSelectableByUser, - uint256 userId - ) external pure returns (AuthRequest memory); - - // the user is ask to choose isSelectableByUser to avoid the function signature collision - // between build(AuthType authType, bool isAnon, bool isOptional) and build(AuthType authType, bool isOptional, bool isSelectableByUser) - - function build( - AuthType authType, - bool isAnon, - bool isOptional, - bool isSelectableByUser - ) external pure returns (AuthRequest memory); - - function build( - AuthType authType, - uint256 userId, - bool isOptional - ) external pure returns (AuthRequest memory); - - function build( - AuthType authType, - bool isAnon, - uint256 userId, - bool isOptional - ) external pure returns (AuthRequest memory); -} diff --git a/src/interfaces/IClaimRequestBuilder.sol b/src/interfaces/IClaimRequestBuilder.sol deleted file mode 100644 index 92cac70..0000000 --- a/src/interfaces/IClaimRequestBuilder.sol +++ /dev/null @@ -1,170 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.17; - -import {ClaimRequest, ClaimType} from "../utils/Structs.sol"; - -interface IClaimRequestBuilder { - function build( - bytes16 groupId, - bytes16 groupTimestamp, - uint256 value, - ClaimType claimType, - bool isOptional, - bool isSelectableByUser, - bytes memory extraData - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - uint256 value, - ClaimType claimType, - bytes memory extraData - ) external pure returns (ClaimRequest memory); - - function build(bytes16 groupId) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - bytes16 groupTimestamp - ) external pure returns (ClaimRequest memory); - - function build(bytes16 groupId, uint256 value) external pure returns (ClaimRequest memory); - - function build(bytes16 groupId, ClaimType claimType) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - bytes memory extraData - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - uint256 value - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - ClaimType claimType - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - bytes memory extraData - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - uint256 value, - ClaimType claimType - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - uint256 value, - bytes memory extraData - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - ClaimType claimType, - bytes memory extraData - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - uint256 value, - ClaimType claimType - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - uint256 value, - bytes memory extraData - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - ClaimType claimType, - bytes memory extraData - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - uint256 value, - ClaimType claimType, - bytes memory extraData - ) external pure returns (ClaimRequest memory); - - // allow dev to choose for isOptional - // we force to also set isSelectableByUser - // otherwise function signatures would be colliding - // between build(bytes16 groupId, bool isOptional) and build(bytes16 groupId, bool isSelectableByUser) - // we keep this logic for all function signature combinations - - function build( - bytes16 groupId, - bool isOptional, - bool isSelectableByUser - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - bool isOptional, - bool isSelectableByUser - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - uint256 value, - bool isOptional, - bool isSelectableByUser - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - ClaimType claimType, - bool isOptional, - bool isSelectableByUser - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - uint256 value, - bool isOptional, - bool isSelectableByUser - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - ClaimType claimType, - bool isOptional, - bool isSelectableByUser - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - uint256 value, - ClaimType claimType, - bool isOptional, - bool isSelectableByUser - ) external pure returns (ClaimRequest memory); - - function build( - bytes16 groupId, - bytes16 groupTimestamp, - uint256 value, - ClaimType claimType, - bool isOptional, - bool isSelectableByUser - ) external pure returns (ClaimRequest memory); -} diff --git a/src/interfaces/IRequestBuilder.sol b/src/interfaces/IRequestBuilder.sol deleted file mode 100644 index ed5c82f..0000000 --- a/src/interfaces/IRequestBuilder.sol +++ /dev/null @@ -1,127 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.17; - -import {AuthRequest, ClaimRequest, SignatureRequest, SismoConnectRequest} from "../utils/Structs.sol"; - -interface IRequestBuilder { - function build( - AuthRequest memory auth, - ClaimRequest memory claim, - SignatureRequest memory signature, - bytes16 namespace - ) external pure returns (SismoConnectRequest memory); - - function build( - AuthRequest memory auth, - ClaimRequest memory claim, - bytes16 namespace - ) external view returns (SismoConnectRequest memory); - - function build( - ClaimRequest memory claim, - SignatureRequest memory signature, - bytes16 namespace - ) external pure returns (SismoConnectRequest memory); - - function build( - ClaimRequest memory claim, - bytes16 namespace - ) external view returns (SismoConnectRequest memory); - - function build( - AuthRequest memory auth, - SignatureRequest memory signature, - bytes16 namespace - ) external pure returns (SismoConnectRequest memory); - - function build( - AuthRequest memory auth, - bytes16 namespace - ) external view returns (SismoConnectRequest memory); - - function build( - AuthRequest memory auth, - ClaimRequest memory claim, - SignatureRequest memory signature - ) external pure returns (SismoConnectRequest memory); - - function build( - AuthRequest memory auth, - ClaimRequest memory claim - ) external view returns (SismoConnectRequest memory); - - function build( - AuthRequest memory auth, - SignatureRequest memory signature - ) external pure returns (SismoConnectRequest memory); - - function build(AuthRequest memory auth) external view returns (SismoConnectRequest memory); - - function build( - ClaimRequest memory claim, - SignatureRequest memory signature - ) external pure returns (SismoConnectRequest memory); - - function build(ClaimRequest memory claim) external view returns (SismoConnectRequest memory); - - // build with arrays for auths and claims - function build( - AuthRequest[] memory auths, - ClaimRequest[] memory claims, - SignatureRequest memory signature, - bytes16 namespace - ) external pure returns (SismoConnectRequest memory); - - function build( - AuthRequest[] memory auths, - ClaimRequest[] memory claims, - bytes16 namespace - ) external view returns (SismoConnectRequest memory); - - function build( - ClaimRequest[] memory claims, - SignatureRequest memory signature, - bytes16 namespace - ) external pure returns (SismoConnectRequest memory); - - function build( - ClaimRequest[] memory claims, - bytes16 namespace - ) external view returns (SismoConnectRequest memory); - - function build( - AuthRequest[] memory auths, - SignatureRequest memory signature, - bytes16 namespace - ) external pure returns (SismoConnectRequest memory); - - function build( - AuthRequest[] memory auths, - bytes16 namespace - ) external view returns (SismoConnectRequest memory); - - function build( - AuthRequest[] memory auths, - ClaimRequest[] memory claims, - SignatureRequest memory signature - ) external pure returns (SismoConnectRequest memory); - - function build( - AuthRequest[] memory auths, - ClaimRequest[] memory claims - ) external view returns (SismoConnectRequest memory); - - function build( - AuthRequest[] memory auths, - SignatureRequest memory signature - ) external pure returns (SismoConnectRequest memory); - - function build(AuthRequest[] memory auths) external view returns (SismoConnectRequest memory); - - function build( - ClaimRequest[] memory claims, - SignatureRequest memory signature - ) external pure returns (SismoConnectRequest memory); - - function build(ClaimRequest[] memory claims) external view returns (SismoConnectRequest memory); -} diff --git a/src/interfaces/ISignatureBuilder.sol b/src/interfaces/ISignatureBuilder.sol deleted file mode 100644 index 2e3b78e..0000000 --- a/src/interfaces/ISignatureBuilder.sol +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.17; - -import {SignatureRequest} from "../utils/Structs.sol"; - -interface ISignatureBuilder { - function build(bytes memory message) external pure returns (SignatureRequest memory); - - function build( - bytes memory message, - bool isSelectableByUser - ) external pure returns (SignatureRequest memory); - - function build( - bytes memory message, - bytes memory extraData - ) external pure returns (SignatureRequest memory); - - function build( - bytes memory message, - bool isSelectableByUser, - bytes memory extraData - ) external pure returns (SignatureRequest memory); - - function build(bool isSelectableByUser) external pure returns (SignatureRequest memory); - - function build( - bool isSelectableByUser, - bytes memory extraData - ) external pure returns (SignatureRequest memory); - - function buildEmpty() external pure returns (SignatureRequest memory); -} diff --git a/src/utils/AuthRequestBuilder.sol b/src/utils/AuthRequestBuilder.sol new file mode 100644 index 0000000..68886c6 --- /dev/null +++ b/src/utils/AuthRequestBuilder.sol @@ -0,0 +1,302 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "./Structs.sol"; + +contract AuthRequestBuilder { + // default values for Auth Request + bool public constant DEFAULT_AUTH_REQUEST_IS_ANON = false; + uint256 public constant DEFAULT_AUTH_REQUEST_USER_ID = 0; + bool public constant DEFAULT_AUTH_REQUEST_IS_OPTIONAL = false; + bytes public constant DEFAULT_AUTH_REQUEST_EXTRA_DATA = ""; + + error InvalidUserIdAndIsSelectableByUserAuthType(); + error InvalidUserIdAndAuthType(); + + function build( + AuthType authType, + bool isAnon, + uint256 userId, + bool isOptional, + bool isSelectableByUser, + bytes memory extraData + ) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: isAnon, + userId: userId, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: extraData + }); + } + + function build( + AuthType authType, + bool isAnon, + uint256 userId, + bytes memory extraData + ) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: isAnon, + userId: userId, + isOptional: DEFAULT_AUTH_REQUEST_IS_OPTIONAL, + extraData: extraData + }); + } + + function build(AuthType authType) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: DEFAULT_AUTH_REQUEST_IS_ANON, + userId: DEFAULT_AUTH_REQUEST_USER_ID, + isOptional: DEFAULT_AUTH_REQUEST_IS_OPTIONAL, + extraData: DEFAULT_AUTH_REQUEST_EXTRA_DATA + }); + } + + function build(AuthType authType, bool isAnon) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: isAnon, + userId: DEFAULT_AUTH_REQUEST_USER_ID, + isOptional: DEFAULT_AUTH_REQUEST_IS_OPTIONAL, + extraData: DEFAULT_AUTH_REQUEST_EXTRA_DATA + }); + } + + function build(AuthType authType, uint256 userId) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: DEFAULT_AUTH_REQUEST_IS_ANON, + userId: userId, + isOptional: DEFAULT_AUTH_REQUEST_IS_OPTIONAL, + extraData: DEFAULT_AUTH_REQUEST_EXTRA_DATA + }); + } + + function build( + AuthType authType, + bytes memory extraData + ) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: DEFAULT_AUTH_REQUEST_IS_ANON, + userId: DEFAULT_AUTH_REQUEST_USER_ID, + isOptional: DEFAULT_AUTH_REQUEST_IS_OPTIONAL, + extraData: extraData + }); + } + + function build( + AuthType authType, + bool isAnon, + uint256 userId + ) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: isAnon, + userId: userId, + isOptional: DEFAULT_AUTH_REQUEST_IS_OPTIONAL, + extraData: DEFAULT_AUTH_REQUEST_EXTRA_DATA + }); + } + + function build( + AuthType authType, + bool isAnon, + bytes memory extraData + ) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: isAnon, + userId: DEFAULT_AUTH_REQUEST_USER_ID, + isOptional: DEFAULT_AUTH_REQUEST_IS_OPTIONAL, + extraData: extraData + }); + } + + function build( + AuthType authType, + uint256 userId, + bytes memory extraData + ) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: DEFAULT_AUTH_REQUEST_IS_ANON, + userId: userId, + isOptional: DEFAULT_AUTH_REQUEST_IS_OPTIONAL, + extraData: extraData + }); + } + + // allow dev to choose for isOptional + // the user is ask to choose isSelectableByUser to avoid the function signature collision + // between build(AuthType authType, bool isOptional) and build(AuthType authType, bool isAnon) + + function build( + AuthType authType, + bool isOptional, + bool isSelectableByUser + ) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: DEFAULT_AUTH_REQUEST_IS_ANON, + userId: DEFAULT_AUTH_REQUEST_USER_ID, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: DEFAULT_AUTH_REQUEST_EXTRA_DATA + }); + } + + function build( + AuthType authType, + bool isOptional, + bool isSelectableByUser, + uint256 userId + ) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: DEFAULT_AUTH_REQUEST_IS_ANON, + userId: userId, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: DEFAULT_AUTH_REQUEST_EXTRA_DATA + }); + } + + // the user is ask to choose isSelectableByUser to avoid the function signature collision + // between build(AuthType authType, bool isAnon, bool isOptional) and build(AuthType authType, bool isOptional, bool isSelectableByUser) + + function build( + AuthType authType, + bool isAnon, + bool isOptional, + bool isSelectableByUser + ) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: isAnon, + userId: DEFAULT_AUTH_REQUEST_USER_ID, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: DEFAULT_AUTH_REQUEST_EXTRA_DATA + }); + } + + function build( + AuthType authType, + uint256 userId, + bool isOptional + ) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: DEFAULT_AUTH_REQUEST_IS_ANON, + userId: userId, + isOptional: isOptional, + extraData: DEFAULT_AUTH_REQUEST_EXTRA_DATA + }); + } + + function build( + AuthType authType, + bool isAnon, + uint256 userId, + bool isOptional + ) external pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: isAnon, + userId: userId, + isOptional: isOptional, + extraData: DEFAULT_AUTH_REQUEST_EXTRA_DATA + }); + } + + function _build( + AuthType authType, + bool isAnon, + uint256 userId, + bool isOptional, + bytes memory extraData + ) internal pure returns (AuthRequest memory) { + return + _build({ + authType: authType, + isAnon: isAnon, + userId: userId, + isOptional: isOptional, + isSelectableByUser: _authIsSelectableDefaultValue(authType, userId), + extraData: extraData + }); + } + + function _build( + AuthType authType, + bool isAnon, + uint256 userId, + bool isOptional, + bool isSelectableByUser, + bytes memory extraData + ) internal pure returns (AuthRequest memory) { + // 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. + // If this combination is detected, the function will revert with an error. + if (authType != AuthType.VAULT && userId == 0 && isSelectableByUser == false) { + revert InvalidUserIdAndIsSelectableByUserAuthType(); + } + // When requesting an authType VAULT, the `userId` must be 0 and isSelectableByUser must be true. + if (authType == AuthType.VAULT && userId != 0 && isSelectableByUser == false) { + revert InvalidUserIdAndAuthType(); + } + return + AuthRequest({ + authType: authType, + isAnon: isAnon, + userId: userId, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: extraData + }); + } + + function _authIsSelectableDefaultValue( + AuthType authType, + uint256 requestedUserId + ) internal pure returns (bool) { + // isSelectableByUser value should always be false in case of VAULT authType. + // This is because the user can't select the account they want to use for the app. + // the userId = Hash(VaultSecret, AppId) in the case of VAULT authType. + if (authType == AuthType.VAULT) { + return false; + } + // When `requestedUserId` is 0, it means no specific auth account is requested by the app, + // so we want the default value for `isSelectableByUser` to be `true`. + if (requestedUserId == 0) { + return true; + } + // When `requestedUserId` is not 0, it means a specific auth account is requested by the app, + // so we want the default value for `isSelectableByUser` to be `false`. + else { + return false; + } + // However, the dev can still override this default value by setting `isSelectableByUser` to `true`. + } +} diff --git a/src/utils/ClaimRequestBuilder.sol b/src/utils/ClaimRequestBuilder.sol new file mode 100644 index 0000000..c415d00 --- /dev/null +++ b/src/utils/ClaimRequestBuilder.sol @@ -0,0 +1,453 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "./Structs.sol"; + +contract ClaimRequestBuilder { + // default value for Claim Request + bytes16 public constant DEFAULT_CLAIM_REQUEST_GROUP_TIMESTAMP = bytes16("latest"); + uint256 public constant DEFAULT_CLAIM_REQUEST_VALUE = 1; + ClaimType public constant DEFAULT_CLAIM_REQUEST_TYPE = ClaimType.GTE; + bool public constant DEFAULT_CLAIM_REQUEST_IS_OPTIONAL = false; + bool public constant DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER = true; + bytes public constant DEFAULT_CLAIM_REQUEST_EXTRA_DATA = ""; + + function build( + bytes16 groupId, + bytes16 groupTimestamp, + uint256 value, + ClaimType claimType, + bool isOptional, + bool isSelectableByUser, + bytes memory extraData + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + claimType: claimType, + groupId: groupId, + groupTimestamp: groupTimestamp, + value: value, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: extraData + }); + } + + function build( + bytes16 groupId, + bytes16 groupTimestamp, + uint256 value, + ClaimType claimType, + bytes memory extraData + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + claimType: claimType, + groupId: groupId, + groupTimestamp: groupTimestamp, + value: value, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: extraData + }); + } + + function build(bytes16 groupId) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: DEFAULT_CLAIM_REQUEST_GROUP_TIMESTAMP, + value: DEFAULT_CLAIM_REQUEST_VALUE, + claimType: DEFAULT_CLAIM_REQUEST_TYPE, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes16 groupId, + bytes16 groupTimestamp + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: groupTimestamp, + value: DEFAULT_CLAIM_REQUEST_VALUE, + claimType: DEFAULT_CLAIM_REQUEST_TYPE, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build(bytes16 groupId, uint256 value) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: DEFAULT_CLAIM_REQUEST_GROUP_TIMESTAMP, + value: value, + claimType: DEFAULT_CLAIM_REQUEST_TYPE, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build(bytes16 groupId, ClaimType claimType) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: DEFAULT_CLAIM_REQUEST_GROUP_TIMESTAMP, + value: DEFAULT_CLAIM_REQUEST_VALUE, + claimType: claimType, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes16 groupId, + bytes memory extraData + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: DEFAULT_CLAIM_REQUEST_GROUP_TIMESTAMP, + value: DEFAULT_CLAIM_REQUEST_VALUE, + claimType: DEFAULT_CLAIM_REQUEST_TYPE, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: extraData + }); + } + + function build( + bytes16 groupId, + bytes16 groupTimestamp, + uint256 value + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: groupTimestamp, + value: value, + claimType: DEFAULT_CLAIM_REQUEST_TYPE, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes16 groupId, + bytes16 groupTimestamp, + ClaimType claimType + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: groupTimestamp, + value: DEFAULT_CLAIM_REQUEST_VALUE, + claimType: claimType, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes16 groupId, + bytes16 groupTimestamp, + bytes memory extraData + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: groupTimestamp, + value: DEFAULT_CLAIM_REQUEST_VALUE, + claimType: DEFAULT_CLAIM_REQUEST_TYPE, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: extraData + }); + } + + function build( + bytes16 groupId, + uint256 value, + ClaimType claimType + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: DEFAULT_CLAIM_REQUEST_GROUP_TIMESTAMP, + value: value, + claimType: claimType, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes16 groupId, + uint256 value, + bytes memory extraData + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: DEFAULT_CLAIM_REQUEST_GROUP_TIMESTAMP, + value: value, + claimType: DEFAULT_CLAIM_REQUEST_TYPE, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: extraData + }); + } + + function build( + bytes16 groupId, + ClaimType claimType, + bytes memory extraData + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: DEFAULT_CLAIM_REQUEST_GROUP_TIMESTAMP, + value: DEFAULT_CLAIM_REQUEST_VALUE, + claimType: claimType, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: extraData + }); + } + + function build( + bytes16 groupId, + bytes16 groupTimestamp, + uint256 value, + ClaimType claimType + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: groupTimestamp, + value: value, + claimType: claimType, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes16 groupId, + bytes16 groupTimestamp, + uint256 value, + bytes memory extraData + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: groupTimestamp, + value: value, + claimType: DEFAULT_CLAIM_REQUEST_TYPE, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: extraData + }); + } + + function build( + bytes16 groupId, + bytes16 groupTimestamp, + ClaimType claimType, + bytes memory extraData + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: groupTimestamp, + value: DEFAULT_CLAIM_REQUEST_VALUE, + claimType: claimType, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: extraData + }); + } + + function build( + bytes16 groupId, + uint256 value, + ClaimType claimType, + bytes memory extraData + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: DEFAULT_CLAIM_REQUEST_GROUP_TIMESTAMP, + value: value, + claimType: claimType, + isOptional: DEFAULT_CLAIM_REQUEST_IS_OPTIONAL, + isSelectableByUser: DEFAULT_CLAIM_REQUEST_IS_SELECTABLE_BY_USER, + extraData: extraData + }); + } + + // allow dev to choose for isOptional + // we force to also set isSelectableByUser + // otherwise function signatures would be colliding + // between build(bytes16 groupId, bool isOptional) and build(bytes16 groupId, bool isSelectableByUser) + // we keep this logic for all function signature combinations + + function build( + bytes16 groupId, + bool isOptional, + bool isSelectableByUser + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: DEFAULT_CLAIM_REQUEST_GROUP_TIMESTAMP, + value: DEFAULT_CLAIM_REQUEST_VALUE, + claimType: DEFAULT_CLAIM_REQUEST_TYPE, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes16 groupId, + bytes16 groupTimestamp, + bool isOptional, + bool isSelectableByUser + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: groupTimestamp, + value: DEFAULT_CLAIM_REQUEST_VALUE, + claimType: DEFAULT_CLAIM_REQUEST_TYPE, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes16 groupId, + uint256 value, + bool isOptional, + bool isSelectableByUser + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: DEFAULT_CLAIM_REQUEST_GROUP_TIMESTAMP, + value: value, + claimType: DEFAULT_CLAIM_REQUEST_TYPE, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes16 groupId, + ClaimType claimType, + bool isOptional, + bool isSelectableByUser + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: DEFAULT_CLAIM_REQUEST_GROUP_TIMESTAMP, + value: DEFAULT_CLAIM_REQUEST_VALUE, + claimType: claimType, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes16 groupId, + bytes16 groupTimestamp, + uint256 value, + bool isOptional, + bool isSelectableByUser + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: groupTimestamp, + value: value, + claimType: DEFAULT_CLAIM_REQUEST_TYPE, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes16 groupId, + bytes16 groupTimestamp, + ClaimType claimType, + bool isOptional, + bool isSelectableByUser + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: groupTimestamp, + value: DEFAULT_CLAIM_REQUEST_VALUE, + claimType: claimType, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes16 groupId, + uint256 value, + ClaimType claimType, + bool isOptional, + bool isSelectableByUser + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: DEFAULT_CLAIM_REQUEST_GROUP_TIMESTAMP, + value: value, + claimType: claimType, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes16 groupId, + bytes16 groupTimestamp, + uint256 value, + ClaimType claimType, + bool isOptional, + bool isSelectableByUser + ) external pure returns (ClaimRequest memory) { + return + ClaimRequest({ + groupId: groupId, + groupTimestamp: groupTimestamp, + value: value, + claimType: claimType, + isOptional: isOptional, + isSelectableByUser: isSelectableByUser, + extraData: DEFAULT_CLAIM_REQUEST_EXTRA_DATA + }); + } +} diff --git a/src/utils/RequestBuilder.sol b/src/utils/RequestBuilder.sol new file mode 100644 index 0000000..76199ad --- /dev/null +++ b/src/utils/RequestBuilder.sol @@ -0,0 +1,402 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "./Structs.sol"; +import {SignatureBuilder} from "./SignatureBuilder.sol"; + +contract RequestBuilder { + // default value for namespace + bytes16 public constant DEFAULT_NAMESPACE = bytes16(keccak256("main")); + // default value for a signature request + SignatureRequest DEFAULT_SIGNATURE_REQUEST = + SignatureRequest({ + message: "MESSAGE_SELECTED_BY_USER", + isSelectableByUser: false, + extraData: "" + }); + + function build( + AuthRequest memory auth, + ClaimRequest memory claim, + SignatureRequest memory signature, + bytes16 namespace + ) external pure returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](1); + auths[0] = auth; + ClaimRequest[] memory claims = new ClaimRequest[](1); + claims[0] = claim; + return ( + SismoConnectRequest({ + namespace: namespace, + auths: auths, + claims: claims, + signature: signature + }) + ); + } + + function build( + AuthRequest memory auth, + ClaimRequest memory claim, + bytes16 namespace + ) external view returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](1); + auths[0] = auth; + ClaimRequest[] memory claims = new ClaimRequest[](1); + claims[0] = claim; + return ( + SismoConnectRequest({ + namespace: namespace, + auths: auths, + claims: claims, + signature: DEFAULT_SIGNATURE_REQUEST + }) + ); + } + + function build( + ClaimRequest memory claim, + SignatureRequest memory signature, + bytes16 namespace + ) external pure returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](0); + ClaimRequest[] memory claims = new ClaimRequest[](1); + claims[0] = claim; + return ( + SismoConnectRequest({ + namespace: namespace, + auths: auths, + claims: claims, + signature: signature + }) + ); + } + + function build( + ClaimRequest memory claim, + bytes16 namespace + ) external view returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](0); + ClaimRequest[] memory claims = new ClaimRequest[](1); + claims[0] = claim; + return ( + SismoConnectRequest({ + namespace: namespace, + auths: auths, + claims: claims, + signature: DEFAULT_SIGNATURE_REQUEST + }) + ); + } + + function build( + AuthRequest memory auth, + SignatureRequest memory signature, + bytes16 namespace + ) external pure returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](1); + auths[0] = auth; + ClaimRequest[] memory claims = new ClaimRequest[](0); + return ( + SismoConnectRequest({ + namespace: namespace, + auths: auths, + claims: claims, + signature: signature + }) + ); + } + + function build( + AuthRequest memory auth, + bytes16 namespace + ) external view returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](1); + auths[0] = auth; + ClaimRequest[] memory claims = new ClaimRequest[](0); + return ( + SismoConnectRequest({ + namespace: namespace, + auths: auths, + claims: claims, + signature: DEFAULT_SIGNATURE_REQUEST + }) + ); + } + + function build( + AuthRequest memory auth, + ClaimRequest memory claim, + SignatureRequest memory signature + ) external pure returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](1); + auths[0] = auth; + ClaimRequest[] memory claims = new ClaimRequest[](1); + claims[0] = claim; + return ( + SismoConnectRequest({ + namespace: DEFAULT_NAMESPACE, + auths: auths, + claims: claims, + signature: signature + }) + ); + } + + function build( + AuthRequest memory auth, + ClaimRequest memory claim + ) external view returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](1); + auths[0] = auth; + ClaimRequest[] memory claims = new ClaimRequest[](1); + claims[0] = claim; + return ( + SismoConnectRequest({ + namespace: DEFAULT_NAMESPACE, + auths: auths, + claims: claims, + signature: DEFAULT_SIGNATURE_REQUEST + }) + ); + } + + function build( + AuthRequest memory auth, + SignatureRequest memory signature + ) external pure returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](1); + auths[0] = auth; + ClaimRequest[] memory claims = new ClaimRequest[](0); + return ( + SismoConnectRequest({ + namespace: DEFAULT_NAMESPACE, + auths: auths, + claims: claims, + signature: signature + }) + ); + } + + function build(AuthRequest memory auth) external view returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](1); + auths[0] = auth; + ClaimRequest[] memory claims = new ClaimRequest[](0); + return ( + SismoConnectRequest({ + namespace: DEFAULT_NAMESPACE, + auths: auths, + claims: claims, + signature: DEFAULT_SIGNATURE_REQUEST + }) + ); + } + + function build( + ClaimRequest memory claim, + SignatureRequest memory signature + ) external pure returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](0); + ClaimRequest[] memory claims = new ClaimRequest[](1); + claims[0] = claim; + return ( + SismoConnectRequest({ + namespace: DEFAULT_NAMESPACE, + auths: auths, + claims: claims, + signature: signature + }) + ); + } + + function build(ClaimRequest memory claim) external view returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](0); + ClaimRequest[] memory claims = new ClaimRequest[](1); + claims[0] = claim; + return ( + SismoConnectRequest({ + namespace: DEFAULT_NAMESPACE, + auths: auths, + claims: claims, + signature: DEFAULT_SIGNATURE_REQUEST + }) + ); + } + + // build with arrays for auths and claims + function build( + AuthRequest[] memory auths, + ClaimRequest[] memory claims, + SignatureRequest memory signature, + bytes16 namespace + ) external pure returns (SismoConnectRequest memory) { + return ( + SismoConnectRequest({ + namespace: namespace, + auths: auths, + claims: claims, + signature: signature + }) + ); + } + + function build( + AuthRequest[] memory auths, + ClaimRequest[] memory claims, + bytes16 namespace + ) external view returns (SismoConnectRequest memory) { + return ( + SismoConnectRequest({ + namespace: namespace, + auths: auths, + claims: claims, + signature: DEFAULT_SIGNATURE_REQUEST + }) + ); + } + + function build( + ClaimRequest[] memory claims, + SignatureRequest memory signature, + bytes16 namespace + ) external pure returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](0); + return ( + SismoConnectRequest({ + namespace: namespace, + auths: auths, + claims: claims, + signature: signature + }) + ); + } + + function build( + ClaimRequest[] memory claims, + bytes16 namespace + ) external view returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](0); + return ( + SismoConnectRequest({ + namespace: namespace, + auths: auths, + claims: claims, + signature: DEFAULT_SIGNATURE_REQUEST + }) + ); + } + + function build( + AuthRequest[] memory auths, + SignatureRequest memory signature, + bytes16 namespace + ) external pure returns (SismoConnectRequest memory) { + ClaimRequest[] memory claims = new ClaimRequest[](0); + return ( + SismoConnectRequest({ + namespace: namespace, + auths: auths, + claims: claims, + signature: signature + }) + ); + } + + function build( + AuthRequest[] memory auths, + bytes16 namespace + ) external view returns (SismoConnectRequest memory) { + ClaimRequest[] memory claims = new ClaimRequest[](0); + return ( + SismoConnectRequest({ + namespace: namespace, + auths: auths, + claims: claims, + signature: DEFAULT_SIGNATURE_REQUEST + }) + ); + } + + function build( + AuthRequest[] memory auths, + ClaimRequest[] memory claims, + SignatureRequest memory signature + ) external pure returns (SismoConnectRequest memory) { + return ( + SismoConnectRequest({ + namespace: DEFAULT_NAMESPACE, + auths: auths, + claims: claims, + signature: signature + }) + ); + } + + function build( + AuthRequest[] memory auths, + ClaimRequest[] memory claims + ) external view returns (SismoConnectRequest memory) { + return ( + SismoConnectRequest({ + namespace: DEFAULT_NAMESPACE, + auths: auths, + claims: claims, + signature: DEFAULT_SIGNATURE_REQUEST + }) + ); + } + + function build( + AuthRequest[] memory auths, + SignatureRequest memory signature + ) external pure returns (SismoConnectRequest memory) { + ClaimRequest[] memory claims = new ClaimRequest[](0); + return ( + SismoConnectRequest({ + namespace: DEFAULT_NAMESPACE, + auths: auths, + claims: claims, + signature: signature + }) + ); + } + + function build(AuthRequest[] memory auths) external view returns (SismoConnectRequest memory) { + ClaimRequest[] memory claims = new ClaimRequest[](0); + return ( + SismoConnectRequest({ + namespace: DEFAULT_NAMESPACE, + auths: auths, + claims: claims, + signature: DEFAULT_SIGNATURE_REQUEST + }) + ); + } + + function build( + ClaimRequest[] memory claims, + SignatureRequest memory signature + ) external pure returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](0); + return ( + SismoConnectRequest({ + namespace: DEFAULT_NAMESPACE, + auths: auths, + claims: claims, + signature: signature + }) + ); + } + + function build(ClaimRequest[] memory claims) external view returns (SismoConnectRequest memory) { + AuthRequest[] memory auths = new AuthRequest[](0); + return ( + SismoConnectRequest({ + namespace: DEFAULT_NAMESPACE, + auths: auths, + claims: claims, + signature: DEFAULT_SIGNATURE_REQUEST + }) + ); + } +} diff --git a/src/utils/SignatureBuilder.sol b/src/utils/SignatureBuilder.sol new file mode 100644 index 0000000..c74c300 --- /dev/null +++ b/src/utils/SignatureBuilder.sol @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "./Structs.sol"; + +contract SignatureBuilder { + // default values for Signature Request + bytes public constant DEFAULT_SIGNATURE_REQUEST_MESSAGE = "MESSAGE_SELECTED_BY_USER"; + bool public constant DEFAULT_SIGNATURE_REQUEST_IS_SELECTABLE_BY_USER = false; + bytes public constant DEFAULT_SIGNATURE_REQUEST_EXTRA_DATA = ""; + + function build(bytes memory message) external pure returns (SignatureRequest memory) { + return + SignatureRequest({ + message: message, + isSelectableByUser: DEFAULT_SIGNATURE_REQUEST_IS_SELECTABLE_BY_USER, + extraData: DEFAULT_SIGNATURE_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes memory message, + bool isSelectableByUser + ) external pure returns (SignatureRequest memory) { + return + SignatureRequest({ + message: message, + isSelectableByUser: isSelectableByUser, + extraData: DEFAULT_SIGNATURE_REQUEST_EXTRA_DATA + }); + } + + function build( + bytes memory message, + bytes memory extraData + ) external pure returns (SignatureRequest memory) { + return + SignatureRequest({ + message: message, + isSelectableByUser: DEFAULT_SIGNATURE_REQUEST_IS_SELECTABLE_BY_USER, + extraData: extraData + }); + } + + function build( + bytes memory message, + bool isSelectableByUser, + bytes memory extraData + ) external pure returns (SignatureRequest memory) { + return + SignatureRequest({ + message: message, + isSelectableByUser: isSelectableByUser, + extraData: extraData + }); + } + + function build(bool isSelectableByUser) external pure returns (SignatureRequest memory) { + return + SignatureRequest({ + message: DEFAULT_SIGNATURE_REQUEST_MESSAGE, + isSelectableByUser: isSelectableByUser, + extraData: DEFAULT_SIGNATURE_REQUEST_EXTRA_DATA + }); + } + + function build( + bool isSelectableByUser, + bytes memory extraData + ) external pure returns (SignatureRequest memory) { + return + SignatureRequest({ + message: DEFAULT_SIGNATURE_REQUEST_MESSAGE, + isSelectableByUser: isSelectableByUser, + extraData: extraData + }); + } + + function buildEmpty() external pure returns (SignatureRequest memory) { + return + SignatureRequest({ + message: DEFAULT_SIGNATURE_REQUEST_MESSAGE, + isSelectableByUser: DEFAULT_SIGNATURE_REQUEST_IS_SELECTABLE_BY_USER, + extraData: DEFAULT_SIGNATURE_REQUEST_EXTRA_DATA + }); + } +} diff --git a/src/utils/SismoConnectProofBuilder.sol b/src/utils/SismoConnectProofBuilder.sol new file mode 100644 index 0000000..70e88f0 --- /dev/null +++ b/src/utils/SismoConnectProofBuilder.sol @@ -0,0 +1,150 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "./Structs.sol"; + +library ProofBuilder { + // default values for SismoConnect Proof + bytes32 public constant DEFAULT_PROOF_PROVING_SCHEME = bytes32("hydra-s3.1"); + bytes public constant DEFAULT_PROOF_EXTRA_DATA = ""; + + 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) { + 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: provingScheme, + extraData: DEFAULT_PROOF_EXTRA_DATA + }); + } + + function build( + Auth memory auth, + bytes memory proofData + ) 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: DEFAULT_PROOF_PROVING_SCHEME, + extraData: DEFAULT_PROOF_EXTRA_DATA + }); + } + + 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) { + Auth[] memory auths = new Auth[](0); + 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( + Claim memory claim, + bytes memory proofData, + bytes32 provingScheme + ) external pure returns (SismoConnectProof memory) { + Auth[] memory auths = new Auth[](0); + Claim[] memory claims = new Claim[](1); + claims[0] = claim; + return + SismoConnectProof({ + auths: auths, + claims: claims, + proofData: proofData, + provingScheme: provingScheme, + 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/CheatSheet.t.sol b/test/CheatSheet.t.sol deleted file mode 100644 index 2912d4e..0000000 --- a/test/CheatSheet.t.sol +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: Unlicense -pragma solidity ^0.8.17; - -import "forge-std/console.sol"; -import {BaseTest} from "test/base/BaseTest.t.sol"; -import {CheatSheet} from "test/misc/CheatSheet.sol"; -import "src/utils/Fmt.sol"; -import "src/utils/Structs.sol"; -import {AuthBuilder} from "src/utils/AuthBuilder.sol"; -import {ClaimBuilder} from "src/utils/ClaimBuilder.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 index cbe85c2..01dd142 100644 --- a/test/base/BaseTest.t.sol +++ b/test/base/BaseTest.t.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.17; import "forge-std/Test.sol"; import "forge-std/console.sol"; -import {IAddressesProvider} from "src/SismoConnectLib.sol"; +import {IAddressesProvider, AuthRequestBuilder, ClaimRequestBuilder, SignatureBuilder, RequestBuilder} from "src/SismoConnectLib.sol"; interface IAvailableRootsRegistry { event RegisteredRoot(uint256 root); @@ -16,13 +16,21 @@ interface IAvailableRootsRegistry { contract BaseTest is Test { IAddressesProvider sismoAddressesProvider = IAddressesProvider(0x3Cd5334eB64ebBd4003b72022CC25465f1BFcEe6); - IAvailableRootsRegistry availableRootsRegistry; + IAvailableRootsRegistry availableRootsRegistry = + IAvailableRootsRegistry( + sismoAddressesProvider.get(string("sismoConnectAvailableRootsRegistry")) + ); + + AuthRequestBuilder authRequestBuilder = + AuthRequestBuilder(sismoAddressesProvider.get(string("authRequestBuilder-v1.1"))); + ClaimRequestBuilder claimRequestBuilder = + ClaimRequestBuilder(sismoAddressesProvider.get(string("claimRequestBuilder-v1.1"))); + SignatureBuilder signatureBuilder = + SignatureBuilder(sismoAddressesProvider.get(string("signatureBuilder-v1.1"))); + RequestBuilder requestBuilder = + RequestBuilder(sismoAddressesProvider.get(string("requestBuilder-v1.1"))); 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); diff --git a/test/fork/SismoConnectE2E.t.sol b/test/fork/SismoConnectE2E.t.sol new file mode 100644 index 0000000..c738919 --- /dev/null +++ b/test/fork/SismoConnectE2E.t.sol @@ -0,0 +1,352 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity ^0.8.17; + +import "forge-std/console.sol"; +import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import {BaseTest} from "../base/BaseTest.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 is BaseTest { + using ResponseBuilder for SismoConnectResponse; + using ResponseBuilder for ResponseWithoutProofs; + + Proofs proofs = new Proofs(); + + 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; + + bytes16 immutable APP_ID_ZK_DROP = 0x11b1de449c6c4adb0b5775b3868b28b3; + bytes16 immutable SISMO_CONTRIBUTORS_GROUP_ID = 0xe9ed316946d3d98dfcd829a53ec9822e; + ZKDropERC721 zkdrop; + + CheatSheet cheatsheet; + + function setUp() public { + 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)}); + + 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 test_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 test_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 test_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 test_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 test_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 test_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 test_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 test_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 test_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 test_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 test_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 test_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 test_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 test_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..ceb8eda --- /dev/null +++ b/test/fork/proofs/Proofs.sol @@ -0,0 +1,270 @@ +// SPDX-License-Identifier: Unlicense +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..b506288 --- /dev/null +++ b/test/harness/SismoConnectHarness.sol @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: Unlicense +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/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 + }); + } +}