A minimal CLI-based messaging application built in Rust that demonstrates MLS (Messaging Layer Security) protocol concepts. This application showcases end-to-end encryption for group messaging with cryptographic agility and modular design through a mock implementation.
- End-to-End Encryption: All messages are encrypted using the MLS protocol
- Group Messaging: Create groups and add members with secure key distribution
- Cryptographic Agility: Modular crypto provider supporting various KEMs and encryption algorithms
- Persistent State: Application state is saved to disk for session persistence
- Simple CLI Interface: Easy-to-use command-line interface for messaging operations
- Two-User Demo: Supports Alice and Bob for demonstration purposes
- MLS Protocol Demonstration: Mock implementation showcasing MLS protocol concepts
- Cryptographic Simulation: Demonstrates key generation, distribution, and rotation
- Group Management: Handles group creation, member addition, and key distribution
- Message Encryption: Simulates message encryption using group secrets
- State Persistence: JSON-based storage for groups and messages
- Key Encapsulation Mechanisms (KEMs): Flexible KEM support through OpenMLS
- Authenticated Encryption: Messages are encrypted and authenticated
- Forward Secrecy: Keys are updated with each message to ensure forward secrecy
- Post-Compromise Security: Compromised keys can be rotated out of the group
- Rust 1.70+ (stable)
- Linux environment (tested on Ubuntu 22.04)
# Clone the repository
git clone https://github.com/yourusername/mls-chat.git
cd mls-chat
# Build the application
cargo build --release
# Run the application
cargo run --release-
Initialize Users
# Initialize Alice cargo run -- init alice # Initialize Bob cargo run -- init bob
-
Create a Group
# Alice creates a group cargo run -- create-group "MyGroup"
-
Add Members
# Alice adds Bob to the group cargo run -- add-member "MyGroup" bob
-
Send Messages
# Send a message to the group cargo run -- send "MyGroup" "Hello, this is an encrypted message!"
-
View Messages
# List all messages in the group cargo run -- list "MyGroup"
Initialize a new user identity (Alice or Bob).
Arguments:
user: User name (alice|bob)
Example:
cargo run -- init aliceCreate a new MLS group with the current user as the creator.
Arguments:
name: Group name
Example:
cargo run -- create-group "ProjectTeam"Add a member to an existing group.
Arguments:
group: Group namemember: Member to add (alice|bob)
Example:
cargo run -- add-member "ProjectTeam" bobSend an encrypted message to a group.
Arguments:
group: Group namemessage: Message content
Example:
cargo run -- send "ProjectTeam" "Meeting at 3 PM tomorrow"List all messages in a group.
Arguments:
group: Group name
Example:
cargo run -- list "ProjectTeam"Show detailed information about a group.
Arguments:
group: Group name
Example:
cargo run -- info "ProjectTeam"- End-to-End Encryption: Messages are encrypted on the sender's device and only decrypted on recipient devices
- Group Key Management: Automatic key distribution and rotation for group members
- Forward Secrecy: Compromise of current keys doesn't affect past messages
- Post-Compromise Security: Compromised devices can be removed and keys rotated
- Message Authentication: All messages are cryptographically authenticated
The application uses a modular crypto provider that supports:
- Multiple key encapsulation mechanisms
- Various encryption algorithms
- Flexible signature schemes
- Configurable ciphersuites
Application data is stored in the mls_chat_data/ directory:
app_state.json: Serialized application state including groups and messages- MLS group states are persisted for session continuity
mls-chat/
├── src/
│ └── main.rs # Main application code
├── Cargo.toml # Dependencies and build configuration
├── README.md # This file
└── .gitignore # Git ignore rules
- clap: Command-line argument parsing
- serde: Serialization for state persistence
- anyhow: Error handling
- colored: Terminal output formatting
- uuid: Unique identifier generation
- chrono: Timestamp handling
# Development build
cargo build
# Run with debug output
RUST_LOG=debug cargo run -- init alice
# Run tests
cargo testProblem: Trying to use commands without initializing a user first.
Solution: Initialize a user with cargo run -- init alice or cargo run -- init bob.
Problem: Trying to access a group that doesn't exist.
Solution: Create the group first with cargo run -- create-group "GroupName".
Problem: Trying to add a member who hasn't been initialized. Solution: Initialize all users before adding them to groups.
Problem: Compilation fails due to missing dependencies.
Solution: Ensure you have Rust 1.70+ installed and run cargo clean && cargo build.
Problem: Cannot create data directory or write files. Solution: Ensure write permissions in the current directory.
Enable debug logging to troubleshoot issues:
RUST_LOG=debug cargo run -- <command>If the application state becomes corrupted:
- Stop the application
- Backup the
mls_chat_data/directory - Delete
mls_chat_data/app_state.json - Restart the application and reinitialize users/groups
- Two Users Only: Currently supports only Alice and Bob for demonstration
- Local Storage: All data is stored locally (no network communication)
- No Message Decryption: Messages are encrypted but not decrypted in this demo
- Single Session: No support for multiple concurrent sessions
- Multi-User Support: Extend to support arbitrary user names
- Network Communication: Add client-server architecture
- Message Decryption: Implement full message decryption
- Concurrent Sessions: Support multiple active sessions
- Key Rotation: Implement automatic key rotation
- Member Removal: Add ability to remove group members
- Demo Purpose: This application is for educational and demonstration purposes
- Local Storage: Keys and messages are stored locally without additional encryption
- No Network Security: This demo doesn't include transport layer security
- Key Management: In production, implement proper key backup and recovery
- Regular Updates: Keep dependencies updated for security patches
- Secure Storage: In production, encrypt stored keys and messages
- Key Backup: Implement secure key backup mechanisms
- Audit Logging: Add comprehensive audit logging for security events
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenMLS - MLS protocol implementation
- Rust Crypto - Cryptographic primitives
- MLS Working Group - Protocol specification
For issues and questions:
- Check the troubleshooting section above
- Review the OpenMLS documentation
- Open an issue on GitHub
- Check the MLS protocol specification
Note: This is a demonstration application. For production use, implement additional security measures and follow MLS protocol best practices.