Seal Decentralized Secrets Management

repository·main·Indexed 19 days ago

https://github.com/mystenlabs/seal

A decentralized secrets management (DSM) product for identity-based encryption and decryption of sensitive data. Seal uses onchain Sui policies to control access and lightweight key servers for threshold-based decryption. It includes a Move package for onchain functionality, a TypeScript SDK (@mysten/seal), and a seal-proxy server for metrics relay to Mimir and Grafana. The system supports Boneh-Franklin key encapsulation, AES-256-GCM, and HMAC-256-CTR.

Tokens
57.3K
Snippets
164
Records
258
Agent score
58%

What's inside Seal

  1. Overview of Seal decentralized secrets management

    main

    Seal is a decentralized secrets management (DSM) product designed to secure sensitive data at rest on decentralized storage (such as Walrus) or any other onchain/offchain storage.

    Key features include:

    • Identity-based encryption/decryption: Secure data using identity-based primitives.
    • Onchain access control: Access to sensitive data is controlled by onchain policies on the Sui network.
    • Threshold-based decryption: Lightweight key servers enforce Sui policies and provide threshold-based decryption keys.
    • Developer integration: Easily integrate Seal into applications using the official TypeScript SDK.
  2. What is Seal?

    main

    Seal is a decentralized secrets management (DSM) service that secures sensitive data at rest on decentralized storage (like Walrus) or any other onchain/off-chain storage. It uses access control policies defined and validated on the Sui blockchain to manage decryption keys.

    Core Workflow

    1. Encryption: Users or applications encrypt sensitive data using a secret sharing mechanism. Data is stored on a storage provider (e.g., Walrus).
    2. Access Control: Access to decryption keys is controlled via Sui. Developers implement application-specific Move packages that follow Seal conventions to define authorization logic.
    3. Decryption: Authorized users request identity-based private keys from Seal key servers. The key servers validate the access control on Sui before generating the keys.

    Key Components

    • Sui Blockchain: Acts as the source of truth for access control policies.
    • Key Servers: Lightweight services that validate Sui access and generate identity-based private keys.
    • TypeScript SDK: The primary interface for applications to interact with Seal key servers.
  3. Overview of the Seal Package

    main

    Seal is a decentralized secrets management (DSM) service. It allows application developers and users to secure sensitive data at rest on decentralized storage (such as Walrus) or any other onchain/offchain storage. The service relies on access control policies that are defined and validated on the Sui blockchain.

    The Move package provides the core onchain functionality for:

    • Registering and managing key servers.
    • Performing decryption using Boneh-Franklin key encapsulation (over BLS12-381) and HMAC-256-CTR as the data encapsulation mechanism (DEM).
  4. How Seal's Identity-Based Encryption (IBE) works

    main

    Seal uses Identity-Based Encryption (IBE) to secure data without having visibility into the data itself. In this model, an identity (a string or byte array) acts as a public key.

    Key components of the IBE scheme used by Seal:

    • Setup: Generates a master secret key (msk) and a master public key (mpk).
    • Derive(msk, id): Generates a specific secret key (sk) for a given identity (id) using the master secret key.
    • Encrypt(mpk, id, m): Encrypts a message m using the master public key and the identity id.
    • Decrypt(sk, c): Decrypts the ciphertext c using the derived secret key sk.

    Seal maps onchain Sui strings to these IBE identities. A Move package at a specific address (PkgId) acts as an identity namespace, controlling a subdomain of identities that follow the pattern [PkgId]*.

  5. Understand Seal key server modes: Open vs Permissioned

    main

    Seal supports two operational modes for independent server type key servers:

    • Open mode: Allows anyone to request keys for any access policy package using a shared master key. This is ideal for public use, trials, or experimentation.
    • Permissioned mode: Restricts access to specific approved access policy packages per client. Each client uses a dedicated master key and the mode supports secure key server rotation or switching. This is designed for dedicated or commercial applications.

    When integrating, note that for Permissioned mode, you typically need to contact the provider to configure your client and generate a unique key server object ID.

  6. Use the Secure Voting pattern for encrypted ballots

    main

    The Secure Voting pattern enables running a vote where ballots remain encrypted until the voting period is complete.

    Workflow:

    1. Define eligible voters.
    2. Voters submit their encrypted choices.
    3. Once all votes are submitted, participants fetch the required threshold keys from Seal.
    4. Use onchain decryption to produce a verifiable tally.

    Invalid or tampered ballots are ignored by the process.

    Best use cases:

    • Governance
    • Sealed-bid auctions
    • Time-locked voting
  7. Use Time-lock encryption for scheduled content reveals

    main

    Time-lock encryption allows you to publish encrypted content that automatically unlocks at a specific timestamp. The content is encrypted once with an unlock timestamp; no one can access it before the time passes, and anyone (or a specific audience) can access it after.

    Best use cases:

    • Coordinated reveals (drops, auctions)
    • MEV-resilient trading
    • Secure voting

    Note: An optional variant exists that allows an authorized party to extend the unlock time before it expires.

  8. Choose the right encryption mode for your data

    main

    Select an encryption mode based on your performance and use-case requirements:

    • AES: Use for most application data. It is significantly faster and more memory-efficient than HMAC-CTR.
    • HMAC_CTR: Use only when you require onchain decryption of small-sized data.
  9. Use the Subscription pattern for time-limited access

    main

    The Subscription pattern provides time-limited access to encrypted content or services. A service is defined with a specific price and duration. Upon subscribing, a user's identity is granted a 'pass' that permits decryption of the service's content until the subscription expires. This pattern avoids the need for re-encryption or moving data.

    Best use cases:

    • Premium media
    • Data feeds
    • Paid API and AI model access
  10. Understand Seal's access control patterns

    main

    The Seal reference application demonstrates two primary access control models for managing encrypted content:

    Allowlist-Based Access

    In this model, a creator manages a set of authorized addresses.

    1. Setup: The creator associates encrypted files with an allowlist.
    2. Access Flow: A user signs a personal message to prove identity.
    3. Verification: The message is verified against the allowlist.
    4. Key Retrieval: Upon successful verification, the user retrieves two key shares from two independent servers.
    5. Decryption: The user combines these key shares to derive the decryption key and access the content.

    Subscription-Based Access

    This model uses on-chain assets to manage time-bound access.

    1. Setup: A creator defines a service with a price (in MIST) and a duration (X minutes).
    2. Purchase: Users purchase a subscription, which is issued as an on-chain Non-Fungible Token (NFT).
    3. Access Flow: The user signs a personal message.
    4. Verification: Servers validate the signature and check the Sui clock to ensure the user's subscription NFT is currently active.
    5. Decryption: If valid, the user retrieves the decryption key to access the content.
  11. Choose an appropriate threshold configuration

    main

    Seal supports threshold encryption using multiple independent key servers. When encrypting data, you must select a threshold configuration (e.g., 2-of-3 or 3-of-5) based on data sensitivity and required availability.

    Risks of poor configuration:

    • Data Loss: If too many key servers in a configuration go offline or become unavailable, users may be unable to obtain enough decryption shares to recover their keys.
    • Security vs. Availability: Always balance the desired security guarantees against the risk of losing access due to server unavailability.

    :::note Choosing a specific threshold configuration does not apply to decentralized (committee mode) key servers, as one is defined for each such key server during its setup. :::

  12. Understand the Decentralized (Committee) server type

    main

    A Decentralized server type uses a committee of multiple independent providers coordinating via threshold cryptography. To the blockchain, it appears as a single logical key server with one object ID and one stable public key.

    How it works:

    • Distributed Key Generation (DKG): Operators participate in a DKG ceremony to produce distributed key shares. Each operator runs a key server holding only a partial share.
    • Aggregator Gateway: Clients do not connect to individual committee members. Instead, they send requests to an Aggregator, which collects encrypted partial responses from the committee and combines them into a single encrypted result for the client.
    • Stability: The onchain object ID and public key remain stable even when operators are added, removed, or replaced through rotation ceremonies. This means clients do not need updates and existing encrypted data does not need re-encryption when membership changes.

    Key Properties:

    • Trustless Aggregator: The aggregator holds no key material and cannot decrypt data.
    • No Single Point of Failure: No single operator holds the full master key.
    • Seamless Membership Changes: Membership rotation is transparent to the client.

    Use Cases:

    • Distributed key management across multiple parties.
    • Multi-party governance with changing membership.
    • Long-term deployments where operator membership is expected to evolve.