Skip to content

secure-chat: p2p E2E messaging over mailboxes and direct delivery (DIP-0018) - #167

Closed
ralyodio wants to merge 1 commit into
masterfrom
feat/secure-chat-messaging
Closed

ralyodio wants to merge 1 commit into
masterfrom
feat/secure-chat-messaging

Conversation

@ralyodio

@ralyodio ralyodio commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Turns c0mpute dm from a local keygen stub into working peer-to-peer, end-to-end encrypted one-to-one messaging. No coordinator is involved.

How it works

  • Addresses are public keys. An address is a hash of all four public keys (X25519, ML-KEM-768, Ed25519, ML-DSA-65). The fingerprint is its first 8 bytes. A lookup is checked against the address, so a node cannot substitute a different key.
  • Sealed outer layer. Mailboxes see a rotating recipient tag, the size, and the peer that handed the message over. They never see the sender, the recipient address, or the content.
  • Delivery order:
    1. If the recipient's home node is online, the message goes straight into that node's spool. The home node is announced by a signed HomeRecord that it gossips together with its dial addresses.
    2. Otherwise it is stored on the 3 mailbox nodes that rank highest for the tag (rendezvous hashing, so every node picks the same 3). They keep it for up to 30 days, within size, count and per-sender rate caps.
  • Pull and ack. The recipient polls its tags, opens and verifies each message, and acks it. The ack reveals a secret only the recipient could decrypt, and every copy is deleted.
  • Local state. Contacts, blocklist, inbox and replay guard are stored in chat-state.enc, encrypted with AES-256-GCM under a key derived from the chat seed.

Changes

  • c0mpute-secure-chat: new modules identity, sealed, mailbox, placement and state.
  • c0mpute-net: a new /c0mpute/rpc/1.0.0 request/response protocol for named services (RpcHandler, register_rpc, rpc, connected_peers). Bodies are capped at 1 MiB per request and 8 MiB per response.
  • c0mpute-core::dm: the network service, plus a new Role::Mailbox. The role is on by default, gateways serve it too, and the supervisor starts it.
  • CLI: c0mpute dm send|pull|inbox|lookup|contacts add/ls/rm|block|unblock. The old c0mpute chat <cmd> forms still work. C0MPUTE_DM_PASSWORD is read for scripts.
  • plugins/secure-chat/module.toml updated to match.

Tests

  • Unit tests: secure-chat (18), plus a two-node RPC round trip in c0mpute-net.
  • tests/dm_e2e.rs runs on loopback with 4 mailbox nodes. It covers:
    • offline store on exactly the 3 ranked nodes
    • pull, then ack deletes all 3 copies
    • a blocked sender's message is dropped and still deleted
    • a replayed message is rejected
    • lookup by fingerprint
    • direct delivery to the home node with no mailbox involved
  • cargo test --workspace --locked passes locally, except for one failure in hosting_market_e2e (Paid hosting marketplace: d1sks-picked preferred hosts, proof of storage, settlement (off by default) #163, just merged). That test does not touch this code. It saw 4 challenge receipts instead of 3 under full-workspace load, and passed 2 of 2 when run alone, so it looks timing-sensitive.

Not in this PR

Group chats, attachments, web/TUI surfaces, CoinPay DID binding, and Double Ratchet forward secrecy.

🤖 Generated with Claude Code

…ry (DIP-0018)

- c0mpute-secure-chat: addresses = hash of all four public keys, signed
  key/home records, sealed outer layer hiding sender and recipient,
  rotating recipient tags, replay guard, bounded mailbox store,
  rendezvous placement, and client state encrypted at rest.
- c0mpute-net: /c0mpute/rpc/1.0.0 named-service request/response
  (RpcHandler, register_rpc, rpc, connected_peers).
- c0mpute-core::dm: mailbox role (on by default, gateways too), gossip
  on c0mpute/dm/v1, direct delivery to a recipient's home node, store on
  3 rendezvous-ranked mailboxes otherwise, fetch/ack, key publish and
  lookup by fingerprint. New Role::Mailbox.
- c0mpute dm: send/pull/inbox/lookup/contacts/block/unblock wired to the
  network; old `c0mpute chat <cmd>` forms still work.
- tests: unit tests plus dm_e2e (4 mailboxes, offline store-and-forward,
  ack deletes every copy, blocklist, fingerprint lookup, direct delivery).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

ThreatCrush Security Scan

12 finding(s)

HIGH/CRITICAL: 1 | MEDIUM: 8 | LOW: 3

Severity Rule Location
HIGH js-ssrf-outbound-request apps/web/public/sw.js:24
MEDIUM js-unescaped-html-sink apps/web/src/app/blog/[slug]/page.tsx:53
MEDIUM js-unescaped-html-sink apps/web/src/app/layout.tsx:80
MEDIUM sh-remote-script-execution scripts/dev-setup.sh:25
MEDIUM sh-eval-expansion scripts/dev-setup.sh:35
MEDIUM sh-remote-script-execution scripts/install.sh:173
MEDIUM sh-remote-script-execution scripts/install.sh:198
MEDIUM sh-remote-script-execution scripts/install.sh:316
MEDIUM sh-remote-script-execution scripts/install.sh:354
LOW py-ssrf-outbound-request examples/business-strategist-agent/chat.py:37
LOW py-ssrf-outbound-request examples/business-strategist-agent/train.py:54
LOW secret-generic-credential node/crates/c0mpute-core/src/webhook.rs:1165

Snippets are redacted; ThreatCrush never prints matched credential material.

@ralyodio

ralyodio commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator Author

Shipped in #169 (v0.2.82) together with the hosting race fix.

@ralyodio ralyodio closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant