Spec

Backup file format spec v1.0

This page is the versioned public spec of 默·Tacet backup files: format schema, crypto parameters, versioning strategy, and the attachment/quota notes surface. Completeness promise: a third party who never sees this repo can still recognize the file format from this page and, with the passphrase, decode its contents (the spec text is self-sufficient; the reference reader and samples are on record - access channel in the reader section).

Last updated: 2026-11-27

Scope and completeness promise

This spec covers the file formats produced by the app's three export/backup channels, with every crypto parameter. Out of scope: app-internal storage, the sync wire, and login credential derivation (the wire layer is documented in the open-source core package's format-spec; see Sources and reconciliation).

The public source of byte-level detail is the npm package @tacet-ink/journal-core: docs/format-spec.md plus docs/vectors/ (frozen test vectors). This page embeds every parameter the backup surface needs, one-to-one with that package.

The three export channels

File names are convention only (the importer never reads the name); the format is self-describing in the content:

tacet-YYYYMMDD[-Nitems].md: plain Markdown, the human-readable channel. Section header ## YYYY-MM-DD HH:MM[ · title]: the timestamp is the exporting device's local time (no timezone); without a title the header is the timestamp alone (no " · " part); sections separated by ---. Not a round-trip channel: title and timestamp fold into the header, no field semantics; no capsule ledger section.

tacet-YYYYMMDD[-Nitems].json: plain JSON, the tacet-plain-v1 disaster-recovery round-trip channel (see the plain JSON section).

tacet-YYYYMMDD[-Nitems]-enc.json: encrypted backup, tacet-enc-v1, tacet-enc-v2, or tacet-enc-v3 (see the encrypted envelope and crypto parameter sections).

tacet-plain-v1 (plain JSON)

{
  "format": "tacet-plain-v1",
  "exported_at": 1795741200000,
  "notes": [ { "note_id", "text", "title?", "created_at", "updated_at",
               "deleted", "synced", "server_seq?", "version",
               "account_id?", "conflict_of?", "from_past?", "author?" } ],
  "capsules"?: [ { "capsule_id", "release_at", "key_hash", "content_digest",
                  "note_id", "attach_refs", "created_at" } ]
}

author is limited to 1 to 4 characters; deleted/synced are 0/1 marks, always present; server_seq/account_id/conflict_of are ledger fields, present when applicable. kind/cred (hidden-item marks) never appear in the plain channel: credential/capsule notes are filtered out before export (zero-knowledge minimization) and are visible only inside the encrypted backup channel (note plaintext payload). The capsules section is locator-only (no field is a key): absent means an old file or a zero-record ledger, byte-identical to the old shape (zero version change).

tacet-enc-v1, v2, v3 (encrypted backup envelope)

{
  "format": "tacet-enc-v1" | "tacet-enc-v2" | "tacet-enc-v3",
  "notes": [ { "note_id", "ciphertext": "jr1b.<base64>",
               "created_at", "updated_at", "version" } ],
  "wrapped": "jr1w. | jr3w. | jr4w.<base64>",
  "salt": "<32 lowercase hex chars, i.e. 16B>",
  "attachments"?: [ { "attachment_id", "note_id",
                      "ciphertext": "jr1c.<base64>",
                      "kind"?: "img" | "file",
                      "size", "created_at", "updated_at", "version" } ]
}

format (envelope version) semantics: v1 = notes only (the historical pre-attachment shape); v2 = notes + attachments[]; v3 = current, the wrap leg upgraded to jr4w., with the wrapped_rec and rec_hash fields removed (account recovery goes over the e2e bind wire, not the backup file). New exports are always v3 (with or without attachments; the attachments field is simply absent when there are none); v1 and v2 are historical shapes and the read side is the compatibility layer (old files always read).

The version field on each note and each attachment = that item's LWW revision, incremented on every edit; import keeps the value as-is (never resets it).

Crypto parameters

AEAD = AES-256-GCM; IV 12B random; tag 16B; ciphertext form = base64(iv‖ct‖tag). noteKey is 32B random, one per file; the wrap plaintext = UTF8(hex(noteKey)) = 64 lowercase hex chars (64B), so the payload of the three backup wrap families (jr1w./jr3w./jr4w., after base64 decoding) is always 92B = iv12‖ct64‖tag16 (the ciphertext segment ct+tag is fixed at 80B); salt-embedded families are 108B (login forms, never in backup files). salt is 16B random, hex in the envelope's top-level salt field (salt external; salt never enters the payload).

Wrap families (KDF generations; the prefix is the version, self-describing dispatch):

jr1w.  PBKDF2-HMAC-SHA256(raw passphrase, salt, 600000 iterations, 32B)
jr3w.  Argon2id(raw passphrase, salt, m=65536KiB, t=3, p=1, tag 32B, version 0x13)
jr4w.  Argon2id(NFKC(passphrase), same parameters)   current (v3 generation)
All three use AAD = UTF8("notekey"); passphrase normalization: jr1w./jr3w. raw, only jr4w. applies NFKC (no trim, no case folding)

Content families (key is always the file's noteKey):

jr1b.  note ciphertext   AAD = UTF8("jr1:<note_id>") (account_id not bound)
jr1c.  attachment ciphertext   AAD = UTF8("jr1a:<note_id>:<attachment_id>")

Note plaintext payload: a JSON object {"v":1,"text":...,"title":...,"fromPast?","author?","kind?","cred?"} (v is always 1; the reader does not check v; v1-era files may carry a bare-string plaintext, and the reader accepts both shapes = compatibility layer; discrimination rule: the payload is the object form if and only if it parses as JSON to an object with a string text field; otherwise (including a JSON object that lacks the text field) it is the bare string form); cred is present only for credential notes, and the reference reader reports presence only, never credential values. Attachment plaintext payload: img = {"v":1,"kind":"img","mime","w","h","b64","src?":"draw"} (w/h = numbers); file = {"v":1,"kind":"file","mime","name","b64","dur?"} (dur only for audio, positive integer seconds; img must not carry name, file must not carry w/h = shapes do not mix).

Versioning strategy (forward / backward)

In-band versioning: the prefix is the version. Any change to KDF parameters, normalization, or AAD = a new prefix; an existing prefix may never change meaning in place; unwrap paths for old prefixes are never removed, and old files decrypt forever, byte for byte.

The envelope format is an explicit whitelist: v1, v2, v3 all read; an unknown tacet-enc-* (a future version) is reported honestly as incompatible, never silently swallowed into empty notes, and never mixed with "file corrupt / wrong passphrase".

Read old, write new: the reader dispatches by prefix (three-family fork); the writer (new exports) only produces the newest generation (current = jr4w.). A file in the user's hands never self-re-encrypts: a KDF generation upgrade never touches old files; the bridge is only the import side.

Attachment and quota notes surface

Attachment file name, MIME, and dimensions live only inside the ciphertext-layer payload; the backup file's plain JSON carries no file name (zero-knowledge minimization). The metadata kind field = content type (img or file), not a file name; the size field = the wire ciphertext string length (jr1c. prefix + base64 character count; not the decoded byte count, and not the original file size).

The format itself sets no file size cap; account-tier quotas (note/attachment limits) live server-side, are not format fields, and the backup file carries no quota fields.

Strict import rule: if any note or attachment fails to decode, or its payload shape is wrong, the whole package is rejected. No half-set ever lands.

Reference reader and samples

In the repo, scripts/spec-reader.cjs is a standalone CLI (node:crypto built-ins + hash-wasm; it imports no business modules and only consumes the format described on this page):

node scripts/spec-reader.cjs --selftest
node scripts/spec-reader.cjs --pass <passphrase> <backup-file.json>
TACET_SPEC_PASS='...' node scripts/spec-reader.cjs   # passphrase via env (never in other processes' ps argv; the local shell history still records the prefix form - run IFS= read -rs TACET_SPEC_PASS; export TACET_SPEC_PASS to keep it out of history)
node scripts/spec-reader.cjs <plain-file>

Access channel (honest sentence): the reader and the samples live in the app repo, which is not published at this stage - run from source in the repo for now; whether they get a public channel (public/ or npm) is decided separately. The text of this page (plus the open-source core package's format-spec and vectors) is sufficient to implement an independent reader, independent of that channel.

The selftest embeds frozen vectors: the RFC 9106 Argon2id no secret/AD vector, the production-parameter KAT, jr1w./jr3w./jr4w. frozen blobs, jr1b./jr1c. content vectors, and wrong-passphrase fail-closed. All green = the parameter table is in sync with this page.

Samples (synthetic data, sample passphrase published): spec/samples/sample-enc-v3.json (passphrase Tacet-Spec-Sample-2026-11-27) plus spec/samples/sample-plain-v1.json and spec/samples/sample-plain-v1.md. The reader decoding the sample successfully is the runnable acceptance closure for this spec.

Sources and reconciliation

Byte-level detail: npm @tacet-ink/journal-core, docs/format-spec.md and docs/vectors/ (kat.json frozen KAT, families.json family vectors). This page's parameters are one-to-one with that package; the public-page gate (the /spec/ section of verify-trust-pages) mechanically asserts this page's key literals (format names, KDF parameters, AAD forms, family prefixes) against transcription drift.

Core is an open-source package (version pinned in the repo's dual fields); the app layer is not published. Reader + vectors + this page = the independently verifiable surface.

Honest boundary

This spec covers the backup-file surface only; app internals (sync wire, login, local storage) are not on this page. The boundary of "a third party can decode": with this page and the reader, a holder of the passphrase can recognize and decrypt a backup file; that does not mean the app can be rebuilt (the app layer is not open source).

The samples are synthetic data; the published sample passphrase is meaningful only for the samples.

Start writing