···11# Cistern
2233-Cistern is an attempt at implementing a private, personal quick-capture system
44-on AT Protocol. Cistern "items" are encrypted, so that they are only readable by
55-the holder of the correct secret key—stored off-protocol. These items are
66-intended to be ephemeral, and to be deleted after they've been read.
33+Cistern is a private, end-to-end encrypted quick-capture system built on AT Protocol. Items are encrypted using post-quantum cryptography and stored temporarily in your Personal Data Server (PDS), then automatically retrieved and deleted after consumption.
44+55+The system bridges the gap between where ideas are captured and where they are stored long-term. Create an encrypted item on your phone, and it automatically appears in your desktop application, decrypted and ready to use.
66+77+## Architecture
88+99+Cistern is a Deno monorepo consisting of five packages:
1010+1111+### `@cistern/crypto`
1212+Core cryptographic operations using post-quantum algorithms. Implements X-Wing key encapsulation with XChaCha20-Poly1305 authenticated encryption and SHA3-512 integrity verification. Handles keypair generation, encryption, and decryption.
1313+1414+### `@cistern/lexicon`
1515+AT Protocol schema definitions for Cistern record types. Defines `app.cistern.lexicon.pubkey` (public key records) and `app.cistern.lexicon.item` (encrypted item records). Includes code generation from JSON schemas.
1616+1717+### `@cistern/shared`
1818+Common utilities and authentication logic. Handles DID resolution via Slingshot service and creates authenticated RPC clients using app passwords.
1919+2020+### `@cistern/producer`
2121+Creates and encrypts items for storage. Manages public key selection, encrypts plaintext content, and uploads encrypted items to the PDS as AT Protocol records.
2222+2323+### `@cistern/consumer`
2424+Retrieves, decrypts, and deletes items. Generates keypairs, manages private keys locally, retrieves items via polling or real-time streaming (Jetstream), and handles item deletion after consumption.
2525+2626+## Security Model
2727+2828+Private keys never leave the consumer device. Public keys are stored in the PDS as records, while private keys remain off-protocol. Only the holder of the matching private key can decrypt items encrypted with the corresponding public key.
2929+3030+## Testing
3131+3232+Run all unit tests:
3333+```bash
3434+deno test --allow-env
3535+```
73688-The intention is for Cistern to bridge the gap between where ideas are had and
99-where they can be stored long-term. For example, let's say you have an idea
1010-while at a restaurant. You create an item using your phone, and once you're back
1111-at your desk and you open Obsidian, that item is automatically pulled from your
1212-PDS, decrypted, and deleted from your PDS. If your notebook was open at the time
1313-you created your item, the Cistern Obsidian plugin would have been notified of
1414-the new item via the Jetstream, and so you would find your memo waiting for you
1515-once you got home.
3737+Run end-to-end tests (requires AT Protocol credentials):
3838+```bash
3939+CISTERN_HANDLE="your.bsky.social" \
4040+CISTERN_APP_PASSWORD="xxxx-xxxx-xxxx-xxxx" \
4141+deno test --allow-env --allow-net e2e.test.ts
4242+```