Files
synchronicity/docs/vault-pddb-research.md
Greg ShuflinandClaude Opus 5.5 d46a858f3e humans: interactions are events, in the code as on screen
The Humans screen's second tab is Events, and the thing it lists is an event
everywhere: DocumentType::Event, Event/EventSummary, log_event, events_with,
the FFI's EventItem/EventDetail, HumansCmd::Events, syn humans events, the
desktop's EventsView/EventForm and the copy ("Log an event", "an event only
you were at"). "Event" fits a walk taken alone, which "interaction" never
did, and one name in the code and on screen is one less translation.

EdgeKind::Attendee and PropertyKind::OccurredOn keep their names: an event
has attendees and occurs. Documents' tag for the type is EVT now, not MET.

DocumentType rides bare on the sync wire, so the rename is a wire change and
SYNC_PROTOCOL_VERSION is bumped. A store holding interactions doesn't read
them as events; delete and recreate it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 23:55:28 -08:00

30 KiB

Vaults and the PDDB: what a plausibly deniable database has to teach

Research notes mining Xous' Plausibly Deniable DataBase (PDDB) for the Vault design, which is specified in docs/data-model.md but almost entirely unbuilt. The PDDB is the closest prior art this project has: a small team of experienced engineers spent a lot of effort on "one store, several keying domains, one of which the user can lock" and wrote down both the mechanism and the ways it leaks. Sources are listed at the end; the primary one is the Xous book, chapter 9.

This document is research plus a recommendation. It does not commit to an implementation. §7 is what it argues should be decided now, while nothing constructs a second vault and every schema choice is still free.


1. The distinction that governs the whole comparison

The PDDB and Vaults look alike and are aimed at different threats.

  • Confidentiality is: an adversary cannot read the data. A locked vault gives this. The lock is visible; the adversary knows there is something they cannot read.
  • Deniability is: an adversary cannot establish that the data exists. This is a much stronger claim, and every part of the PDDB's architecture — the bespoke page table, the noise-filled backing store, the free-space cache, the refusal to store a salt — exists to buy it.

docs/data-model.md describes the Passphrase vault as covering "the cop-with-open-phone scenario". That is a confidentiality threat: the device is unlocked and in someone else's hands, and the secrets vault stays shut because its key was never stored. A Passphrase vault as specified already solves it, completely, and needs no deniability at all.

The PDDB targets a different scene: the device is seized and imaged, the boot PIN is compelled, and the question is whether the forensic image proves a second Basis exists. Nothing in the current Vault design addresses that, and §5 and §6 argue that reaching for it in a syncing ensemble would cost far more than it did for a single device with 100 MiB of raw FLASH.

So the value of this exercise is not "how do we get deniability". It is: the PDDB is a locked-domain design that was pushed all the way to its limits by people who then wrote down where it breaks. Most of what breaks it breaks locked domains too.


2. Where vaults are today

Piece State
VaultId on every Document, Artifact, BlobRef Built (vault::VaultId)
VaultStore — encrypted vault keys in SQLite Built (stores/vault.rs), one row per vault: (vault_id, nonce, ciphertext, updated_at)
Default vault key, EnsembleDerived via HKDF, wrapped under the node key Built (vault::derive_ensemble_vault_key, encrypt_vault_key; set up in ensemble/init.rs)
Blob content encryption, convergent, chunked AEAD Built (vault::BlobCipher, ADR 0028)
Downstream key domains derived from the vault key Built — derive_blob_content_key, NameKey::from_vault_key (p2p/sealed_name.rs), credentials.rs
Property and Artifact value encryption Not built. The columns are BLOB so it can be added without migration (stores/document.rs:223, stores/artifact.rs:87), and that is all
A second vault of any kind Not built. Nothing constructs VaultKeySpec::Passphrase; SharedKey is a reserved name with no body
Persistence for a Vault descriptor (name, key_spec) Does not exist. default_vault() is a function that returns a constant. There is no table for a vault's name or its KdfParams
Vault key exchange between nodes Not built (docs/document-sync.md §Vault identity calls it future work)
Vault lock/unlock as a runtime state Does not exist. blob_store::vault_key resolves a key by id or returns VaultKeyNotFound; there is no locked state, only a missing key
Any UI on any modality None

Three claims in the docs are ahead of the code, and matter for what follows:

  • docs/document-sync.md §Vault identity says a receiving node "cannot decrypt the content without the vault key". True for blob bytes only. PropertyRecord.value (p2p/doc_sync.rs:350) is MessagePack plaintext on the wire and plaintext in SQLite at both ends. So today the vault boundary is enforced for blobs and for nothing else.
  • SyncScope (stores/document.rs:2810) has no vault predicate. Every document row syncs to every admitted node, vault_id and all.
  • docs/data-model.md says property/artifact/blob encryption "is the remaining step". Blobs are done; the sentence should now name only the other two.

3. How the PDDB works, in the parts that are load-bearing

A Basis is a named, password-protected overlay. The user's view is the union of all unlocked Bases; a name collision resolves to the most recently unlocked one; the API can always name a Basis explicitly. .System is created at format time, is always mounted, and its presence is what "mounted" means.

Four mechanisms do the work:

  1. Orthogonal page tables. Every Basis has an identical 64-bit virtual address space, and all of them share one physical page table. Entries are 128-bit AES-ECB blocks holding a virtual page number, flags, a 32-bit nonce and a 32-bit murmur3 checksum. Bases do not collide because each Basis encrypts its entries under a different key. Mounting means trial-decrypting every page-table block (~25,000 of them) and keeping the ones whose checksum passes — a cheap filter, with the real authentication deferred to the AES-GCM-SIV MAC on the data page.
  2. IND$-CPA everywhere. Data pages are indistinguishable from random, and free space is pre-filled with CSPRNG noise. A locked Basis is bytes that look like unused space. This is the deniability.
  3. No record of a Basis exists anywhere. Not the name, not the password, not a hash, not a salt. A Basis key is derived from name + password hashed against a global salt_base — and the derived salt is a function of the secret material itself, because a stored per-Basis salt would be exactly the record that betrays the Basis. Lose the name or the password and the Basis is deleted, by construction.
  4. The Free Space Cache (FSCB). Knowing the true free space would reveal hidden data, so the system deliberately only ever knows some of it — by default about half, ±10% of TRNG fuzz, capped at ~7% of capacity. When it is exhausted, the user is asked to enumerate every secret Basis so free space can be recomputed; a Basis not presented at that moment can have its pages handed out and its data destroyed.

Two vocabulary items are worth keeping: enumerate (prove you know the Basis so its used pages can be counted, then zeroize the keys) versus unlock (mount it, cache the keys, put it in the union view). They are different operations with different costs and different disclosures.


4. Ideas worth taking

A. The union view, and the rule for where a write lands

The PDDB's most transferable idea is not a mechanism, it is a set of view semantics, stated up front:

reads come from the union, most-recently-unlocked wins; writes go to the most-recently-unlocked Basis that has the key, else create there; the API can always name a Basis explicitly.

Synchronicity gets the read half nearly free — a document whose vault is locked simply is not in the result set — but has no answer at all for the write half. Nothing in the code or the docs says which vault a newly created document lands in, because nothing can yet put one anywhere but the default: Document::new (documents/document.rs:440) takes a type, a parent and an origin node, and assigns vault_id: DEFAULT_VAULT_ID itself. The parameter has to be introduced, and the moment it is, every call site becomes a policy decision.

Take the PDDB's default (most recently unlocked, overridable), and take its warning with it, because the project has the exact hazard bunnie flags:

Administrative operations, especially ones that deal with non-sensitive settings, should generally specify the system basis explicitly so that options don't mysteriously reset or disappear when secret Bases are mounted or unmounted.

Agent settings are documents here (ADR 0018). Under a most-recently-unlocked default, changing a setting while the secrets vault is open writes the setting into the secrets vault, and locking it reverts the setting with no explanation. That is a bug the PDDB shipped, wrote down, and worked around by convention. The better fix is that the settings document's vault is pinned to the default at the type level, not left to each agent to remember.

The same test applies to anything else the system writes on the user's behalf rather than at their direction: jobs, sync policy, peer health, provenance.

B. Enumerate vs. unlock — and the state the UI is missing

Synchronicity already refuses to conflate "the bytes are elsewhere" with "there are no bytes": DocumentAvailability is Local / Remote / Nowhere (documents/availability.rs), and the "Absence is not an error" principle exists because rendering an empty buffer for text that demonstrably exists invites the user to retype it and fork the document.

A locked vault introduces a fourth condition that is orthogonal to all three: the bytes are right here and cannot be read. If it is left to fall out as a VaultKeyNotFound at decrypt time, the document will render as Local — everything present — and then produce an error or a blank at the moment of opening. That is precisely the failure the principle forbids, arriving through a new door.

So: a locked vault needs its own state, named in the type system and rendered deliberately, with its words in copy.rs (a copy::vault module) rather than invented per screen. The PDDB's enumerate/unlock split is also worth keeping as vocabulary even without an FSCB, because the same two operations exist here: prove you can open this vault so its size can be counted is not the same act as open it and put its documents in the view.

C. A stored per-vault salt is a stored per-vault record

This is the single most valuable thing to take from the PDDB, and it is a schema decision that is free today and expensive later.

VaultKeySpec::Passphrase { kdf_params: KdfParams { salt, m_cost, t_cost, p_cost } } implies persisting, per vault, a random salt and a set of Argon2 parameters. VaultStore already has a row per vault. Persist a second vault at all — its name, its salt, even just its id — and the store now contains a positive record that a second vault exists. Every node that holds the store holds that record.

The PDDB will not do this. It derives the salt from name + password + salt_base, where salt_base is one global block of TRNG bytes that exists whether or not any secret Basis does. The cost is real and is accepted: a mistyped name is indistinguishable from a wrong password, and a forgotten name is unrecoverable data loss with no error message to tell you so.

Two conclusions, and they are different:

  • If vaults are locked-but-visible (the recommendation in §7), storing the salt is correct, and the UX is enormously better for it: locked vaults can be listed, named, and offered for unlock. Say so on purpose rather than by default.
  • If a hidden vault is ever wanted, it cannot reuse this shape at all. It needs a global salt block, no row of its own anywhere, and a name that is part of the key derivation. That makes it a distinct VaultKeySpec variant with distinct storage rules, not a flag on Passphrase.

D. Deriving several keys from one, with domain separation

The PDDB derives two keys per Basis — a page-table key and a data key — from one password, via HKDF-SHA256 with different info strings. This project already does the same thing, and does it in more places and more cleanly: derive_ensemble_vault_key → derive_blob_content_key, NameKey::from_vault_key, each with its own context string, each documented as to why the domains are kept apart. No change needed; recorded as convergent evidence that the pattern is right.

E. Key commitment, and what "the passphrase was wrong" will mean

The PDDB was bitten here. AES-GCM-SIV is not key-committing (the "Salamanders" result): a crafted ciphertext can open validly under two different keys. The fix was a hand-rolled key commitment in each Basis' root page, which the book flags as hand-rolled because no blessed standard existed.

ChaCha20-Poly1305 has the same non-committing property, so the same care applies the moment there is a passphrase to check. Today nothing trial-decrypts — a vault key is looked up by id — so the exposure is nil. It arrives with the first Passphrase vault, because "did the user type the right passphrase?" has to be answered somehow, and the obvious implementation is to try opening something and see.

What matters when writing that:

  • The verifier must not be a stored hash of the passphrase, for §4C's reason.
  • A failed unlock must be indistinguishable from a wrong vault name, if hidden vaults are ever in scope; if they are not, a clear error is better.
  • Whatever ciphertext is used as the verifier must be one the user's own node wrote, so a non-committing AEAD cannot be exploited by an attacker-chosen blob. A committing construction (an explicit key-commitment tag) is the belt-and-braces answer and is cheap to add to a format that does not exist yet.

F. Bind the vault id into the key wrap (applied)

encrypt_vault_key/decrypt_vault_key (vault/mod.rs) sealed with empty AAD:

cipher.encrypt_in_place(nonce, b"", &mut buf)

Every wrapped key on a node is sealed under the same node-local wrapping key, so the vault_id — the row's primary key, and not bound to the ciphertext — was the only thing saying which vault a key was for, and a row's ciphertext was interchangeable between vaults. The threat is small on its own, since writing store.db means owning the node, but the codebase's standard is stricter than this everywhere else it seals something: blob chunks bind plaintext_hash || chunk_index so a chunk cannot be spliced elsewhere, and sealed_name binds the node pubkey so a name cannot be lifted onto another member's announcement.

vault_key_aad now binds the id, so a misfiled row fails authentication rather than handing back a plausible key for the wrong vault. It changes the wrap format and existing vault_keys rows no longer unwrap, which the project's status makes acceptable.

G. An offline reader for the store

backalyzer.py takes a PDDB backup image plus the keys, decrypts it, walks every Basis/dictionary/key, checks consistency, and can dump everything. It is presented as a backup tool; its more interesting properties are that it is a consistency checker and a recovery path that does not need the device.

Synchronicity has neither. ensemble/reseed.rs moves a store into a new ensemble, which is a different job. A syn store verify that walks documents → artifacts → blob files, opens every sealed chunk, and reports what does not reconcile would be worth having independently of vaults — and once blobs live under several keys, it is the only way to answer "what in this store can I still open?" The PDDB's own warning applies to the recovery half: such a tool is handed every key at once, so it belongs on a trusted machine and its documentation should say so.


5. What does not transfer, and why

Worth writing down so nobody re-derives these.

  • Noise-filled backing store. The PDDB owns a fixed 100 MiB FLASH region and pre-fills it with CSPRNG output. Synchronicity is a SQLite file plus a git-style sharded directory of blob files on someone's ordinary filesystem. There is no "free space" to be indistinguishable from — there are directory entries, file sizes, mtimes, and a database with a row per document. Getting the PDDB's core property would mean a fixed-size container file, i.e. a different storage engine.
  • Make-before-break journaling. Ten pages of FLASH and a bespoke protocol to survive power loss during a page-table update. SQLite gives this away. Worth noticing how much of the PDDB's complexity is paid for a durability guarantee this project gets for free; the only analogous exposure here is blob files living outside the transaction, which TempBlob's write-temp-then-rename already covers.
  • Device-DNA in the AAD. The PDDB binds each page's AAD to the FPGA's silicon serial so a raw copy to another device is inert. Synchronicity must do the opposite: the whole point is that a vault opens on every node. Binding anything node-specific into content AEAD would break sync. (The version half of their AAD is already covered here, since the rotation counter feeds the key derivation, so an old key simply fails to open new data.)
  • bcrypt with work factor 7. A concession to a single-issue in-order 100 MHz RV32 core, and it drags in bcrypt's 72-byte password truncation, which surfaces in the PDDB's API as a documented password length limit. Argon2id — already a dependency, already the plan in TODO.md — has neither problem. Do not copy the parameters or the limit.
  • The per-device pepper. The PDDB mixes in a pepper from the key ROM so brute-force tables cannot be reused across devices. It works because the pepper lives somewhere an attacker with a disk image does not reach (it takes JTAG). Synchronicity has no such enclave, so a pepper in the store is just a salt under another name, and a per-vault random salt already provides the cross-target property. The idea does not transfer unless a hardware root of trust does.
  • The FSCB itself. Its purpose is to lie about free space. With no fixed container there is no free space to lie about. Its lesson transfers and is in §6.

6. Pitfalls, most of which bite harder here

6.1 API leakage — and this project's version of it

The book's frankest section: a deniability-naive application defeats the whole system by keeping a path to a secret file in a non-secret place. Their example is a dangling contact reference that throws an error, which betrays the contact. Their rule of thumb is that applications must treat the store as the authoritative index and stop caching listings — "unlearn the pattern of creating local copies of directory listings", and re-query every time a view is rebuilt.

Synchronicity's structure is more exposed than a filesystem's, because the things that link documents together are themselves first-class synced records:

Surface What it would leak about a locked vault
documents/wikilinks.rs The WikiLink edge targets an id, deliberately, so it survives a rename — but the body of the linking note still contains the literal [[Ada Lovelace]]. The link text is the leak, it lives in the unlocked note, and it survives the target being locked.
Edges (stores/document.rs's get_edges_from, e.g. EdgeKind::Attendee) An edge rides with its from document on the wire. A default-vault Human edged to a locked Event carries the target id in plaintext, on every node.
parent_id A locked child of an unlocked collection means the collection's children count and tree shape disagree with what is visible.
Command palette / search (docs/command-palette-and-search.md) Any persisted index built over unlocked content is a cache of exactly the kind bunnie says to stop keeping.
Recents, "open recently", jobs Same. A job record names what it worked on.
Provenance (ADR 0038) Records where a document came from, whether or not you can read it.

None of this is hypothetical or far off — the edges and wikilinks exist and are synced today. The mitigation for a locked (not hidden) vault is modest and mostly about not producing errors: a link into a locked vault should render as locked, and a view should never fail because part of it is sealed. The mitigation for a hidden vault is that most of these records cannot exist across the boundary at all.

6.2 "Absence is not an error" and deniability point in opposite directions

The project's principle says that a document whose content is elsewhere is a state to render, clearly and specifically. Deniability requires that a locked vault's contents be indistinguishable from nothing at all. You cannot do both: rendering "this is in a locked vault" is a disclosure, and rendering nothing is the retype-and-fork bug.

This is a genuine, unavoidable fork, and it is a second reason to answer it in favor of locked-but-visible — the principle is load-bearing across every agent and every modality, and it was written first.

6.3 Accounting leaks — the FSCB lesson without the FSCB

The FSCB exists because any accounting the system keeps about storage discloses what is stored. That generalizes past free space, and Synchronicity has several accounts:

  • copy::ContentRowCopy::stored() renders "N of M artifact(s) held (X of Y)" from content_ledger::TypeLedger. The ledger is entirely vault-blind — grep content_ledger.rs for vault and the only hits are in tests. A locked vault's blobs would be counted into both the numerator and the denominator.
  • eviction.rs is equally vault-blind. Two consequences, and the second is worse than a leak: eviction may delete the only copy of a locked vault's blob, and the last-copy guard (ADR 0013) may name a locked document while refusing to. The PDDB has the same failure — a Basis not presented during an FSCB refill can have its pages reallocated and its data destroyed — and it handles it by stopping and asking the user to enumerate every Basis. That is the shape of the answer here too: destructive space reclamation has to know what it cannot see.
  • node_content_status / node_document_status / presence: possession evidence is per-blob and vault-blind, so "who holds this" answers for locked content as readily as for anything else.

6.4 Sync is the deniability killer, and it is structural

The literature's threat hierarchy is single-snapshot → multi-snapshot → online/continuous adversary, and the PDDB explicitly targets the first. Its own book concedes the second: with several backup images an adversary can diff the ciphertext and map which blocks are definitely used, "to an asymptotic limit of an adversary with a precise log of every write to disk, leading to zero deniability". The mitigation is pddb churn — re-nonce every used block, re-noise every free one — which takes 20-30 minutes and burns FLASH lifetime, and is therefore optional and rarely run. A published multiple-snapshot attack detects moderately sized hidden volumes from two snapshots with high probability.

An ensemble is a machine for producing snapshots.

  • Every peer holds a copy of the catalog, including vault_id on every document row (p2p/doc_sync.rs:247). A locked vault on one node is fully enumerated on every other node's disk. Locking discloses nothing less the more nodes there are.
  • A revoked node keeps everything it had (docs/NODE_REVOCATION.md §3, and the §3c vault-key-rotation gap). That is a dated snapshot in the hands of exactly the party the revocation was aimed at.
  • Convergent encryption makes blob ciphertext deterministic by design — that is what buys dedup. So a blob's file name is a stable identifier of its ciphertext across time and across nodes, sitting in a directory entry. Two images of the blob store diff perfectly. (Cross-vault unlinkability does hold, and is the good half: the same file in two vaults has two unrelated hashes.)
  • Sync traffic itself is an online side channel, which is the strongest adversary class in the taxonomy.

The conclusion is not subtle: deniability and sync are close to incompatible at the catalog layer. A vault that is meant to be deniable would have to not sync at all, or sync on a plane of its own that does not put vault_id in a record every peer keeps — which is a protocol redesign, not a feature. That is a reason to defer deniability deliberately, not a reason to half-build it.

6.5 The bootstrapping trap

Raised against the PDDB and never resolved: a user has to remember the secret Basis' name and password with no on-device record, and any list of Basis names they keep is itself the leak. One commenter called it a self-referential UX trap. It is the direct consequence of §4C, and it is the practical reason most deniable systems go unused.

The escape is the same fork: a locked-but-visible vault can be listed by name in the UI, which removes the trap entirely at the cost of the deniability that was never really achievable here anyway.

6.6 The loss-of-data attack

bunnie names it: an adversary who can write to the device can fill the free space with garbage and destroy any hidden Basis, without ever finding it. The local analogue is §6.3's vault-blind eviction, which does this by accident. The ensemble analogue is worse — a node that does not hold a vault's key still participates in sync policy and blob possession decisions, so "nobody holds the last copy" can be concluded about content nobody present can read.


7. What to decide now

Ordered by how much they constrain later work.

7.1 Write down that vaults are locked, not hidden. Amend docs/data-model.md §Security/Vault Model to state the §1 distinction explicitly, and to say that a locked vault conceals content, not existence. The "cop-with-open-phone" line stays — it is the accurate threat — but should stop being the only sentence about the threat model, because it currently reads as a deniability claim to anyone who arrives from that literature. Whatever the UI eventually says about a locked vault belongs in copy::vault, once, for all four modalities.

7.2 Give "locked" a state, not an error. blob_store::vault_key returning VaultKeyNotFound is the wrong shape for a vault the user could open by typing something. A locked vault is a state alongside DocumentAvailability's three, and it has to be reachable before render, not discovered at decrypt time — §4B and §6.2.

7.3 Fix the write-target question before there is a second vault. Decide the default (recommendation: most recently unlocked, explicitly overridable, per the PDDB) and pin settings documents and every other system-written record to the default vault at the type level, not by convention — §4A.

7.4 Decide whether the passphrase vault stores a salt. Recommendation: yes, and accept that this forecloses deniability for that variant. Note in long-term-todo.md that a hidden vault, if ever wanted, is a separate VaultKeySpec variant with three non-negotiable rules — no per-vault record on disk, a global salt block, and its own sync story or none — and that the trigger is a threat model that includes a forensic image of a node.

7.5 Close the property/artifact gap or stop claiming it. Right now the vault boundary holds for blob bytes and nothing else, while docs/document-sync.md says otherwise. Encrypting value under the vault key is the intended end state and the columns are already BLOB; the work is figuring out what breaks — anything that filters, sorts, or indexes on a value, and the search index in particular. Until it is done, the doc should say what is true.

7.6 Two cheap things that need no decision. Binding vault_id as AAD in the vault key wrap (§4F) is done. The other is to make eviction, the content ledger, and the last-copy guard vault-aware before a second vault can exist (§6.3, §6.6) — that one is a data-loss bug, not a privacy one.

7.7 Worth having regardless: an offline store verifier (§4G).


8. Documentation drift spotted along the way

Four items, all in the vault sections, all corrected:

  • docs/data-model.md: "the actual encryption of Property/Artifact/Blob content under the vault key is the remaining step" — blob content is done (ADR 0028, vault::BlobCipher). Only Property and Artifact values remain, and the note now says which boundary that leaves standing.
  • docs/document-sync.md §Vault identity: "the receiver cannot decrypt the content without the vault key" is true of blob bytes only. Property and artifact values travel and rest in plaintext, so the section now says what a keyless receiver can actually read.
  • docs/document-sync.md §Vault identity also said the default vault's UUID is HKDF-derived from the ensemble public key. It is the nil UUID (vault::DEFAULT_VAULT_ID, a constant kept from the original placeholder so existing rows need no migration); the key is what HKDF derives, from the ensemble secret. Id and key had been conflated.
  • docs/data-model.md §Vault Key Versioning describes rotation as though version were stored per node per vault. vault_keys has no version column and default_vault() hard-codes version: 1, so the section now marks itself as design and points at TODO.md's revocation phase 3c, which is what wants rotation first.

One item left alone, because it is about sync maturity rather than vaults: docs/document-sync.md's "Explicitly out of scope" list still names artifact values and blob payloads as future protocols. Both exist — p2p::artifact_sync, p2p::blob_sync, and the streaming path in p2p::blob_stream.


9. Sources