Skip to main content

Module protocol

Module protocol 

Source
Expand description

Wire protocol for room discovery and message broadcast.

Two gossipsub topics:

  • ROOMS_TOPIC — global, every node subscribes. Used for room advertisements (so all peers see “rooms in this network”).
  • format!("{ROOM_TOPIC_PREFIX}{room_id}") — per-room. Only members of a room subscribe. All room messages flow here.

Structs§

RoomAnnouncement
Broadcast on the global ROOMS_TOPIC. Each peer republishes the rooms they’re currently in, periodically. Listeners maintain a cache with TTL.
SignedRoomMessage
Application-level signed envelope around a RoomMessage. Used for any message whose authenticity matters beyond gossipsub’s transport- level signing.

Enums§

RoomMessage
All messages on a room’s per-room topic.
WireMessage
What actually gets serialized onto a per-room gossipsub topic. New in v0.3.0 — previously, the raw RoomMessage JSON went on the wire. All outgoing messages now flow through this envelope so the receiver can tell signed from unsigned at the outer layer without trial- parsing. Tagged so future variants don’t silently misparse.

Constants§

ROOMS_TOPIC
ROOM_TOPIC_PREFIX

Functions§

encode_wire
Serialize an unsigned RoomMessage to its on-wire bytes inside the new WireMessage::Plain envelope. The single helper keeps every send site in app/mod.rs from open-coding the wrap.
encode_wire_signed
Serialize a SignedRoomMessage envelope to its on-wire bytes.
inbox_room_id
huddle 1.0: a stable, per-identity “inbox” room id for relay-routed contact requests — inbox:<hex(sha256("huddle-inbox-v1" || fingerprint))>. Lets “add by HD-ID” work over the internet (not just the LAN mesh): the requester publishes a signed ContactRequest here and the owner, who auto-subscribes to their own inbox, picks it up (live or from the relay mailbox). The relay only ever sees this hash, never the raw fingerprint (preimage resistance), so it can’t reconstruct a contact graph; the inbox: prefix + distinct salt keep it from colliding with DM / group room ids. Both sides derive the same id from the target fingerprint.
room_topic