- Home
- Skills
- APIs & Backend
- Multi-Recipient Sealed Envelope (X25519 + ML-KEM)
Multi-Recipient Sealed Envelope (X25519 + ML-KEM)
Recipients that publish an ML-KEM-768 key get a hybrid X25519 + ML-KEM-768 wrap when the runtime supports it; openers lacking the half fail closed.
$39
Works with the AI Agents you already use
Multi-Recipient Sealed Envelope (X25519 + ML-KEM)
Example session with this skill installed
Our clients upload tax-style documents through the browser and the API server must never be able to read them. Three parties need to open them: the account manager, the processing workstation, and an offline recovery key. Set up end-to-end encryption with a key directory the server can't tamper with.
- Read your context and instructions
- Compiled the multi-recipient sealed envelope
Summary
Three recipient keys generated, the directory signed by an offline root key and pinned in the web client, uploads sealed in the browser, server validates headers only. Round trip verified for all three recipients; every tamper case rejected.
$ node scripts/envelope-cli.mjs keygen --out manager --role operator
kid Q2x1...8w (with ML-KEM-768); wrote manager.public.json and manager.private.json
$ node scripts/envelope-cli.mjs keygen --out workstation --role workstation
$ node scripts/envelope-cli.mjs keygen --out recovery --role recovery --pq false # offline, classical only
$ node scripts/envelope-cli.mjs keygen --out root --role root --pq false # offline
$ node scripts/envelope-cli.mjs directory --org acme --root root.private.json \
--recipient manager.public.json --recipient workstation.public.json --recipient recovery.public.json --out directory.json
signed directory with 3 recipient(s) by 7HfK...2a
Browser (seal): verifyDirectory(directory, ROOT_PUBLIC) with the root pinned in the bundle, then seal(fileBytes, { recipients, meta: { name, type } }). Header: 3 wraps (2 hybrid X25519+ML-KEM-768, 1 X25519), chunk size 1 MiB, no file name visible.
Server (validate only): parseHeader(upload) must succeed and every recipient kid must be in the current directory; the server stores the bytes and cannot open them.
Workstation (open):
$ node scripts/envelope-cli.mjs open --in upload.mre1 --key workstation.private.json --pub workstation.public.json --out statement.pdf
opened with X25519+ML-KEM-768; meta {"name":"statement.pdf","type":"application/pdf"}; wrote 1,284,772 bytes
Tamper tests (from the suite, run against a real upload): swapped chunks, dropped chunk, truncated tail, flipped byte, edited header timestamp -> all TAMPERED; stranger's key -> NOT_A_RECIPIENT; stranger relabelled with the manager's kid -> WRONG_KEY; recovery key with no ML-KEM half opening a hybrid-only envelope -> NO_PQ_KEY (so recovery is always included as a classical wrap).
Passwords: deriveLoginKeys gives the server an auth key (stored as Argon2id) and the device a wrap key; the manager's private bundle is stored wrapped under it with context user:<email>. Recovery code issued once.
Next steps
- Keep root.private.json offline; rotate the directory by re-signing with new recipients.
- Mask identifiers before any plaintext leaves the workstation for a third-party model.
- A second implementation (Kotlin, Swift) is correct when it passes
test-vectors.json.
Connects securely to your tools. The creator never sees your data.
About this skill
Encrypt a document on the client so the server stores bytes it cannot open, to several recipients at once, with the whole file authenticated and the file name hidden. Written as a spec to be re-implemented in another language and proven against published vectors.
Format (MRE1)
"MRE1" || len || canonical JSON header || chunks. One random content key, wrapped once per recipient: X25519 ephemeral agreement, HKDF-SHA-256 with a salt bound to the ephemeral key and the recipient's keys, AES-256-GCM over the content key. Recipients that publish an ML-KEM-768 key get a hybrid X25519 + ML-KEM-768 wrap when the runtime supports it; openers lacking the half fail closed. Content is split into AES-256-GCM chunks whose nonce carries the chunk index and a last-chunk flag, with the header's SHA-256 as AAD, so reordering, dropping, truncating or editing chunks, or editing the header, all fail authentication. File name and type live inside the ciphertext. Key ids are recomputed from the key material so a forged id is refused.
Also in the module
Ed25519 signed statements over canonical JSON (approvals, consents, attestations); a recipient key directory signed by an offline root key that clients pin, so a compromised server cannot add a key; PBKDF2 (600k) then HKDF login derivation that splits an auth key for the server from a wrap key that never leaves the device; wrapped private bundles with an AAD context; Crockford base32 recovery codes with misread normalization.
What you get
envelope.mjs (one file, browser and Node Web Crypto, no packages), envelope-cli.mjs (keygen, seal, header, open, directory, verify-directory), reference/spec.md, test-vectors.json with a generator, and 11 tests covering every tamper case, wrong keys, hybrid fail-closed, login and recovery derivations, directories, and the vectors.
Requirements
Node 20+; hybrid wraps on Node 24.7+ (ML-KEM-768 in Web Crypto). No network.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Web client protection requires native pinning. File sizes/times remain metadata-visible. ML-KEM-768 requires experimental Node 24.7+ flags. Kotlin implementation not included.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 19 days ago
- Software
Node.js 20+
ML-KEM-768 hybrid wraps need Node.js 24.7+.
Permissions
Shell runs node for the tests, the vector generator and the CLI. Read files: key records and envelopes you name. Write files: generated key files (private file written with mode 600), sealed envelopes, opened plaintext, the signed directory, test-vectors.json. No network, no environment variables.