The Data Vault is an end-to-end encrypted key-value store built into the TinyCloud SDK. All encryption and decryption happens on the client — the server only stores encrypted blobs and has zero access to plaintext data. Available asDocumentation Index
Fetch the complete documentation index at: https://docs.tinycloud.xyz/llms.txt
Use this file to discover all available pages before exploring further.
tc.vault on both TinyCloudWeb (browser) and TinyCloudNode (Node.js).
How It Works
The vault uses WASM-based cryptography:- AES-256-GCM for data encryption (per-entry random keys for forward secrecy)
- HKDF-SHA256 for master key derivation from wallet signatures
- X25519 Diffie-Hellman for sharing encrypted data with other users
- One to derive the master encryption key (deterministic — same wallet always produces the same key)
- One to derive the X25519 identity keypair (used for sharing)
.well-known/vault-pubkey in the user’s public space for peer discovery. All encrypted data (vault/*, keys/*, grants/*) lives in the user’s primary space.
Public Space vs Primary Space
The vault uses two separate spaces with distinct roles:- Primary space (authenticated): Stores all encrypted data (
vault/*), encryption keys (keys/*), and grants (grants/*). Only accessible with proper UCAN delegation. This is where your actual vault contents live. - Public space (unauthenticated reads): Stores only discovery metadata —
.well-known/vault-pubkey,.well-known/vault-version, and.well-known/vault-space. Anyone can read these to discover your vault’s public key for sharing.
vault.grant().
Unlocking the Vault
Before any vault operations, you must unlock it. This derives encryption keys from wallet signatures.Unlocking is deterministic. The same wallet always produces the same encryption keys, so data encrypted in one session can be decrypted in another.
Basic Operations
Put
Encrypt and store a value.put generates a random AES-256-GCM key for that entry. The entry key is encrypted with your master key and stored separately from the ciphertext.
Get
Retrieve and decrypt a value.Delete
Remove an encrypted entry.List
List vault keys with optional prefix filtering.Head
Get metadata for an entry without decrypting the value.Sharing Encrypted Data
The vault supports sharing individual entries with other users via X25519 key exchange. Sharing involves two steps: the grantor creates a grant, and the recipient reads the shared data using a delegation.Step 1: Grant Access
The grantor re-encrypts the entry key to the recipient’s X25519 public key using an ephemeral Diffie-Hellman keypair.Step 2: Delegate Read Access
The grantor must also create a UCAN delegation so the recipient can read the encrypted data and grant from the grantor’s space.Step 3: Decrypt Shared Data
The recipient loads the delegation and usesgetShared to decrypt.
getShared requires a delegated KV instance (access.kv) because grants and encrypted data live in the grantor’s authenticated space — not in a public endpoint.Batch Operations
Store or retrieve multiple entries in one call.CLI
Thetc vault CLI wraps the SDK for command-line usage.
The CLI requires a private key via
--private-key <hex> or the TC_PRIVATE_KEY environment variable.Error Handling
Vault operations returnResult types. Handle errors by checking result.ok.
What the Server Sees
The server stores self-describing encrypted envelopes. A vault entry on the server looks like:data field. It has no access to the master key or per-entry keys.
API Quick Reference
| Method | Description |
|---|---|
vault.unlock(signer) | Derive encryption keys from wallet signatures |
vault.lock() | Clear all key material from memory |
vault.isUnlocked | Whether the vault is currently unlocked |
vault.put(key, value) | Encrypt and store a value |
vault.get(key) | Decrypt and retrieve a value |
vault.delete(key) | Remove an encrypted entry |
vault.list(options?) | List vault keys (optional prefix filter) |
vault.head(key) | Get envelope metadata without decrypting |
vault.putMany(entries) | Batch encrypt and store |
vault.getMany(keys) | Batch decrypt and retrieve |
vault.grant(key, recipientDID) | Share access via X25519 key exchange |
vault.revoke(key, recipientDID) | Revoke a grant |
vault.listGrants(key) | List DIDs with access to a key |
vault.getShared(grantorDID, key, opts) | Decrypt data shared by another user |
vault.resolvePublicKey(did) | Look up a user’s X25519 public key |