Skip to content

Commit

Permalink
Merge pull request #1 from gnosisguild/draft-spec
Browse files Browse the repository at this point in the history
Encalve Spec
  • Loading branch information
auryn-macmillan authored Jun 5, 2024
2 parents 3b6ac3f + 2164536 commit fd1c799
Show file tree
Hide file tree
Showing 36 changed files with 6,660 additions and 255 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
"name": "@gnosisguild/enclave",
"description": "Enclave is an open-source protocol for Encrypted Execution Environments (E3).",
"version": "0.0.0",
"license": "LGPL-3.0-only",
"author": {
"name": "gnosisguild",
"url": "https://github.com/gnosisguild"
},
"scripts": {
"clean": "cd packages/evm && yarn clean",
"compile": "yarn evm:compile",
"lint": "yarn evm:lint",
"typechain": "yarn evm:typechain",
"test": "yarn evm:test",
"coverage": "yarn evm:coverage",
"evm:install": "cd packages/evm && yarn install",
"evm:compile": "cd packages/evm && yarn compile",
"evm:lint": "cd packages/evm && yarn lint",
"evm:typechain": "cd packages/evm && yarn typechain",
"evm:test": "cd packages/evm && yarn test",
"evm:coverage": "cd packages/evm && yarn coverage",
"preinstall": "yarn evm:install"
}
Expand Down
57 changes: 57 additions & 0 deletions packages/docs/contracts.spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Enclave Specification

This document is a specification of the smart contract components to Enclave, an open source protocol for Encrypted Execution Environments (E3).

## Actors

There are five groups of actors in Enclave:

1. **Requesters:** Anyone can request an E3 from the Enclave protocol by calling the corresponding smart contract entrypoint and depositing a bond proportional to the number, threshold, and duration of Cypher Nodes that they request.
2. **Data Providers:** Individuals and systems providing inputs to a requested E3. Data Providers contribute data encrypted to the public threshold key that is created, and published on chain, by the Cypher Nodes selected for a requested E3.
3. **Execution Modules:** Enclave is a modular framework, allowing the choice of many different Execution Modules in which to run encrypted computations. Broadly, Execution Modules fall into two categories: (1) Provable (like RISC Zero’s virtual machine[^1], Arbitrum’s WAVM[^2], or Succinct's SP1[^3]) and (2) Oracle-based. The former provides cryptographic guarantees of correct execution, while the latter provides economic guarantees of correct execution.
4. **Cypher Nodes:** Cypher Nodes are responsible for creating threshold public keys and decrypting the cyphertext output for each requested computation. Cypher Nodes can be registered by anyone staking Enclave tokens.
5. **Token Holders:** As the top-level governance body, Enclave token holders are responsible for setting protocol parameters, overseeing protocol upgrades, and facilitating dispute resolution.

Enclave is a smart contract protocol for coordinating the interactions between these various actors.

## Components

Enclave is a modular architecture, this section describes each of the various smart contract components that constitute the Enclave protocol.

### Core

Contains the main entrypoints for requesting and publishing inputs to E3s.

**`requestE3(uint256 computationId, bytes memory data)`**

**`publishInput(bytes32 e3Id, bytes memory data)`**

**`publishOutput(bytes32 e3Id, bytes memory data)`**

**`registerNode()`**

### CyphernodeRegistry

Registry of staked Cyphernodes that are eligible to be selected for E3 duties.

### ComputationRegistry

Registry of computations which can be requested via the protocol.

### IComputationModule

Computation module contracts implement any specific

### ExecutionModuleRegistry

Registry of execution modules on which a requested computation can be run.

### IExecutionModule

Interface defining interactions with any given execution module.

---

[^1]: RISC Zero is a general-purpose, zero-knowledge virtual machine. More information can be found on their website at https://risczero.com
[^2]: WAVM is Arbitrum’s execution environment, provable via optimistic fraud proofs. More information can be found on their website at https://arbitrum.io
[^3]: SP1 is a performant, 100% open-source, contributor-friendly zero-knowledge virtual machine (zkVM) that can prove the execution of arbitrary Rust (or any LLVM-compiled language) programs. More information can be found on Succinct's github at https://github.com/succinctlabs/sp1
3 changes: 1 addition & 2 deletions packages/evm/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ deployments
.pnp.*
coverage.json
package-lock.json
pnpm-lock.yaml
yarn.lock
pnpm-lock.yaml
4 changes: 2 additions & 2 deletions packages/evm/.prettierrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ bracketSpacing: true
plugins:
- "@trivago/prettier-plugin-sort-imports"
- "prettier-plugin-solidity"
printWidth: 120
printWidth: 100
proseWrap: "always"
singleQuote: false
tabWidth: 2
Expand All @@ -11,7 +11,7 @@ trailingComma: "all"
overrides:
- files: "*.sol"
options:
compiler: "0.8.17"
compiler: "0.8.26"
parser: "solidity-parse"
tabWidth: 4
- files: "*.ts"
Expand Down
4 changes: 3 additions & 1 deletion packages/evm/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
"plugins": ["prettier"],
"rules": {
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.8.4"],
"compiler-version": ["error", ">=0.8.26"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 120],
"named-parameters-mapping": "warn",
"no-console": "off",
"not-rely-on-time": "off",
"gas-custom-errors": "off",
"one-contract-per-file": "off",
"prettier/prettier": [
"error",
{
Expand Down
Loading

0 comments on commit fd1c799

Please sign in to comment.