Index of every page on this site: llms.txt
All skills
mystenlabs avatar

/walrus-data-security

@4d8aa0b
Run it yourself

Encrypting data before storing on Walrus using Seal (threshold encryption with onchain access control). Use when the user needs to store private or sensitive data on Walrus, implement access control for blob content, encrypt blobs before uploading, use @mysten/seal for threshold encryption, or understand Walrus data security guarantees (availability, integrity, confidentiality). Also use when the user asks about Nautilus (TEE-based off-chain computation) in the context of Walrus data. All blobs on Walrus are public by default.

Use this Skill: https://skilld.dev/gh/mystenlabs/walrus-skills/walrus-data-security

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

seal-sdk.md

≈1.5k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Seal SDK Integration Guide

Source: https://seal-docs.wal.app/ and https://www.npmjs.com/package/@mysten/seal

This reference file covers the practical details of integrating the Seal TypeScript SDK with Walrus for encrypted blob storage. For the conceptual overview of Walrus data security, see the parent SKILL.md.

Overview

Seal provides threshold encryption with onchain access control. The workflow is:

  1. Define an access policy as a Move smart contract on Sui
  2. Encrypt data client-side using the Seal SDK (threshold encryption)
  3. Store the ciphertext on Walrus (it is safe because it is encrypted)
  4. To decrypt, the requesting user proves they meet the access policy; Seal key servers provide decryption shares

No single key server holds the full decryption key. A threshold of key servers must participate.

Installation

npm install @mysten/seal @mysten/sui

Client initialization

import { SealClient } from '@mysten/seal';
import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';

const suiClient = new SuiClient({ url: getFullnodeUrl('mainnet') });

const sealClient = new SealClient({
  suiClient,
  network: 'mainnet',  // or 'testnet'
});

Key server object IDs

Seal requires key server object IDs for the target network. These identify the on-chain key server registry that coordinates threshold decryption.

Important: Key server object IDs are different for testnet and mainnet. Check the Seal documentation for the current values. Do not hardcode them — they may change with upgrades.

If you are building a frontend, these are commonly set as environment variables:

NEXT_PUBLIC_SEAL_PACKAGE_ID=<seal-package-id>

Encryption flow

// 1. Build a policy transaction (defines who can decrypt)
const tx = new Transaction();
// ... add your access control logic (allowlist check, token gate, etc.)

// 2. Encrypt the data
const { encryptedData, encryptionKey } = await sealClient.encrypt({
  data: plaintextBytes,  // Uint8Array
  policyId: '<POLICY_OBJECT_ID>',
  threshold: 2,  // number of key servers needed for decryption
});

// 3. Store the encrypted data on Walrus
const { blobId } = await walrusClient.walrus.writeBlob({
  blob: encryptedData,   // Uint8Array
  epochs: 30,
  deletable: false,
  signer: keypair,       // pays SUI for gas and WAL for storage
});

Decryption flow

// 1. Read the encrypted blob from Walrus
const encryptedData = await walrusClient.walrus.readBlob({ blobId: '<BLOB_ID>' });

// 2. Build the policy check transaction
const tx = new Transaction();
tx.setSender(userAddress);  // CRITICAL: must match the requesting address
// ... add policy verification calls

// 3. Decrypt
const decryptedData = await sealClient.decrypt({
  data: encryptedData,
  tx,
});

The seal_approve Move function

Access policies are implemented as Move modules that export a seal_approve function. This function is called during decryption to verify the requester meets the policy conditions.

Example: allowlist-based access control:

module my_policy::access {
    use seal::seal;

    public fun seal_approve(
        allowlist: &Allowlist,
        id: vector<u8>,
        ctx: &TxContext,
    ) {
        // Verify the sender is on the allowlist
        assert!(allowlist.contains(ctx.sender()), ENotAllowed);
        seal::approve(id, ctx);
    }
}

The seal::approve(id, ctx) call at the end signals to the key servers that this requester is authorized for the given encryption ID.

Access control patterns

Pattern Description
Allowlist Only specific addresses can decrypt. Managed via a shared Sui object.
Token gate Only holders of a specific NFT or coin can decrypt.
Time lock Data becomes decryptable after a specific epoch or timestamp.
Subscription Decryption tied to an active subscription NFT. Access follows token transfers.
Role-based Capabilities or role objects control access.

Session signing

Seal decryption requires the wallet to sign multiple transactions (one per key server in the threshold). To avoid prompting the user for each signature:

  • Wallets with session signing support: The wallet signs once for a session, and subsequent signatures happen automatically.
  • Wallets without session support: The user must approve each signature individually. This creates a poor UX for high-threshold configurations.

If the wallet does not support sessions, you get:

Connected wallet does not support Seal session signing

Workaround: Implement a manual approval flow, or recommend users switch to a wallet that supports Seal sessions.

Common errors

Error Cause Fix
Transaction was not signed by the correct sender Missing tx.setSender(address) or sender mismatch Set tx.setSender(userAddress) before passing to Seal
Connected wallet does not support Seal session signing Wallet does not implement session protocol Use a compatible wallet or manual per-signature approval
PolicyNotFound The policy object ID is wrong or on the wrong network Verify the policy object exists on the target network
ThresholdNotMet Not enough key servers responded Retry; some key servers may be temporarily unavailable
DecryptionFailed Ciphertext was not encrypted with this policy Verify the policy ID matches what was used during encryption

Limitations

  • Not for HIPAA/PHI or government-classified data. Seal assumes threshold trust among key servers. This may not meet strict regulatory requirements.
  • Key servers must be online for decryption. If fewer than the threshold number of key servers are available, decryption fails.
  • Ciphertext is still public on Walrus. The encrypted blob is visible to anyone. Security relies entirely on the encryption, not on obscurity.
  • Self-hosting key servers is possible but complex. The Docker image is at ghcr.io/mystenlabs/seal/key-server. Check the Seal docs for setup instructions.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts1mo3 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    The skill provides guidance on using the Seal SDK for encrypting data on Walrus. It correctly explains security guarantees, implementation steps, and common errors for the vendor-provided libraries. No malicious patterns or security risks were identified.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

Signed by skilld at 4d8aa0b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 2 months ago

README badge

README badge for mystenlabs/walrus-skills/walrus-data-security