Skip to main content
Inboxes are the core identity primitive in XMTP. Each inbox has a unique identifier and can be associated with multiple wallets and device installations.

InboxId and InstallationId

InboxId

The InboxId is a unique identifier for an inbox, generated from a wallet address and nonce:
Generation:
See member.rs:168-176 for the implementation.

InstallationId

An InstallationId represents a specific device or application installation:
Installation IDs are Ed25519 public keys that sign messages on behalf of the inbox.

InboxOwner Trait

The InboxOwner trait defines how wallets interact with the identity system:
See lib.rs:90-123 for the trait definition and implementations.

Implementation Example

The InboxOwner trait is automatically implemented for references:

Identity Structure

The Identity struct represents a user’s complete identity within the XMTP network:
See identity.rs:294-301 for the struct definition.

Key Methods

Creating an Identity

Identities are created through the IdentityStrategy system:

For New Inboxes

For Existing Inboxes

If a wallet is already associated with an inbox:
See identity.rs:358-441 for the creation flow.

With Legacy Key (V2 Migration)

Legacy keys can only be used once during inbox creation with nonce 0.

Installation Management

Querying Installations

Adding an Installation

See builder.rs:83-99 for the add_association method.

Revoking Installations

See identity_updates.rs:125-140 for the revoke helper.

Key Package Management

Key packages are cryptographic bundles that allow others to add the identity to groups:

Generating Key Packages

Rotating Key Packages

Key packages should be rotated periodically:
Key packages are automatically rotated based on KEY_PACKAGE_ROTATION_INTERVAL_NS. See identity.rs:640-675 for rotation implementation.

Registration Flow

Registering an identity involves:
  1. Creating or loading the identity
  2. Generating and uploading key packages
  3. Storing the identity locally
See identity.rs:609-628 for the registration method.

Identity Errors

Common errors when working with identities:
See identity.rs:188-272 for all error types.

Best Practices

  1. Cache identities - Use IdentityStrategy::CachedOnly when possible to avoid network calls
  2. Rotate key packages - Implement periodic rotation for forward secrecy
  3. Limit installations - Be aware of MAX_INSTALLATIONS_PER_INBOX (typically 100)
  4. Handle legacy migration - Legacy keys can only be used once with nonce 0
  5. Verify inbox associations - Always load and verify identity updates from the network

References

  • Source: crates/xmtp_id/src/lib.rs
  • Source: crates/xmtp_mls/src/identity.rs
  • Source: crates/xmtp_id/src/associations/member.rs