-
Notifications
You must be signed in to change notification settings - Fork 22
docs: readme and contracts #722
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
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,26 +1,22 @@ | ||
| # Solidity Contracts | ||
|
|
||
| This directory contains the Solidity contracts for an application with [RISC Zero] on Ethereum. | ||
| The example contract included within the template is [`EvenNumber.sol`](./EvenNumber.sol). | ||
| It holds a number, guaranteed to be even. | ||
|
|
||
| The Solidity libraries for RISC Zero can be found at [github.com/risc0/risc0-ethereum]. | ||
| This directory contains the Solidity contracts for CRISP - Coercion-Resistant Impartial Selection Protocol. | ||
|
|
||
| Contracts are built and tested with [forge], which is part of the [Foundry] toolkit. | ||
| Tests are defined in the `tests` directory in the root of this template. | ||
|
|
||
| ## Generated Contracts | ||
| ## CRISP Program | ||
|
|
||
| This is the main logic of CRISP - an enclave program for secure voting. | ||
|
|
||
| It exposes two main functions: | ||
|
|
||
| * `validate` - that is called when a new E3 instance is requested on Enclave (`Enclave.request`). | ||
| * `verify` - that is called when the ciphertext output is published on Enclave (`Enclave.publishCiphertextOutput`). This function ensures that the ciphertext output is valid. CRISP uses Risc0 as the compute provider for running the FHE program, thus the proof will be a Risc0 proof. | ||
|
|
||
|
ctrlc03 marked this conversation as resolved.
|
||
| ## Input validator | ||
|
|
||
| As part of the build process, this template generates the `ImageID.sol` and `Elf.sol` contracts. | ||
| Running `cargo build --locked` will generate these contracts with up to date references to your guest code. | ||
| The input validator contract is used to validate the input data that is submitted to the E3 instance. It is called by the Enclave contract when a new input is published (`Enclave.publishInput`). In CRISP, the data providers (the ones submitting the inputs) are the voters, and the input submitted is the vote itself. | ||
|
|
||
| - `ImageID.sol`: contains the [Image IDs][image-id] for the guests implemented in the [methods] directory. | ||
| - `Elf.sol`: contains the path of the guest binaries implemented in the [methods] directory. | ||
| This contract is saved in the `tests` directory in the root of this template. | ||
| The validator will validate the input data by checking whether the gating conditions are satisifed (this uses Semaphore by default), and that the ciphertext is constructed correctly, using [Greco](https://github.com/gnosisguild/enclave/tree/main/packages/circuits/crates/libs/greco) ([link to paper(https://eprint.iacr.org/2024/594)]). | ||
|
ctrlc03 marked this conversation as resolved.
|
||
|
|
||
| [Foundry]: https://getfoundry.sh/ | ||
| [RISC Zero]: https://risczero.com | ||
| [forge]: https://github.com/foundry-rs/foundry#forge | ||
| [github.com/risc0/risc0-ethereum]: https://github.com/risc0/risc0-ethereum/tree/main/contracts | ||
| [image-id]: https://dev.risczero.com/terminology#image-id | ||
| [methods]: ../methods/README.md | ||
Oops, something went wrong.
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.