Status: authoritative. Supersedes the Swift-first framing of the original §40 assignment. Owner: Don Elton. Written from his spec of 2026-09-01 plus his same-day revision.
---
A privacy-preserving opportunistic MANET (mobile ad hoc network) with delay-tolerant fallback — not a chat app that happens to work offline.
Secure text messaging with no Internet, no cellular, no infrastructure Wi-Fi, and no central server. A message may travel A→B, or A→relay→relay→B. Relays learn essentially nothing.
Don's framing, verbatim and load-bearing:
> "The next thing I would design before Claude writes production radio code is the exact wire protocol > and route-discovery state machine, down to each packet type and field. That will prevent iOS, Android, > macOS, and Windows implementations from gradually becoming incompatible."
So the first deliverable is a wire protocol document, not code.
---
Don revised the architecture after the original spec was written. Where they conflict, this section wins.
### 1.1 Platform-neutral from day one Android and possibly Windows are targets. The mesh protocol must be platform-neutral immediately. Apple Wi-Fi Aware, Android Wi-Fi Aware / Wi-Fi Direct, BLE, Windows Wi-Fi Direct, LAN and Internet all become interchangeable transport adapters.
### 1.2 Shared core in Rust — NOT parallel Swift and Kotlin implementations > "I would not have Claude Code independently implement the cryptographic protocol and routing algorithm > once in Swift and once in Kotlin. That invites subtle protocol divergence."
mesh-core-rs owns: crypto, envelopes, identities, route discovery, routing, duplicate suppression, serialization, receipts, protocol state machine.
Compiled for iOS, macOS, Android, Windows. Bindings via UniFFI for Swift/Kotlin; C ABI or generated bindings for Windows.
Platform apps own only: radio APIs, UI, lifecycle, notifications, permissions, secure key storage.
### 1.3 Wire format: canonical CBOR, not Swift Codable Explicitly defined canonical serialization. Deterministic encoding rules must be written down, because two implementations that disagree on map key ordering will silently fail authentication.
### 1.4 Routing: bounded route discovery FIRST, flooding only as fallback Supersedes "controlled epidemic routing" in the original §16.
Two distinct behaviours: Live mesh (Carol reachable now, message traverses immediately) and Courier mode (Bob stores the packet, walks near Carol twenty minutes later, delivers).
### 1.5 Route discovery must not leak topology Relays keep short-lived opaque reverse-path state only:
`` query AB12 · receivedFrom = PeerBob · hop = 2 · expires = now + 10s token 7C91 reachable through peer E32F · cost 137 · expires 15s ``
They must NOT maintain global tables of the form "I can reach Alice / Bob / Carol". That leaks topology.
### 1.6 Presence beacons build a privacy-preserving routing table Carol periodically emits PresenceToken = HMAC(contactSecret, currentEpoch). Alice knows Carol's expected token. Bob does not. But Bob can cache opaque-token-7C91 heard from radio-peer-X, 3s ago, quality 213 and answer or forward Alice's query fast.
### 1.7 Token rotation is mandatory Otherwise an observer in an airport follows one unknown person across locations. token = HMAC(pairwiseRoutingSecret, floor(unixTime / 600)) — 10 minute epochs. Receiver accepts previous, current and next epoch to tolerate clock skew. Consecutive tokens must have no observable cryptographic relationship.
### 1.8 Link quality is an abstraction, and the cost is the WEAKEST link Do not pick the strongest first hop. Don's example:
`` Route A: Alice →(-42) Bob →(-88) Carol Route B: Alice →(-61) Dave →(-59) Carol ← Route B should win ``
Define a generic LinkQuality 0–255. Each transport maps its own metric into it: BLE from RSSI, Wi-Fi Aware from link metrics, LAN from latency/loss, Internet from latency/reachability.
`` RouteCost = hopPenalty + weakLinkPenalty + transportPenalty + congestionPenalty + batteryPenalty ``
### 1.9 Wi-Fi Aware is the preferred interoperable transport It is a Wi-Fi Alliance standard, not an Apple-only mechanism — Android supports it natively on capable devices. BLE is the universal denominator. Windows Wi-Fi Direct is a platform-specific adapter, and Microsoft's older Wi-Fi Direct Services API is deprecated — do not depend on that service layer.
### 1.10 Layer diagram (Don's) `` Messaging UI → Conversation Layer → Crypto Layer → Mesh Protocol → Routing Engine → Transport Manager ├── BLE ├── Wi-Fi Aware ├── Wi-Fi Direct ├── LAN └── Internet ``
---
routingSecret = HKDF(sharedSecret, "routing-v1"), rotating destination tokens.supportsTransportClass3), never deviceType = iPhone17.742 983 125) both sides compare. NFC is an identity/pairing mechanism only — never a messaging transport (Core NFC is for tags). AirDrop and cloud accounts are NOT trust mechanisms.try! network/crypto input.Claim: the protocol discloses no device model, OS, telephone number, account identifier, or permanent device identifier.
Do NOT claim: complete metadata anonymity, or that an observer cannot tell a transmitter is an iPhone. Radio fingerprinting and Apple's underlying P2P protocol behaviour may reveal platform information. This is application-layer minimisation.
Protect against: relays reading or modifying messages, observers reading plaintext, replay, forgery, server compromise, server operators reading contents, permanent identifiers in discovery, stolen database files revealing keys, duplicate packet injection.
Do NOT yet claim protection against: a compromised destination device, malware in decrypted memory, global radio traffic analysis, OS compromise, physical extraction from an unlocked device, or perfect sender/recipient anonymity against a global observer.
`` iPhone A Android B iPhone C Android D A↔B B↔C C↔D A cannot reach C or D. B cannot reach D. ``
No Internet or cellular at any point.
SPEC-ORIGINAL §10 says the QR payload holds "key agreement public information" and a "pairing nonce"; DECISIONS.md E3 says the invite blob "carries public keys and a nonce". PROTOCOL.md §6.5 (Handshake v1, written 2 September 2026) requires each side's X25519 key and nonce half to be fresh per pairing attempt, which a value printed into a QR or left in a mailbox cannot be. What shipped — PairingCode on both platforms — carries the identity key alone, which is consistent with §6.5. DECISIONS.md outranks PROTOCOL.md, so E3's wording needs either an amendment or a note saying its "public keys" meant identity keys only. Nothing is broken today; this is a documentation conflict that will mislead the next reader of E3.This spec cites platform capabilities (Apple Wi-Fi Aware on iPhone 12+, Android Wi-Fi Aware and Wi-Fi Direct, deprecated Windows Wi-Fi Direct Services). Don researched these. The implementing agent must verify current API surface against live Apple/Android/Microsoft documentation before writing radio code — do not treat any API detail in this document, or any model's training knowledge, as current.
English is the reference text; any translation is a convenience. Help is stored on this phone and never contacts anyone.