Sealed Documents
Written for GOVW's own use and published openly: take what's useful, and tell us what's wrong.
A sealed document is an ordinary file anyone can hold and nobody can read. Its key stays on the server and is released for one open at a time, to a signed-in device, and every open is logged. The reader draws each page as a picture with the viewer's name on it, so there is no text to copy, and a copy that leaks points back to whoever opened it.
1Terms
| Term | Meaning |
|---|---|
| Sealed file | A JWE in compact form holding the document. Safe to store, email or publish. |
| Document key | A random 256-bit key, one per document, kept only by the server. |
| Issuer | The site that sealed the document and releases its key, named in the file's iss header. |
| Reader | The issuer's own page that checks a sealed file, gets the key and draws the pages. |
| Open | One release of the key to one signed-in device, logged with an open ID. |
2The sealed file
A JWE (RFC 7516) in compact serialization: five base64url parts separated by dots.
BASE64URL(header) . "" . BASE64URL(iv) . BASE64URL(ciphertext) . BASE64URL(tag)
header: {"alg":"dir", "enc":"A256GCM", "zip":"DEF", "kid":"sample-packet",
"typ":"alpq-sealed-doc", "cty":"application/alpq-pages+json",
"iss":"https://hackthis.alpq.us"}
alg: dir: the key is used directly and never travels with the file, so the second part is empty. That is what makes a found copy useless.enc: A256GCM: AES-256 in GCM mode. The header is the additional authenticated data, so changing any header field, includingissandkid, breaks decryption.zip: DEF: the payload is compressed with raw DEFLATE before encryption, as RFC 7516 allows.kid: the document ID the issuer uses to find the key. 3 to 40 lowercase letters, digits or dashes.typ,cty,iss: what the file is, what the payload is, and where it opens. Other JWE tools ignore fields they don't know.
The issuer MUST generate a fresh key and a fresh 96-bit IV for every document, MUST NOT put the key in the file, and SHOULD keep it in storage that only the key-release service can read.
3Pages as drawings
The payload is JSON: {"v":"0.1", "title":"…", "pages":[{"w":612, "h":792, "svg":"…"}]}. Each page is an SVG in which every letter has been converted to its outline, so the file contains shapes and no text.
- The sealing tool MUST reject a page whose SVG still contains a
<text>element. - Every page SVG MUST pass the same checks as any SVG the site serves: no scripts, event handlers or outside links (ALPQ's
svg-scan). - Size, measured on the test sample: about 11 KB per page compressed, against 51 to 63 KB for the same page as a 150-dpi PNG, and the drawings stay sharp at any zoom.
4Opening a document
- The reader reads the header and checks it (section 5). Nothing is sent anywhere before this check passes.
- If the person isn't signed in, the reader holds the file, asks them to sign in, and continues after sign-in.
- The reader calls
POST /api/doc/openwith{"id": kid}, signed by the device key and carrying the session, as every request in the QR login spec. - The server checks the session belongs to that device key, records the open (user, device, time, rough location, open ID, running count) and returns the key with the details for the watermark.
- The reader decrypts in memory, decompresses, draws each page onto a canvas, and stamps the watermark into the picture.
Opens are rate-limited per device key (20 a minute in the test site). Revoking a person's access, or deleting a document's key, makes every copy they hold unreadable from then on.
5Reader rules
A reader MUST:
- Accept only files with exactly five parts,
typ: alpq-sealed-docand a validkid. - Open only files whose
issis its own site address, or that have noiss. It MUST NOT follow an address a file names. A file can be crafted by anyone; trusting its address would let a fake site collect sign-ins. - Refuse to show anything when decryption fails, and say the file was changed or damaged.
- Draw pages as pictures only, with no text layer, and stamp each page with the viewer, the time and the open ID: a light diagonal pattern and a footer line.
- Show a notice naming who opened the document, on which device and when, and asking them not to share it.
A reader SHOULD turn off printing, the context menu and dragging on the pages, and SHOULD clear the drawings when the document is closed or the person signs out. These are speed bumps, and the spec says so.
6Security considerations
| Threat | Defense here | What remains |
|---|---|---|
| A copy is found, forwarded or published | Unreadable without a key release; every release logged | None for the file itself |
| A copied session token | Key release needs the device key that owns the session | A fully compromised device |
| Editing the file (header or body) | The header is authenticated data; GCM refuses any change | |
| A file pointing at a look-alike site | Reader opens only its own iss; passkeys work only on the real site | |
| Copying text | No text exists: letters are drawn shapes | Text recognition (OCR) on a screenshot |
| Screenshots and photos | Per-viewer watermark points back to the source | Cropping or retyping |
| Reading the browser's memory | Key used once and dropped; drawings cleared on close | A person with developer tools during an open |
| Theft of the key store | Keys separate from files; storage readable only by the release service | Keys at rest are not yet wrapped by a separate master key |
7Privacy
- The open log holds the username, a device description, the time, a rough IP-based location and the open ID, kept 90 days in the test site.
- Watermarks show the viewer's own name on their own screen. They exist to trace leaks, not to profile readers.
- No tracking: no third-party scripts, cookies or analytics in the reader.
8Known gaps and questions
- Server-side drawing. In 0.1 the browser receives the page drawings. Rendering on the server and streaming only what's on screen would keep even the shapes off the device.
- Shuffled shapes. Each letter is the same shape every time, so someone could build a "this shape is A" table once. Shuffling and slightly varying the shapes per open would make every open a fresh puzzle.
- Invisible fingerprint. A per-open variation in spacing or pixels, so a photo of a cropped page still identifies the source.
- Accessibility. Pictures are invisible to screen readers. An accessible copy on request, logged like any open, is needed, and is required by law in some cases.
- Per-document access lists. In 0.1 any signed-in test account can open the sample. Real use needs a list of who may open each document, and expiry dates.
- Key wrapping. Keys at rest should be wrapped by a master key in a key-management service.
- Opening from the desktop. As an installed web app, the reader could register
.jwefiles to open on double-click.
Questions for reviewers:
- Should
issbe a registered JWE header name, or stay private to this format? - Is a per-open approval on the phone (QR and Face ID for every open) worth the friction for the most sensitive documents?
- What should a reader show when the key service is unreachable: nothing, or the title only?
9Changes
| Version | Date | Change |
|---|---|---|
| 0.1 | 2026-10-27 | First draft; demo on the test site, with drop-a-file reading. |
10References
- RFC 7516: JSON Web Encryption (JWE) · RFC 7518: JSON Web Algorithms (JWA)
- RFC 1951: DEFLATE Compressed Data Format
- W3C Scalable Vector Graphics (SVG) 2 · WHATWG Compression Streams
- ALPQ Cross-Device QR Login (sign-in and device-bound sessions)
- Tools in the test site: PyMuPDF (page drawings, sealing only), Python
cryptography(sealing), the browser's own WebCrypto (opening)