Skip to main content

Module inbox_id

Module inbox_id 

Source
Expand description

A versioned, type-safe wrapper around a raw XMTP inbox id.

§Why a newtype instead of [u8; 32]?

Plenty of 32-byte values fly around the codebase — installation ids, commit hashes, TLS key hashes. Using [u8; 32] for inbox ids loses the compiler’s ability to catch accidental mixing, and forces every site that serializes an inbox id to re-derive the wire format from first principles.

InboxId replaces the raw array everywhere an inbox id flows through the AppData-dictionary wire format.

§Wire format

varint(version) || version_specific_payload

The version uses the QUIC variable-length integer encoding from RFC 9000 §16 — the same scheme TLS-codec uses for collection length prefixes. Version 0 fits in a single byte (0x00), so v0 InboxId values are 33 bytes on the wire (1 varint + 32 raw bytes).

  • Version 0: 32 raw bytes — the SHA-256 hash backing the hex-encoded string form (see xmtp_id::associations::member::inbox_id).

Future versions can encode completely different payload shapes (longer ids, different cryptographic schemes, …) without disturbing on-the-wire compatibility of existing values.

Structs§

InboxId
A type-safe XMTP inbox id.

Enums§

InboxIdError
Errors surfaced by InboxId construction from hex strings or Vec<u8>.

Constants§

INBOX_ID_BYTE_LEN
Length in raw bytes of a v0 XMTP inbox id (the SHA-256 hash that backs the hex-encoded string form).
INBOX_ID_VERSION
Current wire-format version written by InboxId::tls_serialize.