fhexmpp on the Fog — XMPP-shaped FHE maildrop
Not logged in

Model: which half of XMPP runs where

This example rebases the fhe-messenger triage circuit on the XMPP data model (RFC 6120 message stanzas, RFC 6122 bare JIDs):

Privacy model and protocol decomposition

What this example does / does NOT do

"Adapt XMPP/DeltaChat?" — this example demonstrates what "based on XMPP" can mean on today's Fog: the data model + sender/recipient key discipline transfers cleanly; adaptation of XMPP SERVER LOGIC (routing decisions, roster fan-out, archive) is a from-scratch FHE circuit, not a port, and per-message latency on this worker generation is tens of seconds, not milliseconds. DeltaChat (IMAP-based) inherits the same constraints plus its own gate.

Circuit: encrypted triage (this check-in)

Packing (one ciphertext, SIMD slots; live region = slots 0..R-1):

Hashing (client side, pure Rust, no FHE): lowercase ASCII token → FNV-1a 64-bit → low 48 bits → affinely into [-0.45, +0.45]. Stays strictly inside the [-1, 1] band of the soft-equality polynomial with margin.

Soft equality: d = msgrep - rule; sc = (1 - d²)^8, evaluated as repeated squaring: d2 = d·d; u = one - d2; u2 = u·u; u4 = u2·u2; u8 = u4·u4. All four multiplies are ct×ct.

Depth audit (fresh ciphertexts, FLEXIBLEAUTO adjustment): d2 (1), u·u (2), u4 (3), u8 (4). Circuit depth 4 of MULT_DEPTH = 6 budget; SCALE 50, FIRST 60 (logQ = 60 + 6·50 = 360 bits; comfortable at N = 2^16, demo posture HEStd_NotSet like the golden and llm-fog examples).

Trace budget: 4 CTC mults + 2 subtractions, no rotations, no bootstrap. Measured 4,255 FHETCH instructions. At the measured Fog calibration (~2,700 instr/s worker wall, llm job 97a7f536) this is ~1.6 s of pure worker compute; the verified Fog round trip (job 0b2cdb44) ran 10 s worker wall for 138.5 MB upload and 4.2 MB encrypted match output — dominated by transport/upload, not compute.

Keygen cost: N = 2^16, depth 6 — a few seconds, a few hundred MB RAM per user on this box. Fine for demo scale (2-4 users).

Parameter selection (trailing)

What a real server-side FHE messenger would need from here

Ordered by distance:

  1. Fan-out routing on encrypted recipient ids — same soft-eq polynomial, roster hashed into a second ciphertext, one rotation to sweep; adds rk.bin to the worker upload (~linear in distinct rotation angles).
  2. Encrypted unread counts + PIR-style mailbox retrieval — rotations; still in worker-generation reach with small state.
  3. Stateful mailbox: persistent/resumable jobs + a named encrypted-handle store (Fog wishlist item — per-call uploads over ~100 MB are the viability cliff, so anything mailbox-shaped needs this first).
  4. Delivery receipts, presence, typing — event-loop semantics, out of scope for batch Fog today. 1-2 buildable on this worker generation; 3-4 gate on the Fog roadmap.

Threat model