-
Notifications
You must be signed in to change notification settings - Fork 22
chore: allow mock input validator in CRISP #782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| VITE_ENCLAVE_API=http://127.0.0.1:4000 | ||
| VITE_TWITTER_SERVERLESS_API= | ||
| VITE_WALLETCONNECT_PROJECT_ID= | ||
| VITE_E3_PROGRAM_ADDRESS=0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1 # Default E3 program address from anvil | ||
| VITE_E3_PROGRAM_ADDRESS=0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44 # Default E3 program address from anvil | ||
| VITE_SEMAPHORE_ADDRESS=0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
examples/CRISP/contracts/Mocks/MockCRISPInputValidator.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // SPDX-License-Identifier: LGPL-3.0-only | ||
| // | ||
| // This file is provided WITHOUT ANY WARRANTY; | ||
| // without even the implied warranty of MERCHANTABILITY | ||
| // or FITNESS FOR A PARTICULAR PURPOSE. | ||
| pragma solidity >=0.8.27; | ||
|
|
||
| import {IInputValidator} from "@enclave-e3/contracts/contracts/interfaces/IInputValidator.sol"; | ||
| import {IBasePolicy} from "@excubiae/contracts/interfaces/IBasePolicy.sol"; | ||
| import {Clone} from "@excubiae/contracts/proxy/Clone.sol"; | ||
| import {IVerifier} from "../CRISPVerifier.sol"; | ||
|
|
||
| /// @title MockCRISPInputValidator. | ||
| /// @notice Mock Enclave Input Validator | ||
| contract MockCRISPInputValidator is IInputValidator, Clone { | ||
| /// @notice The policy that will be used to validate the input. | ||
| IBasePolicy internal policy; | ||
|
|
||
| /// @notice The verifier that will be used to validate the input. | ||
| IVerifier internal noirVerifier; | ||
|
|
||
| /// @notice The error emitted when the input data is empty. | ||
| error EmptyInputData(); | ||
| /// @notice The error emitted when the input data is invalid. | ||
| error InvalidInputData(bytes reason); | ||
| /// @notice The error emitted when the Noir proof is invalid. | ||
| error InvalidNoirProof(); | ||
|
|
||
| /// @notice Initializes the contract with appended bytes data for configuration. | ||
| function _initialize() internal virtual override(Clone) { | ||
| super._initialize(); | ||
|
|
||
| (address policyAddr, address verifierAddr) = abi.decode(_getAppendedBytes(), (address, address)); | ||
| policy = IBasePolicy(policyAddr); | ||
| noirVerifier = IVerifier(verifierAddr); | ||
| } | ||
|
|
||
| /// @notice Validates input | ||
| /// @param sender The account that is submitting the input. | ||
| /// @param data The input to be verified. | ||
| /// @return input The decoded, policy-approved application payload. | ||
| function validate(address sender, bytes memory data) external returns (bytes memory input) { | ||
| if (data.length == 0) revert EmptyInputData(); | ||
|
|
||
| (,,, bytes memory vote) = abi.decode(data, (bytes, bytes, bytes32[], bytes)); | ||
|
|
||
| input = vote; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.