Giter VIP home page Giter VIP logo

sgx-revm's Introduction

SGX - REVM

PoC illustrating usage of the Fortanix SGX platform for executing an EVM message confidentially without leaking any compute or access information.

How it works

  1. User manually provisions an SGX server, e.g. on Azure
  2. SGX-enabled server opens up a TCP Socket with TLS Enabled (assumes some kind of Certificate is already generated, see first line in main.rs - ideally there's a productionized way to do Certificate provisioning).
  3. User submits a TLS-encrypted payload to the server, ensuring the user and the server only have access to the information being delivered (the server actually doesn't because the socket is opened within the SGX enclave).
  4. The Server proceeds to parse the payload into an EVM message and execute it confidentially.

The EVM database is expected to be instantiated as empty, and the user is expected to provide a payload which contains all the storage slots & values required by their transaction, including Merkle Patricia Proofs for proving that these transactions are part of the actual state. It assumes that there is also a state root available to check against.

TODO

  1. Make the demo unit-testable for CI usage
  2. Enable TLS payload decryption on the server (currently we just submit plaintext payloads to make prototype testing with netcat easier)
  3. Extend the user-submitted payload to multiple transactions including merkle patricia proof verification for each access. This is kind of like a stateless node / light-client.
  4. Remote Attestation

How to replicate the results

Installing the Fortanix SDK Platform

On an SGX-supported machine (e.g. on Azure), you'll need to install the Fortanix SDK. Providing a quick-start below:

# From: https://edp.fortanix.com/docs/installation/guide/
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Install Nightly -- required for SGX below
rustup toolchain install nightly

# Add SGX the platform
rustup target add x86_64-fortanix-unknown-sgx --toolchain nightly

# Missing some things..
sudo apt-get install -y pkg-config libssl-dev protobuf-compiler cmake clang

# Install the CLI tools
cargo install fortanix-sgx-tools sgxs-tools

# Override the default cargo runner with the SGX one
echo >> ~/.cargo/config -e '[target.x86_64-fortanix-unknown-sgx]\nrunner = "ftxsgx-runner-cargo"'

# Install DKMS & the SGX Service
echo "deb https://download.fortanix.com/linux/apt xenial main" | sudo tee -a /etc/apt/sources.list.d/fortanix.list >/dev/null
echo "deb https://download.01.org/intel-sgx/sgx_repo/ubuntu $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/intel-sgx.list >/dev/null

curl -sSL "https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key" | sudo -E apt-key add -
curl -sSL "https://download.fortanix.com/linux/apt/fortanix.gpg" | sudo -E apt-key add -

sudo apt-get update
sudo apt-get install intel-sgx-dkms sgx-aesm-service libsgx-aesm-launch-plugin

# Check your SGX setup, all should be green except the `libsgx_enclave_common` maybe.
sgx-detect

Running the demo

On a terminal run:

cargo run --release --target x86_64-fortanix-unknown-sgx

On another terminal:

nc localhost 7878
{ "sender": "0xdafea492d9c6733ae3d56b7ed1adb60692c98bc5", "amount": 40 }

Then CTRL+C to close the netcat session, and you'll see on the first terminal that the simulation has completed, without the host ever knowing what happened!

sgx-revm's People

Contributors

gakonst avatar pbeza avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.