CRISP
Running an E3 Program

Running an E3 Program

In this section, we will go through all the steps to run an E3 Program using CRISP. We will run a single voting round of CRISP and do the following:

  • Request an E3 Voting Round
  • Submit a vote
  • Compute the result
  • Verify the result

Please make sure you have followed the CRISP Setup guide before proceeding.

Ciphernodes Setup

Running Ciphernodes

In the root enclave directory, you have to run the Ciphernodes. To run four Ciphernodes, use the provided script run_ciphernodes.sh (opens in a new tab). Ensure you run the script from the root enclave directory to set the environment variables correctly:

RUST_LOG=info ./run_aggregator.sh

Running the Aggregator

After starting the Ciphernodes, run the aggregator with the script run_aggregator.sh (opens in a new tab):

RUST_LOG=info ./run_aggregator.sh

Adding Ciphernodes to the Registry

Once the aggregator is running, you can add the Ciphernodes to the registry with the script add_ciphernodes.sh (opens in a new tab):

./add_ciphernodes.sh

After running the script, you should see the following output in the aggregator terminal:

[AGG]: READY
[AGG]: CiphernodeAdded(0x2546BcD3c84621e976D8185a91A922aE77ECEc30)
[AGG]: CiphernodeAdded(0xbDA5747bFD65F08deb54cb465eB87D40e51B197E)
[AGG]: CiphernodeAdded(0xdD2FD4581271e230360230F9337D5c0430Bf44C0)
[AGG]: CiphernodeAdded(0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199)

Running the CRISP Server

To run the CRISP Server, navigate to the CRISP/packages/server directory and execute the following command:

Note: Make sure you have set the environment variables correctly before running the server.

cargo run --bin server

Interacting with CRISP via CLI

Once the Server is running, you can interact with the CRISP by using the CLI.

Requesting a New Round

  1. Run the CLI:
cargo run --bin cli

You should see the following output:

? Enclave (EEEE): Please choose the private execution environment you would like to run!   
 CRISP: Voting Protocol (ETH)
  More Coming Soon!
  1. Select CRISP: Voting Protocol (ETH) from the menu.
 Initialize new E3 round.
  Activate an E3 round.
  Participate in an E3 round.
  Decrypt Ciphertext & Publish Results
  1. To initiate a new CRISP voting round, choose the option Initialize new CRISP round.
 Initialize new E3 round.
[2024-10-22 11:56:11] [commands.rs:42] - Starting new CRISP round!
[2024-10-22 11:56:11] [commands.rs:46] - Enabling E3 Program...
[2024-10-22 11:56:11] [commands.rs:50] - E3 Program enabled. TxHash: 0xa391a4cd2dcc59f4bc6dd1f5ed1c78006dbba4556ea633f4b6a53e2271538682
[2024-10-22 11:56:11] [commands.rs:74] - E3 request sent. TxHash: 0xe7998b9748e3526f6ca992c9bb498beabe4f387b02240a23d0f42a2386d3c305

Ensure all services are running correctly and that components are communicating as expected before starting a new CRISP round.

Submitting a Vote

  1. Run the CLI:
cargo run --bin cli
  1. Select the option Participate in an E3 round.
 Participate in an E3 round.
  1. Select the round you would like to participate in.
? Enter CRISP round ID. 
 0
  1. Submit your vote by entering the vote in the prompt.
? Please select your voting option. 
 Abstain
  Yes
  No

After submitting your vote, you should see the following output:

 Enclave (EEEE): Please choose the private execution environment you would like to run! · CRISP: Voting Protocol (ETH)
 Create a new CRISP round or participate in an existing round. · Participate in an E3 round.
 Enter CRISP round ID. · 0
 Please select your voting option. · Vote yes.
[2024-10-22 11:58:58] [commands.rs:129] - Vote broadcast. TxHash: 0x389466265c543845f050aa931472840eb1d3f67276d1650aede77ce07426e98e

Computing the Result

After the voting period has ended, the server will compute the result and publish the ciphertext.

[2024-10-22 11:59:12] [handlers.rs:95] - Vote Count: 1
[2024-10-22 11:59:12] [handlers.rs:101] - Starting computation for E3: 0
Prove function execution time: 2 minutes and 37 seconds
[2024-10-22 12:01:49] [handlers.rs:109] - Computation completed for E3: 0
[2024-10-22 12:01:49] [handlers.rs:110] - RISC0 Output: Risc0Output { result: ComputeResult } ...
[2024-10-22 12:01:49] [handlers.rs:111] - Publishing ciphertext...

Decrypting the Result

The Ciphernodes will capture the published ciphertext, decrypt it, and publish the plaintext.

INFO Extracted log from evm sending now.
INFO evt=CiphertextOutputPublished(e3_id: 0) e3_id=0
INFO evt=DecryptionshareCreated(e3_id: 0, node: 0x2546BcD3c84621e976D8185a91A922aE77ECEc30) e3_id=0
INFO evt=PlaintextAggregated(e3_id: 0, src_chain_id: 31337) e3_id=0
INFO evt=E3RequestComplete(e3_id: 0)
INFO Plaintext published. tx=0x320dd95358cc86c2a709b6fec0c6865b43fa063cb61dfcb8a748005d4886f040

Verifying the Result

The server captures the plaintext, decodes it, and displays it.

[2024-10-22 12:01:49] [handlers.rs:171] - Handling PlaintextOutputPublished event...
[2024-10-22 12:01:49] [handlers.rs:181] - Vote Count: 1
[2024-10-22 12:01:49] [handlers.rs:182] - Votes Option 1: 0
[2024-10-22 12:01:49] [handlers.rs:183] - Votes Option 2: 1
[2024-10-22 12:01:49] [handlers.rs:187] - PlaintextOutputPublished event handled.

Result