Build with Marmot

The Marmot Protocol combines Nostr, MLS, and Blossom for decentralized encrypted messaging. Use the MDK to build compatible clients without implementing the protocol from scratch.

Quick Start (Rust)

The MDK (Marmot Development Kit) is a modular Rust SDK. Requires Rust 1.90.0+ and SQLite.

git clone https://github.com/marmot-protocol/mdk.git
cd mdk
cargo build
cargo test --features mip04

MDK Crate Structure

CratePurpose
mdk-coreMain library: MLS implementation, Nostr integration, group management
mdk-storage-traitsStorage abstraction layer (implement for custom backends)
mdk-memory-storageIn-memory storage for development and testing
mdk-sqlite-storageSQLite-based persistent storage with encryption (production use)

Nostr Event Kinds

Marmot clients must subscribe to and publish these event kinds:

KindPurposeNotes
443KeyPackagePublic invitation card for async group joins. TLS-serialized, base64 encoded.
444WelcomeSent to new members when added to a group. Wrapped in NIP-59 gift wrap.
445Group EventChaCha20-Poly1305 encrypted group messages (proposals, commits, application messages) published with fresh ephemeral keypairs.
447Token RequestPush notification token exchange (MIP-05).
448Token List ResponsePush notification token list (MIP-05).
449Token RemovalRemove push notification token (MIP-05).
10050Relay ListUser's preferred relays for notifications.
10051KeyPackage Relay ListRelays where user publishes KeyPackages.

Default Ciphersuite

All Marmot clients must support this ciphersuite:

MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519

X25519 for key exchange, AES-128-GCM for encryption, SHA-256 for hashing, Ed25519 for signatures.

Identity Model

  • Nostr keypairs are used for identity (32-byte public key as BasicCredential)
  • MLS signing keys are separate from Nostr identity keys
  • Compromise of a Nostr identity does not give access to MLS group messages
  • Each device is a separate MLS leaf node (multi-device support)

Basic Client Flow

  1. Generate identity: Create or import a Nostr keypair
  2. Publish KeyPackage: Create an MLS KeyPackage and publish it as a kind:443 event to relays listed in the user's kind:10051 event
  3. Create a group: Initialize an MLS group with the Marmot Group Data Extension (0xF2EE), then invite members by consuming their KeyPackages
  4. Send Welcome: After committing an Add proposal, send a Welcome message (kind:444) wrapped in NIP-59 gift wrap
  5. Send messages: Derive the 32-byte group event key from exporter_secret, encrypt the serialized MLS message with ChaCha20-Poly1305 using a random nonce, then publish base64(nonce || ciphertext) as kind:445 with a fresh ephemeral keypair
  6. Receive messages: Subscribe to kind:445 events filtered by the group's h tag, decode base64(nonce || ciphertext), decrypt with ChaCha20-Poly1305, and process the MLS message

MIP Status

The Marmot Protocol is specified through MIPs (Marmot Improvement Proposals):

MIPTitleStatusRequired
MIP-00Credentials and KeyPackagesReviewYes
MIP-01Group Construction and Marmot Group Data ExtensionReviewYes
MIP-02Welcome EventsReviewYes
MIP-03Group MessagesReviewYes
MIP-04Encrypted Media (Blossom + ChaCha20-Poly1305)ReviewNo
MIP-05Push NotificationsDraftNo

Full specifications: github.com/marmot-protocol/marmot

Known Limitations

  • Welcome messages currently exceed relay size limits above approximately 150 group members. Work is underway on "light" Welcome support for larger groups.
  • The project is in beta. Protocol specifications are in review status.

TypeScript (marmot-ts)

For web or Node.js applications, marmot-ts is an early-stage TypeScript implementation:

git clone https://github.com/marmot-protocol/marmot-ts.git

marmot-ts is under active development and not yet feature-complete.

Key Dependencies

LibraryPurposeRepository
OpenMLSRust MLS implementationgithub.com/openmls/openmls
rust-nostrNostr protocol supportgithub.com/rust-nostr/nostr
BlossomContent-addressed media storagegithub.com/hzrd149/blossom

Repositories

RepositoryPurposeLanguageLicense
whitenoiseFlutter mobile clientDartAGPL-3.0
whitenoise-rsRust backend library with OpenMLSRustAGPL-3.0
marmotProtocol specification (MIPs)N/AMIT
mdkMarmot Development Kit (modular Rust SDK)RustMIT
marmot-tsTypeScript implementation (early stage)TypeScriptMIT

All repositories: github.com/marmot-protocol