informalsystems / cycles-quartz

Secure SGX Sidecar for CosmWasm
https://cycles.money/
Apache License 2.0
0 stars 0 forks source link

Quartz

Quartz is a flexible framework for privacy-preserving computation via Trusted Execution Environments (TEEs) organized and secured by smart contracts.

Get started with Quartz on existing CosmWasm chains without needing them to upgrade first.

Why? Development of Quartz was motivated by the privacy needs of the Cycles Protocol, which adopts a TEE-based ZK execution sidecar for private smart contracts. For background on how to think about different privacy preserving technologies (FHE vs MPC vs ZKP vs TEE), see How to win friends and TEE-fluence people and the associated tweet thread.

What? With Quartz, data in smart contracts can be encrypted, while computation happens privately off-chain via TEEs like SGX. Each contract can control what code runs in the enclave, when it runs, and who is permitted to run it. Quartz provides a library for CosmWasm and for enclave development, and a CLI tool for setting it all up.

How? At the heart of Quartz is a light-client protocol handshake between the enclave and the smart contract which gives the smart contract control over when, how, and by who the enclave code is run. This significantly reduces the surface area of TEEs. See How it Works.

Where? Quartz currently targets the CosmWasm smart contract environment and the Intel SGX enclave. Other environments and TEEs remain for future work. It works on existing CosmWasm chains without requiring them to upgrade first.

Who? Quartz is (currently) for any CosmWasm developer interested in adding privacy or secure off-chain compute to their contracts and applications.

When? Early, non-production versions of Quartz are available now for building example applications. Production features and requirements are in development. See Future Work


WARNING: Quartz is under heavy development and is not ready for production use. The current code contains known bugs and security vulnerabilities and APIs are still liable to change.


Docs

This Repo

Quartz provides developers three main tools:

This repo contains an example, transfers, which combines these tools into a working private transfers application, complete with a Keplr-based frontend.

Smart Contract Lib

quartz-contract-core does two main things:

It contains the core types for session management and for interfacing with attestations and is the only crate the smart contract dev should have to interact with.

App devs add the quartz-contract-core message types to their contract's messages, and call the verify handler on attested messages. While Quartz enables securely attested private compute off-chain, app devs are still responsible for the on-chain data model. See Building Apps for more.

Under the hood, attestation verification itself is performed via two separate contracts:

The actual types and verification logic for attestation is further encapsulated in quartz-tee-ra.

Enclave Lib

quartz-enclave-core mirrors quartz-contract-core, in that its the enclave side of what happens on chain. Both have to manage a secure session. Where quartz-contract-core verifies attestations, quartz-enclave-core produces them. But additionally, quartz-enclave-core must verify the state of the blockchain so that the enclave binary is restricted to only operate authorized commands. It does this via light-client verification. quartz-enclave-core does the following:

The underlying implementation includes the following crates:

CLI Tool

The core of the quartz command line tool is:

All commands support a --mock-sgx flag for dev/testing purposes without using a real SGX.

It also has convenience commands for building and deploying a smart contract:

And for running everything in one go (build, deploy/start, handshake):

Utils

The repo contains some additional utilities for supporting Quartz development:

Contributing

If you're interested in contributing, please comment on a relevant issue (if there is one) or open a new one! See CONTRIBUTING.md.

License

Apache 2.0