Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[submodule "examples/CRISP/lib/risc0-ethereum"]
path = examples/CRISP/lib/risc0-ethereum
[submodule "examples/CRISP/packages/crisp-contracts/lib/risc0-ethereum"]
path = examples/CRISP/packages/crisp-contracts/lib/risc0-ethereum
url = https://github.com/risc0/risc0-ethereum
[submodule "templates/default/lib/risc0-ethereum"]
path = templates/default/lib/risc0-ethereum
Expand Down
2 changes: 1 addition & 1 deletion deploy/local/contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cargo install --locked --path ./crates/cli --bin enclave -f
(cd packages/enclave-contracts && rm -rf deployments/localhost && pnpm deploy:mocks --network localhost)

# Deploy CRISP Contracts
(cd examples/CRISP && ETH_WALLET_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 FOUNDRY_PROFILE=local forge script --rpc-url http://localhost:8545 --broadcast deploy/Deploy.s.sol)
(cd examples/CRISP/packages/crisp-contracts && ETH_WALLET_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 FOUNDRY_PROFILE=local forge script --rpc-url http://localhost:8545 --broadcast deploy/Deploy.s.sol)

# Add Ciphernodes to Enclave
sleep 2 # wait for enclave to start
Expand Down
2 changes: 1 addition & 1 deletion deploy/local/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ deploy_contracts() {

# Deploy CRISP contracts
echo " Deploying CRISP contracts..."
(cd examples/CRISP && ETH_WALLET_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 FOUNDRY_PROFILE=local forge script --rpc-url http://localhost:8545 --broadcast deploy/Deploy.s.sol)
(cd examples/CRISP/packages/crisp-contracts && ETH_WALLET_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 FOUNDRY_PROFILE=local forge script --rpc-url http://localhost:8545 --broadcast deploy/Deploy.s.sol)

# Wait a bit for nodes to be ready
sleep 5
Expand Down
10 changes: 0 additions & 10 deletions examples/CRISP/.vscode/settings.json

This file was deleted.

8 changes: 0 additions & 8 deletions examples/CRISP/CHANGELOG.md

This file was deleted.

50 changes: 13 additions & 37 deletions examples/CRISP/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ CRISP (Coercion-Resistant Impartial Selection Protocol) is a secure protocol for

## Project Structure

CRISP follows a modern structure with clear separation of concerns
CRISP follows a modern structure with clear separation of concerns, consistent with the Enclave root structure.

```bash
CRISP/
|── client/ # React frontend application
|── server/ # Rust coordination server
|── program/ # RISC Zero computation program
├── contracts/ # Smart contracts (Solidity)
|__ packages/ # JavaScript packages.
|__ crates/ # Rust crates.
├── circuits/ # Noir circuits for ZK proofs
├── scripts/ # Development and utility scripts
├── enclave.config.yaml # Ciphernode configuration
Expand Down Expand Up @@ -79,7 +80,7 @@ You need to setup your environment variables for `client/` and `server/`. Just c
### Client

```bash
VITE_E3_PROGRAM_ADDRESS=0x0B306BF915C4d645ff596e518fAf3F9669b97016 # Default E3 program address
VITE_E3_PROGRAM_ADDRESS=0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1 # Default E3 program address
```

### Server
Expand All @@ -88,7 +89,7 @@ VITE_E3_PROGRAM_ADDRESS=0x0B306BF915C4d645ff596e518fAf3F9669b97016 # Default E3
ENCLAVE_ADDRESS="0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"
CIPHERNODE_REGISTRY_ADDRESS="0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9"
NAIVE_REGISTRY_FILTER_ADDRESS="0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9"
E3_PROGRAM_ADDRESS="0x0B306BF915C4d645ff596e518fAf3F9669b97016" # CRISPProgram Contract Address
E3_PROGRAM_ADDRESS="0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1" # CRISPProgram Contract Address
```

These address will be displayed after successfully running the `pnpm dev:up` command in a log that will look like the following:
Expand All @@ -101,7 +102,7 @@ Verifier: 0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0
InputValidator: 0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6
CRISPInputValidatorFactory: 0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82
HonkVerifier: 0x9A676e781A523b5d0C0e43731313A708CB607508
CRISPProgram: 0x0B306BF915C4d645ff596e518fAf3F9669b97016
CRISPProgram: 0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1
```

If you find any inconsistency with the addresses on the environment, you must update them and run the script again (they must match).
Expand All @@ -111,18 +112,11 @@ If you find any inconsistency with the addresses on the environment, you must up
The fastest way to get CRISP running is using the scripts provided in the `scripts/` directory:

```bash
# Install dependencies
pnpm install

# Setup and build the development environment
pnpm dev:setup

# Start all services (Anvil, Ciphernodes, Applications)
pnpm dev:up

# Clean up all artifacts and generated output (e.g., builds)
# This must be run from enclave root (do cd ../../ if you are inside examples/CRISP)
pnpm clean
```

This will start all CRISP components:
Expand All @@ -133,14 +127,10 @@ This will start all CRISP components:
- Ciphernodes network
- CRISP applications (server, client)

```bash
# Build the development containers
pnpm dev:setup
Additionally, other specific commands are:

# Start all services
pnpm dev:up

# Rebuild containers
```bash
# Rebuild crates, compiles contracts and build the client app
pnpm dev:build

# Invoke the Server CLI
Expand All @@ -158,20 +148,6 @@ Once everything is running, you can:

## Manual Start

### Setting Up the project

1. Navigate to the root directory:

```sh
cd examples/CRISP
```

2. Install dependencies:

```sh
pnpm install
```

### Setting Up the Web App

To set up the CRISP dApp in your local environment, follow these steps:
Expand All @@ -192,15 +168,15 @@ To set up the CRISP dApp in your local environment, follow these steps:

Setting up the CRISP server involves several components, but this guide will walk you through each step.

### Step 1: Start a Local Testnet with Anvil
#### Step 1: Start a Local Testnet with Anvil

```sh
anvil
```

Keep Anvil running in the terminal, and open a new terminal for the next steps.

### Step 2: Setting Up the Ciphernodes
#### Step 2: Setting Up the Ciphernodes

1. Clone the [Enclave Repo](https://github.com/gnosisguild/enclave):

Expand Down Expand Up @@ -234,7 +210,7 @@ After deployment, you will see the addresses for the following contracts:
- CRISP Input Validator Factory
- CRISP Program

### Step 3: RISC0 Setup (Optional)
#### Step 3: RISC0 Setup (Optional)

> Please note that this step is optional for development only. You can run the program server in dev mode which does not use Risc0.
> The smart contracts would have already been deployed at the previous step.
Expand Down Expand Up @@ -263,7 +239,7 @@ The following steps are optional. You can config [Bonsai](https://dev.risczero.c

---

### Step 4: Set up Environment Variables
#### Step 4: Set up Environment Variables

Create a `.env` file in the `server` directory with the following:

Expand Down
4 changes: 3 additions & 1 deletion examples/CRISP/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ services:
- root-node-modules:/app/node_modules
- client-node-modules:/app/examples/CRISP/client/node_modules
- crisp-node-modules:/app/examples/CRISP/node_modules
- crisp-foundry-cache:/app/examples/CRISP/out
- crisp-contracts-node-modules:/app/examples/CRISP/packages/crisp-contracts/node_modules
- crisp-foundry-cache:/app/examples/CRISP/packages/crisp-contracts/out
- synpress-cache:/app/examples/CRISP/.cache-synpress
- test-results:/app/examples/CRISP/test-results
- playwright-report:/app/examples/CRISP/playwright-report
Expand All @@ -43,6 +44,7 @@ volumes:
root-node-modules:
client-node-modules:
crisp-node-modules:
crisp-contracts-node-modules:
crisp-foundry-cache:
git-folder:
synpress-cache:
Expand Down
1 change: 0 additions & 1 deletion examples/CRISP/lib/risc0-ethereum
Submodule risc0-ethereum deleted from 32aa0b
55 changes: 9 additions & 46 deletions examples/CRISP/package.json
Original file line number Diff line number Diff line change
@@ -1,75 +1,38 @@
{
"name": "crisp",
"version": "0.0.0",
"description": "CRISP - Coercion-Resistant Impartial Selection Protocol",
"repository": "https://github.com/gnosisguild/enclave",
"private": true,
"type": "module",
"description": "CRISP - Coercion-Resistant Impartial Selection Protocol",
"author": {
"name": "gnosisguild",
"url": "https://github.com/gnosisguild"
},
"scripts": {
"compile": "forge compile",
Comment thread
cedoor marked this conversation as resolved.
"ciphernode:add": "hardhat ciphernode:add",
Comment thread
cedoor marked this conversation as resolved.
"cli": "bash ./scripts/cli.sh",
"clean:deployments": "hardhat utils:clean-deployments",
"dev:setup": "bash ./scripts/setup.sh",
"dev:build": "bash ./scripts/build.sh",
"dev:up": "bash ./scripts/dev.sh",
"deploy:contracts": "pnpm hardhat run deploy/deploy.ts",
"deploy:contracts:full": "export DEPLOY_ENCLAVE=true && pnpm deploy:contracts",
"deploy:contracts:full:mock": "export DEPLOY_ENCLAVE=true && export USE_MOCK_VERIFIER=true && export USE_MOCK_INPUT_VALIDATOR=true && pnpm deploy:contracts",
"test:e2e": "bash ./scripts/test_e2e.sh",
"compile:contracts": "pnpm -C packages/crisp-contracts compile",
"ciphernode:add": "pnpm -C packages/crisp-contracts ciphernode:add",
Comment thread
cedoor marked this conversation as resolved.
"test": "pnpm test:e2e",
"test:contracts": "hardhat test tests/crisp.contracts.test.ts --network localhost",
"test:circuits:inputs": "hardhat test test/governanceCircuit.test.ts",
"test:circuits:inputs": "node --test test/governanceCircuit.test.ts",
"test:circuits": "cd circuits && nargo test",
"test:sdk": "cd sdk && pnpm test",
"release:sdk": "cd sdk && pnpm release",
"report": "playwright show-report",
"verify": "pnpm hardhat run deploy/verify.ts"
},
"dependencies": {
"@enclave-e3/contracts": "workspace:*",
"@excubiae/contracts": "^0.4.0",
"@zk-kit/lean-imt.sol": "2.0.0",
"poseidon-solidity": "^0.0.5",
"solady": "^0.1.13"
"report": "playwright show-report"
},
"devDependencies": {
"@aztec/bb.js": "^0.82.2",
"@enclave-e3/config": "^0.1.5",
"@noir-lang/noir_js": "1.0.0-beta.3",
"@nomicfoundation/hardhat-ethers": "4",
"@nomicfoundation/hardhat-ethers-chai-matchers": "^3.0.0",
"@nomicfoundation/hardhat-network-helpers": "3",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-toolbox-mocha-ethers": "3.0.0",
"@nomicfoundation/hardhat-typechain": "3",
"@nomicfoundation/hardhat-verify": "^3.0.1",
"@openzeppelin/contracts": "^5.0.2",
"@playwright/test": "1.52.0",
"@synthetixio/synpress": "^4.1.0",
"@synthetixio/synpress-cache": "^0.0.12",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
"@types/mocha": ">=9.1.0",
"@types/node": "^22.18.0",
"concurrently": "^9.1.2",
"dotenv": "^16.4.5",
"ethers": "^6.15.0",
"forge-std": "github:foundry-rs/forge-std#v1.9.4",
"hardhat": "^3.0.1",
"hardhat-deploy": "^0.12.4",
"hardhat-gas-reporter": "^1.0.8",
"concurrently": "^9.1.2",
"playwright": "1.52.0",
"solidity-coverage": "^0.8.1",
"ts-node": "^10.9.2",
"typechain": "^8.3.0",
"typescript": "5.8.3",
"viem": "2.30.6",
"wait-on": "^8.0.3"
"wait-on": "^8.0.3",
"ethers": "^6.15.0"
},
"packageManager": "pnpm@10.7.1+sha512.2d92c86b7928dc8284f53494fb4201f983da65f0fb4f0d40baafa5cf628fa31dae3e5968f12466f17df7e97310e30f343a648baea1b9b350685dafafffdf5808"
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,9 @@ contract CRISPProgram is IE3Program, Ownable {

// Deploy a new input validator
inputValidator = IInputValidator(
INPUT_VALIDATOR_FACTORY.deploy(
address(HONK_VERIFIER),
owner()
)
INPUT_VALIDATOR_FACTORY.deploy(address(HONK_VERIFIER), owner())
);

return (ENCRYPTION_SCHEME_ID, inputValidator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@
}
}
}
}
}
1 change: 1 addition & 0 deletions examples/CRISP/packages/crisp-contracts/lib/risc0-ethereum
Submodule risc0-ethereum added at d04a05
56 changes: 56 additions & 0 deletions examples/CRISP/packages/crisp-contracts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@enclave/crisp-contracts",
"version": "0.0.1",
"type": "module",
"files": [
"contracts/**/*.sol"
],
"author": {
"name": "gnosisguild",
"url": "https://github.com/gnosisguild"
},
"scripts": {
"compile": "hardhat compile",
"ciphernode:add": "hardhat ciphernode:add",
"clean:deployments": "hardhat utils:clean-deployments",
"deploy:contracts": "hardhat run deploy/deploy.ts",
"deploy:contracts:full": "export DEPLOY_ENCLAVE=true && pnpm deploy:contracts",
"deploy:contracts:full:mock": "export DEPLOY_ENCLAVE=true && export USE_MOCK_VERIFIER=true && export USE_MOCK_INPUT_VALIDATOR=true && pnpm deploy:contracts",
"test": "hardhat test tests/crisp.contracts.test.ts --network localhost",
"verify": "hardhat run deploy/verify.ts"
},
"dependencies": {
"@enclave-e3/contracts": "workspace:*",
"@excubiae/contracts": "^0.4.0",
"@zk-kit/lean-imt.sol": "2.0.0",
"poseidon-solidity": "^0.0.5",
"solady": "^0.1.13"
},
"devDependencies": {
"@nomicfoundation/hardhat-ethers": "4",
"@nomicfoundation/hardhat-ethers-chai-matchers": "^3.0.0",
"@nomicfoundation/hardhat-network-helpers": "3",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-toolbox-mocha-ethers": "3.0.0",
"@nomicfoundation/hardhat-typechain": "3",
"@nomicfoundation/hardhat-verify": "^3.0.1",
"@openzeppelin/contracts": "^5.0.2",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
"@types/mocha": ">=9.1.0",
"@types/node": "^22.18.0",
"dotenv": "^16.4.5",
"ethers": "^6.15.0",
"forge-std": "github:foundry-rs/forge-std#v1.9.4",
"hardhat": "^3.0.1",
"hardhat-deploy": "^0.12.4",
"hardhat-gas-reporter": "^1.0.8",
"solidity-coverage": "^0.8.1",
"ts-node": "^10.9.2",
"typechain": "^8.3.0",
"typescript": "5.8.3",
"viem": "2.30.6"
},
"packageManager": "pnpm@10.7.1+sha512.2d92c86b7928dc8284f53494fb4201f983da65f0fb4f0d40baafa5cf628fa31dae3e5968f12466f17df7e97310e30f343a648baea1b9b350685dafafffdf5808"
}
Loading
Loading