guarantee

Crates.ioguarantee
lib.rsguarantee
version0.1.0
created_at2026-01-07 05:37:23.159394+00
updated_at2026-01-07 05:37:23.159394+00
descriptionguarantee is a tee-secured web application framework that focuses on security.
homepage
repository
max_upload_size
id2027578
size54,661
Nadimpalli Susruth (susruth)

documentation

README

Guarantee

A lightweight, boilerplate-free Rust library designed for building HTTP services inside Trusted Execution Environments (TEEs), specifically targeting Intel SGX (via the Fortanix EDP).

This template provides a custom, dependency-light HTTP server and router, allowing you to build secure enclaves with minimal overhead.

Features

  • Custom HTTP Server: Lightweight TCP-based HTTP implementation.
  • Routing: Simple, pattern-matching router.
  • Generic State Management: Share state across handlers in a thread-safe way using Arc<HandlerState<T>>.
  • SGX Ready: Configured for x86_64-fortanix-unknown-sgx out of the box.

Prerequisites

To build and run this project, you need:

  1. Rust Nightly: Required for some SGX features.

    rustup toolchain install nightly
    rustup default nightly
    
  2. SGX Target:

    rustup target add x86_64-fortanix-unknown-sgx
    
  3. Fortanix SGX Runner (Optional, for running locally):

    cargo install ftxsgx-runner-cargo
    

Usage

Library Structure

The project is structured as a library (src/lib.rs) which exports core modules:

  • server: The TCP/HTTP server implementation.
  • http: Request/Response parsing and Router.
  • state: Generic state container.
  • handlers: Example handlers.

Building Examples

This template includes examples demonstrating different use cases.

1. Health Check (Stateless)

A simple "Hello World" style example.

cargo build --example health

To run it (if you have the runner installed/configured):

cargo run --example health

2. Counter (Stateful)

Demonstrates using the generic HandlerState<T> to share atomic state between requests.

cargo build --example counter

Creating Your Own Service

  1. Define your State: Create a struct for your application state (or use () if stateless).
  2. Initialize Router:
    use tee_template::http::router::Router;
    use tee_template::state::HandlerState;
    use std::sync::Arc;
    
    // Define your state type
    type AppState = AtomicUsize;
    
    let my_state = AtomicUsize::new(0);
    let state = Arc::new(HandlerState::new(Some(my_state)));
    let mut router = Router::new(state);
    
  3. Register Handlers:
    router.register("/my-endpoint", my_handler);
    
  4. Start Server:
    HttpServer::new("0.0.0.0:8080", router)?.run()?;
    

License

This project is licensed under the MIT License - see the LICENSE file for details.

Commit count: 0

cargo fmt