Expand description
Share-link generation, encapsulation crypto, and the recipient-side sharing::open_scope
path. Always compiled: it depends only on cbor + crypto, both of which
target wasm32-unknown-unknown, so the browser share viewer (via capsule-wasm) can unwrap
a link client-side. The native issuer (ShareLinkIssuer on capsule-library’s Workspace)
is not needed in the browser; only the pure crypto + recipient-open path is.
Share links — link generation and capability validation (SSoT: Share Links).
A share link grants view-only access to an asset or album to a recipient with no
Capsule account: https://server.tld/s/{opaque-id}#{secret}. The fragment secret
carries the decryption material and never reaches the server; an optional passphrase
wraps it a second time via the password-based KDF, unwrapped client-side (the
server stores and returns only the wrapped material). The serving endpoints live in
the server’s share module; this module owns link generation, the encapsulation
crypto, and the recipient-side open_scope path.
§Cryptographic shape
Cryptography — Keys § Non-registered accounts owns the shape: “we encapsulate the decryption keys around the secret stored in the link … the password-based KDF adds a second encapsulation layer on top of the link secret.” Concretely, per link:
- A fresh random link secret (
fragment_secret,LINK_SECRET_LENbytes) is drawn from the CSPRNG. It is the URL fragment#{secret}and never reaches the server. - The scope’s
ScopeMaterial(a single file key, or an album’s AMK ledger) is serialized to canonical CBOR and sealed underHKDF(link_secret, salt=opaque_id)— the link-secret encapsulation. The sealed bytes are opaque to the server. - If a passphrase is supplied, that sealed blob is wrapped a second time under
an Argon2id key (
crate::crypto::pwkdf) — the passphrase never leaves the client, and the server stores only this wrapped form (served from/s/{opaque-id}/wrapped-secret). SeeWrappedScope.
The recipient reverses the layers with open_scope:
Argon2id-unwrap (client-side, iff passphrase-protected), then link-secret-unwrap with the
fragment secret.
§The record a viewer starts from
What the viewer needs besides the keys — each covered asset’s content address and key-free
crypto parameters — is a ShareMetadata record, canonical
CBOR sealed under HKDF(link_secret, salt=opaque_id, info=share-metadata/v1) and uploaded as
the blob at the link’s metadata_hash. publish_share
builds it and open_share_metadata opens it. A
link-only scope travels inside the record; a passphrase scope is served only from
/s/{opaque-id}/wrapped-secret, so the fragment alone never opens what the passphrase guards.
Structs§
- Revocation
Record - A published revocation record. The serving endpoint refuses a link once its record exists (within its fail-closed cache window — SSoT: Share Links Security Contract).
- Share
Link - An issued share link: the server-held record fields plus the fragment secret the issuing client places in the URL. The fragment secret never leaves the client.
- Share
Link Id - Identifies an issued share link for revocation. Internal owner-held handle (never in
the URL), so a creation-time-leaking UUIDv7 is appropriate here — unlike the
URL-exposed
ShareLink::opaque_id, which must be non-structured. - Share
Link Record - The issuer-held record for one live share link — the authoritative state the serving endpoint consults: the opaque id it is addressed by, the scope it resolves to, the server-held wrapped material, expiry, and any revocation record.
- Share
Metadata - The record a share viewer starts from, sealed into the blob at the link’s
metadata_hash(GET /s/{opaque-id}names the hash;/s/{opaque-id}/blob/{hash}serves the bytes). - Share
Publication - What an issuing client hands the server for one link: the sealed metadata blob to upload, and
the fields of
POST /v1/shares. - Shared
Asset - One covered asset as a share viewer is served it: every key-free parameter it needs to
fetch the asset’s ciphertext and decrypt it under the opened
ScopeMaterial.
Enums§
- Scope
Material - The scope’s decryption material — the “decryption keys” that get encapsulated into the link. Serialized to canonical CBOR before sealing, so two implementations encapsulate byte-identically.
- Share
Scope - What a share link points at. The
{opaque-id}itself carries no scope — the server resolves scope from the link record, so the URL leaks nothing. - Sharing
Error - Failure surfaced by share-link issuance, revocation, and recipient-side opening.
- Wrapped
Scope - The server-held, opaque encapsulation of a link’s
ScopeMaterial. The server can neither open it nor observe the passphrase; it only stores and returns these bytes.
Constants§
- LINK_
SECRET_ LEN - Length of the random link secret carried in the URL fragment. 32 bytes = 256 bits, comfortably above the design’s ≥128-bit floor for the link secret.
- OPAQUE_
ID_ LEN - Length of the opaque URL-path id: a full 128 bits of CSPRNG entropy — never a structured/UUIDv7 id whose embedded timestamp would cut real entropy to ~62 bits (SSoT: Share Links Security Contract — Opaque-id entropy).
- SHARE_
METADATA_ VERSION - Schema string of the share metadata record. A reader refuses any other value rather than guessing at a shape it does not know.
Traits§
- Share
Link Issuer - Issues and revokes view-only share links on a trusted client — the seam
lifecycle::Workspaceimplements. Issuance encapsulates the scope’s decryption material around a fresh link secret; the optional passphrase adds the second, client-side-unwrapped encapsulation layer.
Functions§
- encapsulate_
scope - Encapsulate
materialaround a fresh link secret, optionally adding the Argon2id passphrase layer. Pure crypto — the caller supplies the CSPRNG-drawn secrets and the resolved material, so it is unit-testable without aWorkspace. - generate_
opaque_ id - Draw a fresh opaque URL-path id: a full 128 bits of CSPRNG entropy, not a structured or sequential identifier (SSoT: Share Links Security Contract).
- open_
scope - Open a link’s encapsulated
ScopeMaterialclient-side — the recipient path. - open_
share_ metadata - Open the sealed metadata record a viewer fetched from the link’s
metadata_hash— the recipient half ofpublish_share, run client-side with the URL’s opaque id and fragment. - publish_
share - Prepare everything the server needs to serve a link whose scope is already encapsulated
(
wrapped, fromencapsulate_scopeunder the samefragment_secretandopaque_id).