Nix, crates and tools for TEE handling
Find a file
Patryk Bęza e63d0901fa
feat(verifier): don't retry verifying permanently ignored batches
Currently, the [TEE verifier][1] – the tool for continuous SGX
attestation and batch signature verification – is [stuck][2] on batches
that failed to be proven and are marked as `permanently_ignored`. The
tool should be able to distinguish between batches that are permanently
ignored (and should be skipped) and batches that have failed but will be
retried. This PR enables that distinction.

This commit goes hand in hand with the following PR:
https://github.com/matter-labs/zksync-era/pull/3321

[1]: https://github.com/matter-labs/teepot/blob/main/bin/verify-era-proof-attestation/src/main.rs
[2]: https://grafana.matterlabs.dev/goto/unFqf57Hg?orgId=1
2024-11-26 17:19:55 +01:00
.github ci: remove magic nix cache 2024-09-18 14:56:04 +02:00
assets feat: attestation test on azure and default dcap 2024-03-07 16:05:27 +01:00
bin feat(verifier): don't retry verifying permanently ignored batches 2024-11-26 17:19:55 +01:00
crates feat(logging): centralize logging setup in teepot crate 2024-09-18 16:08:13 +02:00
examples feat: add Kubernetes pod spec for vault-unseal and update docs 2024-08-07 14:46:10 +02:00
packages chore: add extra startup information to unseal and admin enclaves 2024-09-04 09:47:20 +02:00
shells/teepot chore: prepare release tags 2024-09-16 16:14:26 +02:00
.dockerignore feat: initial commit 2024-02-09 10:10:53 +01:00
.gitignore feat: initial commit 2024-02-09 10:10:53 +01:00
Cargo.lock feat(logging): centralize logging setup in teepot crate 2024-09-18 16:08:13 +02:00
Cargo.toml chore: Release 2024-09-16 17:01:14 +02:00
deny.toml Whitelist CC0-1.0 license 2024-07-01 15:23:15 +02:00
flake.lock chore: update flake.lock 2024-09-03 13:24:19 +02:00
flake.nix fix(flake.nix): remove redundant crane input follow 2024-09-18 14:46:33 +02:00
LICENSE-APACHE feat: initial commit 2024-02-09 10:10:53 +01:00
LICENSE-MIT feat: initial commit 2024-02-09 10:10:53 +01:00
README.md docs: adapt README.md to reality 2024-07-02 13:14:36 +02:00
rust-toolchain.toml chore(deps): update to rust version 1.78 2024-06-10 13:09:05 +02:00
taplo.toml chore: prepare release tags 2024-09-16 16:14:26 +02:00
teepot-crate.nix feat(verify-attestation): RPC attestation and batch signature verification binary 2024-08-30 12:14:55 +02:00

teepot

Key Value store in a TEE with Remote Attestation for Authentication

Introduction

This project is a key-value store that runs in a Trusted Execution Environment (TEE) and uses Remote Attestation for Authentication. The key-value store is implemented using Hashicorp Vault running in an Intel SGX enclave via the Gramine runtime.

Parts of this project

  • teepot: The main rust crate that abstracts TEEs and key-value stores.
  • tee-vault-unseal: An enclave that uses the Vault API to unseal a vault as a proxy.
  • vault-unseal: A client utility, that talks to tee-vault-unseal to unseal a vault.
  • tee-vault-admin: An enclave that uses the Vault API to administer a vault as a proxy.
  • vault-admin: A client utility, that talks to tee-vault-admin to administer a vault.
  • teepot-read : A pre-exec utility that reads from the key-value store and passes the key-value pairs as environment variables to the enclave.
  • teepot-write : A pre-exec utility that reads key-values from the environment variables and writes them to the key-value store.
  • verify-attestation: A client utility that verifies the attestation of an enclave.
  • tee-key-preexec: A pre-exec utility that generates a p256 secret key and passes it as an environment variable to the enclave along with the attestation quote containing the hash of the public key.

Development

Prerequisites

Install nix.

In ~/.config/nix/nix.conf

experimental-features = nix-command flakes
sandbox = true

or on nixos in /etc/nixos/configuration.nix add the following lines:

{
  nix = {
    extraOptions = ''
      experimental-features = nix-command flakes
      sandbox = true
    '';
  };
}

Develop

$ nix develop

optionally create .envrc for direnv to automatically load the environment when entering the directory:

$ cat <<EOF > .envrc
use flake .#teepot
EOF
$ direnv allow

Format for commit

$ nix run .#fmt

Build as the CI would

$ nix run github:nixos/nixpkgs/nixos-23.11#nixci

Build and test individual container

See the packages directory for the available packages and containers.

$ nix build -L .#container-self-attestation-test-sgx-azure
[...]
teepot-self-attestation-test-sgx-azure-manifest-app-customisation-layer> Measurement:
teepot-self-attestation-test-sgx-azure-manifest-app-customisation-layer>     eaaabf210797606bcfde818a52e4a434fbf4f2e620d7edcc7025e3e1bbaa95c4
[...]
$ export IMAGE_TAG=$(docker load < result | grep -Po 'Loaded image.*: \K.*')
$ docker run -v $(pwd):/mnt -i --init --rm $IMAGE_TAG "cp app.sig /mnt"
$ nix shell github:matter-labs/nixsgx#gramine -c gramine-sgx-sigstruct-view app.sig
Attributes:
    mr_signer: c5591a72b8b86e0d8814d6e8750e3efe66aea2d102b8ba2405365559b858697d
    mr_enclave: eaaabf210797606bcfde818a52e4a434fbf4f2e620d7edcc7025e3e1bbaa95c4
    isv_prod_id: 0
    isv_svn: 0
    debug_enclave: False