HushNet Backend is a secure backend server for an end-to-end encrypted (E2EE) instant messaging application, built with Rust and Axum. It implements the Signal Protocol (X3DH + Double Ratchet) to provide cryptographically secure communication between users and devices.
- π HushNet Backend
- π End-to-End Encryption (E2EE): Signal Protocol implementation (X3DH + Double Ratchet)
- π Ed25519 Authentication: Cryptographic signature-based authentication (no JWT)
- π₯ Multi-Device Support: Full support for multiple devices per user
- π¬ Instant Messaging: Direct messages and group chats
- π Cryptographic Key Management: Identity keys, prekeys, signed prekeys, one-time prekeys
- β‘ Real-time Communication: WebSockets for instant notifications
- π‘ PostgreSQL LISTEN/NOTIFY: Real-time event notifications
- π High Performance: Asynchronous backend powered by Tokio
- π³ Docker Ready: Docker configuration for PostgreSQL
- π‘οΈ Anti-Replay Protection: Timestamp-based request validation
# Clone the repository
git clone https://github.com/HushNet/HushNet-Backend.git
cd HushNet-Backend
# Start PostgreSQL with Docker
docker build -t hushnet-postgres .
docker run -d -p 5432:5432 --name hushnet-db hushnet-postgres
# Configure environment
echo "DATABASE_URL=postgres://postgres:dev@localhost:5432/e2ee" > .env
# Build and run
cargo build --release
cargo runServer will start at http://127.0.0.1:8080 π
Comprehensive documentation is organized into the following sections:
- API Reference - Complete API endpoint documentation
- Database Schema - Database structure and relationships
- Security & Cryptography - Encryption protocols and authentication
- WebSocket & Real-time - WebSocket implementation and events
- Project Structure - Code organization and architecture
- Installation Guide - Detailed setup instructions
- Configuration Guide - Environment variables and settings
- Docker Deployment - Docker and Docker Compose setup
- Development Guide - Development workflow and tools
- Contributing Guidelines - How to contribute to the project
- Changelog - Version history and updates
- Roadmap - Future features and improvements
HushNet Backend follows a clean, modular architecture:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Client Applications β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β HTTP/WebSocket
βββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββ
β Axum Web Framework β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Routes β β Middlewares β β Controllers β β
β ββββββββ¬βββββββ ββββββββ¬βββββββ ββββββββ¬βββββββ β
β β β β β
β ββββββββββ¬βββββββββ΄βββββββββ¬βββββββββ β
β β β β
β ββββββββββΌββββββββββ βββββΌββββββββββ β
β β Services β β Repositories β β
β ββββββββββββββββββββ βββββββββ¬βββββββ β
βββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββ
β
βββββββββββββββββββββΌβββββββββββββββββββ
β PostgreSQL Database β
β (LISTEN/NOTIFY for real-time) β
ββββββββββββββββββββββββββββββββββββββββ
- Authentication: Ed25519 signature verification on each request
- Key Exchange: X3DH handshake to establish secure sessions
- Messaging: Double Ratchet encryption for each message
- Real-time: PostgreSQL NOTIFY β WebSocket β Clients
- Rust (Edition 2021) - Programming language
- Axum 0.7 - Async web framework
- Tokio - Async runtime
- SQLx 0.8 - PostgreSQL async client
- ed25519-dalek 2.0 - Digital signatures
- base64 - Base64 encoding/decoding
- PostgreSQL 14+ - Relational database
- LISTEN/NOTIFY - Real-time notification mechanism
- Serde - JSON serialization/deserialization
- Tracing - Structured logging
- Dotenvy - Environment variable management
- Anyhow - Error handling
- UUID - Unique identifier generation
- Chrono - Date and time handling
- Rust 1.70+ (Install)
- PostgreSQL 14+ (Install)
- Docker (optional, for database)
- Cargo (included with Rust)
For detailed installation instructions, see the Installation Guide.
# 1. Clone repository
git clone https://github.com/HushNet/HushNet-Backend.git
cd HushNet-Backend
# 2. Install dependencies
cargo build
# 3. Setup database (with Docker)
docker build -t hushnet-postgres .
docker run -d -p 5432:5432 --name hushnet-db hushnet-postgres
# 4. Configure environment
cp .env.example .env
# Edit .env with your configuration
# 5. Run server
cargo runCreate a .env file in the project root:
# Database
DATABASE_URL=postgres://postgres:dev@localhost:5432/e2ee
# Logging
RUST_LOG=infoFor complete configuration options, see the Configuration Guide.
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
cargo test) - Format code (
cargo fmt) - Check lints (
cargo clippy) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License. See the LICENSE file for details.
- Signal Protocol for cryptographic inspiration
- Axum for the excellent web framework
- The Rust community π¦
- GitHub Issues: Open an issue
- GitHub Discussions: Join the discussion
Built with β€οΈ and π¦ Rust
β If you like this project, please give it a star!
Documentation β’ API Reference β’ Contributing