Skip to main content

Secure Trading Platform Example

The example project demonstrates how to create a web-based trading platform utilizing MPC for importing, storing and signing with exchange API keys.
The project uses Sodot Exchange API Vault (Vertex) for its API key management infrastructure.

The aim of this project is to provide a reference implementation for users of Sodot Exchange API Vault who wish to allow their users to securely import an exchange API Key into their platform.

Flow

  1. An end-user enters their API key from an exchange (in this example, only Binance is shown).
  2. The API key is first split into 3 shards.
  3. The shards are then encrypted at the end-user's browser.
  4. These encrypted shards are then sent to the trading platform's backend and imported directly into three Vertex servers.
  5. Each Vertex server then decrypts its key shard within its secure enclave (abbr. TEE).
  6. When the end-user wishes to trade on the platform, the platform's backend does not directly access the end-user's API key, it calls the Vertex API to sign specific trading requests.
  7. Each vertex server has a policy set that enforces that only trades that amount to <0.5 BTC can be made.
  8. If the trading request complies with the above policy, the request is signed via MPC.
  9. The trading platform backend then receives the signature and sends the signed request to exchange successfully.
Note

The code for this demo is available at: sodot-demo-trading-platform
A live version of this demo is hosted at: demo-trading-platform.sodot.dev



Project Architecture

The project is structured as follows:

  1. Frontend

    • Built with Next.js, a React framework for server-side rendering and static site generation.
    • Utilizes Mantine for UI components and styling.
    • Integrates with Sodot HMAC Key Sharing SDK.
  2. HMAC Key Sharing

    • Handles splitting the API key into three encrypted shards.
  3. Backend

    • Uses Rust for server-side logic.
    • Integrates with a policy server and Binance API.
    • Handles API key management using the Vertex (an MPC signer server) if the policy allows the transaction.
  4. Policy Server

    • Creates and stores a policy with any custom logic.
    • The Vertex sets and enforces policies on all API keys at the trading platform's end, independently from the exchange.
  5. Vertex

    • The Vertex is used for secure key share storage and MPC signing on the server side.
  6. Binance API

    • Binance's official API for all trading operations.

Diagram