-
Notifications
You must be signed in to change notification settings - Fork 22
docs: update template documentation #830
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
Show all changes
6 commits
Select commit
Hold shift + click to select a range
605ad2d
update docs for template
0xjei 3130ff9
Update templates/default/README.md
0xjei e3f7b23
Update templates/default/README.md
0xjei 2cce4f5
fix typo
0xjei 6c8842f
make explicit that risc0 is optional in dev mode
0xjei 50af1c6
Merge branch 'main' into docs/template
0xjei 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,144 +1,174 @@ | ||
| # Enclave Protocol Template Setup | ||
| # Template | ||
|
|
||
| The Enclave Protocol Template provides a complete development environment for building and testing applications with Fully Homomorphic Encryption (FHE). This template enables local deployment and interaction with the Enclave protocol without requiring the core contracts to be copied. | ||
| The Enclave Protocol Template provides a complete development environment for building and testing applications with Fully Homomorphic Encryption (FHE). This template enables local deployment and interaction with the Enclave protocol without requiring the core contracts to be copied and avoiding complexities of specific programs (as zk circuits for CRISP). | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Before getting started, ensure your development environment meets the following requirements: | ||
| Before getting started, ensure you have installed: | ||
|
|
||
| ### Required Software | ||
| - [Rust](https://rust-lang.org/tools/install/) | ||
| - [NodeJS](https://nodejs.org/en/download) | ||
| - [RiscZero](https://dev.risczero.com/api/zkvm/install) | ||
| - [pnpm](https://pnpm.io) | ||
| - [Metamask](https://metamask.io) | ||
|
|
||
| **Docker** (tested with version 25.0.6 or later) | ||
| As system requirements: | ||
|
|
||
| ```bash | ||
| docker --version | ||
| # Expected output: Docker version 25.0.6, build v25.0.6 | ||
| ``` | ||
| - Linux/POSIX environment | ||
| - For Nix users: A Nix flake is included in the generated template | ||
|
|
||
| **Node.js** (version 22.10.0 or later) | ||
| ## Quick Start | ||
|
|
||
| ```bash | ||
| node --version | ||
| # Expected output: v22.10.0 | ||
| ``` | ||
| ### (optional) Install RISC Zero Toolchain | ||
|
|
||
| **pnpm** (version 10.7.1 or later) | ||
| Next, install `rzup` for the `cargo-risczero` toolchain. | ||
|
|
||
| ```bash | ||
| pnpm --version | ||
| # Expected output: 10.7.1 | ||
| ```sh | ||
| # Install rzup | ||
| curl -L https://risczero.com/install | bash | ||
|
|
||
| # Install RISC Zero toolchain | ||
| rzup install cargo-risczero | ||
| ``` | ||
|
|
||
| **Rust** (version 1.86.0 or later) | ||
| Verify the installation was successful by running: | ||
|
|
||
| ```bash | ||
| rustc --version | ||
| # Expected output: rustc 1.86.0 (05f9846f8 2025-03-31) | ||
| ```sh | ||
| cargo risczero --version | ||
| ``` | ||
|
|
||
| ### Optional Software | ||
| At this point, you should have all the tools required to develop and deploy an application with | ||
| [RISC Zero](https://www.risczero.com). | ||
|
|
||
| **tmux** (recommended for managing multiple processes) | ||
| ### Install Metamask | ||
|
|
||
| ```bash | ||
| tmux -V | ||
| # Expected output: tmux 3.4 | ||
| ``` | ||
| You can add Metamask as an extension to your browser following the official | ||
| [documentation](https://metamask.io). | ||
|
|
||
| ### System Requirements | ||
| ### Install the Enclave CLI | ||
|
|
||
| - Linux/POSIX environment | ||
| - For Nix users: A Nix flake is included in the generated template | ||
| The easiest way to install the Enclave CLI is using our installer script: | ||
| `curl -fsSL https://raw.githubusercontent.com/gnosisguild/enclave/main/install | bash` | ||
|
|
||
| ## Installation | ||
| Or if you prefer wget: | ||
| `wget -qO- https://raw.githubusercontent.com/gnosisguild/enclave/main/install | bash` | ||
|
|
||
| ### 1. Install the Enclave CLI | ||
| This script will download and install enclaveup, which is the standalone installer for the Enclave CLI. | ||
|
|
||
| Install the Enclave CLI tool from the official repository: | ||
| Once you have `enclaveup` installed, you can manage your Enclave CLI installation: | ||
|
|
||
| ```bash | ||
| cargo install --git https://github.com/gnosisguild/enclave --branch main e3-cli | ||
| # Install to ~/.local/bin (default) | ||
| enclaveup install | ||
|
|
||
| # Install to /usr/local/bin (requires sudo) | ||
| enclaveup install --system | ||
| ``` | ||
|
|
||
| ### 2. Install wasm-pack | ||
| Running `enclaveup install` will install the latest version of the Enclave CLI. | ||
|
|
||
| Install wasm-pack for WebAssembly compilation: | ||
| After installation, verify that the Enclave CLI is working correctly: | ||
|
|
||
| ```bash | ||
| cargo install wasm-pack | ||
| ``` | ||
| `enclave --help` | ||
|
|
||
| ## Project Setup | ||
| You should see the help information for the Enclave CLI. | ||
|
|
||
| ### Generate a New Project | ||
| ### Create your Project | ||
|
|
||
| Create a new Enclave project using the CLI: | ||
| Generate a new E3 program from the default template: | ||
|
|
||
| ```bash | ||
| enclave init myenclave | ||
| cd ./myenclave | ||
| enclave init my-first-e3 | ||
| cd my-first-e3 | ||
| ``` | ||
|
|
||
| Replace `myenclave` with your desired project name. | ||
| This creates a complete E3 project with: | ||
|
|
||
| ### Project Structure | ||
| - **FHE computation logic** (`./program/`) | ||
| - **Smart contracts** (`./contracts/`) | ||
| - **Client application** (`./client/`) | ||
| - **Coordination server** (`./server/`) | ||
| - **Configuration** (`enclave.config.yaml`) | ||
|
|
||
| The generated project contains the following directories and files: | ||
| ### Compile your E3 Program | ||
|
|
||
| | File/Directory | Description | | ||
| | ----------------------- | -------------------------------------------------- | | ||
| | `./client` | Client-side application | | ||
| | `./contracts` | Your contracts that interact with the protocol | | ||
| | `./deploy` | Your deploy scripts | | ||
| | `./enclave.config.yaml` | Configuration for the enclave CLI | | ||
| | `./program` | FHE computation code | | ||
| | `./scripts` | Scripts to run the project | | ||
| | `./server` | TypeScript server that coordinates the FHE process | | ||
| First, compile your E3 program to build the Risc0 zkvm image: | ||
|
|
||
| ## Running the Development Environment | ||
| ```bash | ||
| enclave program compile | ||
| ``` | ||
|
|
||
| ### Start All Services | ||
| This builds the Risc0 zkvm image that will be deployed on the blockchain and used for verification of the final proof. | ||
|
|
||
| Launch the complete development stack with a single command: | ||
| If you want to avoid the proof or you have trouble with Risc0 zkvm installation, you can run it in dev mode (no proof). | ||
|
|
||
| ```bash | ||
| pnpm dev:all | ||
| enclave program start --dev true | ||
| ``` | ||
|
|
||
| or, if you have `tmux` installed: | ||
| ### Start the Development Environment | ||
|
|
||
| Launch all services with one command: | ||
|
|
||
| ```bash | ||
| pnpm dev:all --tmux | ||
| pnpm dev:all | ||
| ``` | ||
|
|
||
| ### What Happens Next | ||
| This starts: | ||
|
|
||
| - Local Ethereum network (Hardhat) | ||
| - Deploys all the smart contracts to the local network | ||
| - Multiple ciphernodes for FHE processing | ||
| - TypeScript coordination server | ||
| - FHE program server | ||
| - Frontend client application | ||
|
|
||
| **Wait for all services to start** (usually 30-60 seconds). | ||
|
|
||
| ### Access Your Application | ||
|
|
||
| 1. Open your browser to [http://localhost:3000](http://localhost:3000) | ||
| 2. Import the local development private key: `0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80` (DO NOT USE IN PRODUCTION) | ||
| 3. Configure MetaMask for local network development: | ||
|
0xjei marked this conversation as resolved.
|
||
| - Network: `http://localhost:8545` | ||
| - Chain ID: `31337` | ||
| 4. Switch to the network. | ||
|
0xjei marked this conversation as resolved.
|
||
|
|
||
| ### Test the FHE Computation | ||
|
|
||
| The default template includes a simple addition program that: | ||
|
|
||
| 1. **Encrypts** two numbers on the client | ||
| 2. **Computes** their sum using FHE (without decrypting) | ||
| 3. **Returns** the encrypted result | ||
| 4. **Decrypts** and displays the result | ||
|
|
||
| Try it: | ||
|
|
||
| The command will start multiple processes simultaneously: | ||
| - Input two numbers in the web interface | ||
| - Click "Submit" | ||
| - Watch the encrypted computation happen! | ||
|
|
||
| 1. **Hardhat EVM Node** - Local Ethereum development network | ||
| 2. **Enclave Ciphernodes** - Set of nodes for FHE processing | ||
| 3. **TypeScript Coordination Server** - Manages FHE process coordination | ||
| 4. **FHE Program Server** - Handles encrypted computation execution | ||
| 5. **Frontend Application** - User interface for interaction | ||
| ### What Just Happened? | ||
|
|
||
| ### Process Management | ||
| You successfully ran a **Fully Homomorphic Encryption** computation where: | ||
|
|
||
| - **With tmux installed**: Your terminal will split into multiple panes, each showing logs from different services | ||
| - **Without tmux**: You'll see a stream of logs from all processes in a single terminal | ||
| - Your inputs were encrypted before leaving the browser | ||
| - The computation happened on encrypted data | ||
| - The result was computed without exposing your private inputs | ||
| - All coordination was handled by the Enclave protocol | ||
|
|
||
| ### Accessing the Application | ||
| ## Manual Start | ||
|
|
||
| 1. **Wait for initialization**: Allow all processes to fully start and stabilize | ||
| 2. **Open your browser**: Navigate to [http://localhost:3000](http://localhost:3000) | ||
| 3. **Configure MetaMask**: Ensure MetaMask is installed and configured with a local network pointing to `http://localhost:8545` | ||
| If you prefer to install the Enclave CLI manually, please visit the dedicated section in the [documentation](https://docs.enclave.gg/installation#manual-installation). | ||
|
|
||
| ## Next Steps | ||
|
|
||
| Once your development environment is running, you can: | ||
| Now that you have a working E3 program: | ||
|
|
||
| - Modify the FHE computation logic in the `./program` directory | ||
| - Update smart contracts in the `./contracts` directory | ||
| - Customize the client application in the `./client` directory | ||
| - Configure deployment scripts in the `./deploy` directory | ||
| 1. **Explore the code**: Check out `./program/src/lib.rs` to see the FHE computation | ||
| 2. **Modify the computation**: Try changing the addition to multiplication | ||
| 3. **Update the UI**: Customize the client in `./client/src/` | ||
| 4. **Deploy**: Learn about production deployment | ||
|
|
||
| For detailed usage instructions and API documentation, refer to the project's README.md file and the official Enclave Protocol documentation. | ||
| Ready to dive deeper? Continue with our [Hello World Tutorial](https://docs.enclave.gg/hello-world-tutorial) for a step-by-step breakdown of building E3 programs from scratch. | ||
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.