A guide for AI coding agents working on the Marmot Protocol specification. This will work for most major AI harnesses. The CLAUDE.md file in this repo is a symlink to this doc.
Marmot is a secure, decentralized group messaging protocol that combines the MLS Protocol with Nostr's decentralized network. The protocol enables end-to-end encrypted group messaging without relying on centralized servers.
Key Characteristics:
- Protocol specification repository (not an implementation)
- Markdown-based documentation (MIPs - Marmot Implementation Proposals)
- References MLS RFCs and Nostr NIPs
- Focus on security, interoperability, and clarity
marmot/
├── README.md # Main project overview
├── AGENTS.md # This file
├── 00.md - 04.md # Marmot Implementation Proposals (MIPs)
├── threat_model.md # Security threat analysis
├── data_flows.md # Protocol flow diagrams
├── dependency_reqs.md # Implementation dependencies
├── docs/mls/ # Local copies of MLS RFCs
│ ├── rfc9420.txt # MLS Protocol spec
│ ├── rfc9750.txt # MLS Architecture
│ └── draft-ietf-mls-extensions-08.txt
└── assets/ # Images and diagrams
- MIP-00: Credentials & Key Packages (REQUIRED)
- MIP-01: Group Construction & Marmot Group Data Extension (REQUIRED)
- MIP-02: Welcome Events (REQUIRED)
- MIP-03: Group Messages (REQUIRED)
- MIP-04: Encrypted Media (OPTIONAL)
- threat_model.md: Comprehensive security analysis
- data_flows.md: Protocol flow diagrams and architecture
- dependency_reqs.md: Implementation dependencies
- MLS (Messaging Layer Security): Provides group encryption, forward secrecy, and post-compromise security
- Nostr: Provides decentralized relay network and identity system
- Marmot Group Data Extension: Custom MLS extension containing group metadata
- KeyPackages: Public invitation cards for asynchronous group joins
- Double Encryption: MLS symmetric encryption + NIP-44 encryption for application messages
kind: 443: KeyPackage events (public invitations)kind: 444: Welcome events (gift-wrapped via NIP-59)kind: 445: Group events (messages, proposals, commits)kind: 10051: KeyPackage relay list events
When working on protocol specifications, ensure these are always addressed:
- Credential Validation: MLS credential identity MUST match Nostr pubkey in KeyPackage events
- Commit/Welcome Ordering: Commits MUST be confirmed before sending Welcome events
- Ephemeral Keypair Uniqueness: Fresh keypair for EVERY kind: 445 event
- Unsigned Inner Events: Inner events MUST NOT be signed (prevents leak publication)
- Admin Authorization: Non-self-update Commits MUST verify sender is in admin_pubkeys array (self-update Commits are allowed from any member)
- TLS Serialization: Exact TLS presentation language format required
- Use clear headings with descriptive names
- Include code examples in JSON format for Nostr events
- Reference other MIPs using
[MIP-XX](XX.md)format - Use tables for structured data (event fields, security properties, etc.)
- Include security notes with ✅ (protections) and
⚠️ (limitations)
- MUST/SHOULD/MAY: Use RFC 2119 terminology for requirements
- CRITICAL: Mark security-critical requirements explicitly
- Examples: Include complete, valid examples
- Edge Cases: Document race conditions, error handling, and failure modes
- Interoperability: Consider cross-implementation compatibility
- Always reference threat_model.md for security context
- Document observable metadata and privacy limitations
- Include countermeasures for identified threats
- Mark security-critical sections with CRITICAL labels
- Create
XX.mdfile (next sequential number) - Follow structure of existing MIPs:
- Title and status (review/draft)
- Required/optional flag
- Overview and motivation
- Detailed specification
- Examples
- Security considerations
- References to other MIPs
- Update README.md MIP table
- Update threat_model.md if security implications exist
- Read relevant MIPs and MLS RFCs
- Check threat_model.md for security implications
- Update data_flows.md if protocol flows change
- Ensure examples remain valid
- Update cross-references between MIPs
- Review threat_model.md for relevant threats
- Consider new attack vectors
- Document countermeasures
- Update security requirements section
- Reference specific threat IDs (e.g., T.1.2)
- RFC 9420: docs/mls/rfc9420.txt - MLS Protocol specification
- RFC 9750: docs/mls/rfc9750.txt - MLS Architecture overview
- MLS Extensions: docs/mls/draft-ietf-mls-extensions-08.txt
- Use Nostrbook MCP server to query NIPs (if available)
- Key NIPs referenced:
- NIP-01: Basic protocol flow
- NIP-44: Encrypted Direct Message (key derivation)
- NIP-59: Gift Wrap (Welcome event encryption)
- NIP-70: Replaceable Events (KeyPackage deletion)
- Verify all JSON examples are valid
- Check that event kinds match Nostr standards
- Ensure TLS serialization examples are correct
- Validate cross-references between documents
- Consider how different implementations might interpret specs
- Document ambiguous areas clearly
- Provide test vectors where helpful
- Reference implementation behavior when relevant
- This is a specification repo: Focus on protocol design, not implementation code
- Security-first: Always consider security implications of changes
- Backward compatibility: Changes should maintain interoperability
- Cross-references: Update related documents when making changes
- Examples: Keep examples complete and valid
- Terminology: Use precise MLS and Nostr terminology
- Status tracking: Update MIP status (draft → review → stable)
- Missing security considerations: Always document security implications
- Incomplete examples: JSON examples must be complete and valid
- Broken references: Check that all
[MIP-XX](XX.md)links work - Ambiguous requirements: Use MUST/SHOULD/MAY consistently
- Ignoring edge cases: Document race conditions and error handling
- TLS serialization errors: Verify exact byte-level format matches spec
When making changes, ask:
- Does this maintain backward compatibility?
- What are the security implications?
- Are there race conditions or edge cases?
- Do examples need updating?
- Should threat_model.md be updated?
- Are cross-references still valid?
- Does this affect interoperability?
- Review existing MIPs for patterns and style
- Check threat_model.md for security context
- Reference MLS RFCs for cryptographic details
- Consult Nostr NIPs for event format requirements
- Look at implementation repos for clarification
Remember: This is a protocol specification. Clarity, precision, and security are paramount. When in doubt, err on the side of explicitness and security.