Overview
Thexmtp_id crate implements XMTP’s identity system as specified in XIP-46. It provides identity management, wallet associations, signature verification, and smart contract wallet support for the XMTP protocol.
Installation
Key Exports
String
Global InboxID owned type. Represents a unique identifier for a user’s inbox.
&str
Reference type for InboxID. Used for passing inbox IDs without ownership transfer.
String
String type representing a blockchain wallet address.
struct
Represents an update to an inbox’s identity state.Fields:
sequence_id: u64- Sequential identifier for ordering updatesserver_timestamp_ns: u64- Server timestamp in nanosecondsupdate: UnverifiedIdentityUpdate- The identity update payload
Core Modules
associations
Manages identity associations between wallets and installations:- Creating inbox associations
- Adding new wallet associations
- Revoking associations
- Verifying association states
scw_verifier
Smart Contract Wallet (SCW) signature verification:- ERC-1271 signature validation
- Chain-specific verification
- Contract interaction for signature checks
constants
Protocol constants and configuration values.utils
Utility functions for identity operations.Main Types and Traits
trait
Trait for types that can own an inbox and sign messages.Methods:
get_identifier() -> Result<Identifier>- Get the wallet/account identifiersign(text: &str) -> Result<UnverifiedSignature>- Sign a text message
trait
Trait for types that can be referenced as an InboxId.Method:
as_ref() -> InboxIdRef- Get a reference to the inbox ID
enum
Represents different types of identifiers in the system:
- Ethereum addresses
- Installation keys
- Other blockchain addresses
struct
Identifies a member in an association state (wallet or installation).
struct
Represents the current state of an inbox’s associations.Key Fields:
- List of associated wallet addresses
- List of associated installations
- Recovery addresses
- Association history
enum
A signature that has not yet been verified.Variants:
RecoverableEcdsa- ECDSA signature with recovery IDInstallationKey- EdDSA signature from installation keyLegacyDelegated- Legacy delegated signature format
struct
A signature that has been cryptographically verified.Key Methods:
verify()- Verify the signaturesigner()- Get the signer identifier
Usage Examples
Implementing InboxOwner for a Wallet
Working with Inbox IDs
Managing Associations
Verifying Identity Updates
Smart Contract Wallet Verification
Association Types
struct
Action to create a new inbox with initial wallet association.Fields:
nonce: u64- Unique nonce for inbox creationaccount_identifier: Identifier- Initial wallet/accountinitial_identifier_signature: VerifiedSignature- Signature proof
struct
Action to add a new member to an inbox.Fields:
existing_member_signature: VerifiedSignature- Signature from existing membernew_member_signature: VerifiedSignature- Signature from new membernew_member_identifier: MemberIdentifier- New member to add
struct
Action to revoke an existing association.Fields:
recovery_address_signature: VerifiedSignature- Signature from recovery addressrevoked_member: MemberIdentifier- Member to revoke
struct
Action to change the recovery address.Fields:
existing_recovery_address_signature: VerifiedSignaturenew_recovery_address: String
Error Types
Features
feature
Testing utilities including mock implementations and test helpers.
Platform Support
- Native (all platforms)
- WebAssembly (with getrandom wasm_js feature)
Dependencies
Key dependencies:alloy- Ethereum wallet and signinged25519-dalek- EdDSA signaturesxmtp_cryptography- Cryptographic primitivesxmtp_proto- Protocol buffer definitions
