# QF Private Rooms — Wallet-Authenticated Encrypted Treasury Communications

## Purpose

`/private-rooms/` adds a privacy-maximal communications primitive to the ultimate multisig treasury and voting dapp. It is designed for signer coordination, treasury-room presence, encrypted text/file exchange, voice/video review sessions, and evidence/transcript checkpointing without forcing Tezos DAL to behave like a live socket.

## Architecture boundary

| Layer | Correct role | Non-goal |
|---|---|---|
| Tezos wallet | Identity root, session proof, room authorization root | Direct chat/media encryption key |
| Device communication key | Local encryption/session key material | Persistent legal identity by itself |
| WebRTC | Live text, file-control, audio, video, screen-share transport | Durable public availability or audit anchoring |
| MLS / Double Ratchet | Group and 1:1 end-to-end encryption semantics | Tezos account management |
| WebSocket/WebTransport/libp2p/Waku | Signaling, fallback relay, store-forward metadata-minimized delivery | Custody authority |
| Tezos L1 contract | Allowlist, roles, revocation, receipts, treasury authority | Live media transport |
| DAL | Encrypted blob/checkpoint/evidence availability | Live chat, voice, or video streaming |

## New release files

| File | Purpose |
|---|---|
| `private-rooms/index.html` | Static operator workbench for private-room session and checkpoint artifacts |
| `src/core/private-rooms.mjs` | Deterministic session-binding, authorization, transport-plan, and DAL-checkpoint helpers |
| `js/private-rooms.js` | Browser controller for the workbench |
| `schemas/private-room-session.schema.json` | JSON schema for canonical private-room session bindings |
| `examples/private-room.session-binding.json` | Example wallet/device session input |
| `tests/private-rooms.test.mjs` | Offline deterministic tests |

## Session ceremony

1. Connect a Tezos wallet through Beacon or octez.connect.
2. Generate a local device communication keypair.
3. Create the canonical session statement with:
   - origin;
   - Tezos network and chain ID;
   - room ID and treasury ID;
   - wallet address;
   - device ID and device public key;
   - nonce;
   - issued-at and expiration timestamps;
   - requested scopes.
4. Ask the wallet to sign the statement.
5. Verify the wallet signature and address.
6. Check on-chain or signed allowlist membership and revocation status.
7. Use device/session keys for WebRTC/MLS encryption. Do **not** use the Tezos wallet key as the chat encryption key.

## Production wiring checklist

- Implement wallet signature verification for Beacon/octez.connect payloads.
- Read the private-room allowlist contract or signed room registry.
- Add device-key registration and revocation events.
- Add MLS state storage in encrypted IndexedDB.
- Add WebRTC signaling over WebSocket/WebTransport or a libp2p/Waku relay.
- Add TURN-over-TLS privacy mode for high-sensitivity calls.
- Add optional SFU mode with WebRTC Encoded Transform E2EE.
- Add attachment encryption using HPKE/XChaCha20-Poly1305 or equivalent reviewed primitives.
- Add DAL publisher/retriever only for ciphertext bundles, transcript checkpoints, and evidence commitments.
- Anchor checkpoint digests through Tezos receipts or governance/treasury evidence fields.

## Security notes

- A wallet address alone does not authenticate a user; a fresh wallet signature is required.
- Tezos addresses are public-key hashes; do not assume an address is an encryption-capable raw public key.
- DAL is public availability infrastructure. Never put plaintext or sensitive metadata on DAL.
- WebRTC ICE can reveal network metadata. Use TURN-over-TLS and candidate policy controls for strict privacy rooms.
- Persistent room memory must be opt-in, encrypted, exportable, and deletable.
- Live broadcast, treasury proposal submission, and transcript anchoring must remain explicit operator actions.


## v17 advanced Privacy Rooms layer

The v17 package adds the multisignature.io Privacy Rooms implementation as a deeper production primitive set alongside the deterministic v16 workbench:

- `rooms/index.html` — advanced browser lab for wallet/device binding and transport planning.
- `src/privacy/*` — SIWT-style device binding, WebCrypto envelope helpers, room policy evaluation, DAL checkpoint composition, and transport-choice utilities.
- `src/transport/*` — canonical transport envelopes, hash-linked routing, gateway adapters, and transport scoring.
- `contracts/privacy_room_registry.mligo` — on-chain room membership/device/revocation/checkpoint registry scaffold.
- `js/e2ee-frame-transform-worker.js` — WebRTC Encoded Transform worker hook for production E2EE upgrade work.

The security boundary remains unchanged: Tezos wallet signatures authenticate identity and authorization, while local device/session keys perform communications encryption. DAL is for encrypted availability checkpoints and evidence bundles, not live delivery.
