bitchat-qudag

Crates.iobitchat-qudag
lib.rsbitchat-qudag
version0.1.0
created_at2025-07-16 00:54:19.291875+00
updated_at2025-07-16 00:54:19.291875+00
descriptionBitChat messaging integration for QuDAG with WASM support
homepagehttps://github.com/ruvnet/QuDAG/tree/main/bitchat-qudag-crate
repositoryhttps://github.com/ruvnet/QuDAG
max_upload_size
id1754497
size734,697
rUv (ruvnet)

documentation

https://docs.rs/bitchat-qudag

README

BitChat-QuDAG Integration

A quantum-resistant, privacy-focused messaging layer for QuDAG that implements and extends the BitChat protocol with advanced cryptographic features and multi-transport capabilities.

๐Ÿš€ Overview

BitChat-QuDAG bridges decentralized P2P messaging with quantum-resistant security, providing a future-proof communication layer that works across multiple transport protocols including Bluetooth mesh, Internet P2P, WebSocket, and local networks. This implementation not only fulfills the BitChat whitepaper specifications but extends them with quantum-resistant cryptography and WebAssembly support.

โœจ Key Features

Core BitChat Protocol Compliance

  • Bluetooth Mesh Networking: Full support for BLE mesh with automatic message hopping
  • Store & Forward: 12-hour message cache with configurable retention
  • Privacy by Design: No phone numbers, emails, or account registration required
  • Ephemeral Messages: Self-destructing messages with configurable TTL
  • Cover Traffic: Adaptive dummy message generation to prevent traffic analysis

Enhanced Security Features

  • Quantum-Resistant Cryptography:
    • ML-KEM-768 for key exchange (NIST-approved)
    • ML-DSA-65 for digital signatures
    • Hybrid mode combining quantum-resistant and traditional crypto
  • Forward Secrecy: Automatic key rotation and ephemeral key exchanges
  • Multi-Layer Encryption: Support for both traditional (AES-256-GCM) and quantum-resistant algorithms

Advanced Capabilities

  • Multi-Transport Architecture:
    • Internet P2P (via libp2p integration)
    • Bluetooth Low Energy mesh
    • WebSocket (for WASM environments)
    • Local network discovery
    • Relay/bridge support
  • WASM Support: Full browser compatibility with TypeScript bindings
  • Compression: Automatic message compression with LZ4/Zstd
  • Adaptive Routing: Intelligent path selection across transports

๐Ÿ“ฆ Installation

Rust (Native)

[dependencies]
bitchat-qudag = "0.1.0"

JavaScript/TypeScript (WASM)

npm install bitchat-qudag
# or
yarn add bitchat-qudag

๐Ÿ”ง Usage

Basic Messaging (Rust)

use bitchat_qudag::{BitChatMessaging, BitChatConfig, QuDAGMessaging};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create configuration
    let config = BitChatConfig::default();
    
    // Initialize messaging system
    let mut messaging = BitChatMessaging::new(config).await?;
    messaging.start().await?;
    
    // Send a message
    messaging.send_message("peer-id-123", b"Hello, BitChat!").await?;
    
    // Receive messages
    while let Some(message) = messaging.receive_message().await? {
        println!("Received: {} bytes from {}", 
            message.data.len(), 
            message.sender
        );
    }
    
    Ok(())
}

Bluetooth Mesh Setup

use bitchat_qudag::{BitChatConfig, TransportType, CryptoMode};

let config = BitChatConfig {
    enabled: true,
    transports: vec![TransportType::BluetoothMesh],
    crypto_mode: CryptoMode::Hybrid, // Quantum-resistant + traditional
    ephemeral_messages: true,
    store_forward: true,
    cover_traffic: true,
    ..Default::default()
};

WASM Usage (JavaScript/TypeScript)

import { BitChatWasm } from 'bitchat-qudag';

async function initializeMessaging() {
    const config = {
        enabled: true,
        crypto_mode: "Hybrid",
        ephemeral_messages: true,
        compression: true
    };
    
    const bitchat = new BitChatWasm(JSON.stringify(config));
    await bitchat.init();
    
    // Set message handler
    bitchat.set_message_handler((message) => {
        console.log('Received:', message);
    });
    
    // Send a message
    const message = new TextEncoder().encode('Hello from WASM!');
    await bitchat.send_message('peer-id', message);
}

Privacy Features

// Enable all privacy features
let config = BitChatConfig {
    ephemeral_messages: true,           // Self-destructing messages
    cover_traffic: true,                // Generate dummy traffic
    cover_traffic_interval: Duration::from_secs(30),
    rotating_peer_ids: true,            // Change IDs every 5-15 minutes
    ..BitChatConfig::high_privacy()    // Pre-configured privacy profile
};

// Send ephemeral message
messaging.send_ephemeral("peer-id", b"This will self-destruct", 
    Duration::from_mins(5)).await?;

๐Ÿ›ก๏ธ Security Comparison

Feature BitChat Original BitChat-QuDAG
Encryption Noise Protocol (X25519) Hybrid: ML-KEM-768 + X25519
Digital Signatures Ed25519 ML-DSA-65 + Ed25519
Forward Secrecy โœ“ โœ“ Enhanced
Quantum Resistance Future Goal โœ“ Implemented
Multi-Transport Bluetooth Only BLE + Internet + WebSocket
WASM Support โœ— โœ“

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    BitChat-QuDAG API                        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                   Messaging Layer                           โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ Ephemeral   โ”‚  โ”‚ Store &      โ”‚  โ”‚ Cover Traffic   โ”‚  โ”‚
โ”‚  โ”‚ Messages    โ”‚  โ”‚ Forward      โ”‚  โ”‚ Generator       โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                  Crypto Layer (Hybrid)                      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ ML-KEM-768  โ”‚  โ”‚ ML-DSA-65    โ”‚  โ”‚ Traditional     โ”‚  โ”‚
โ”‚  โ”‚ (Quantum)   โ”‚  โ”‚ (Quantum)    โ”‚  โ”‚ (AES/X25519)    โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                 Multi-Transport Layer                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚ Bluetooth โ”‚ โ”‚ Internet   โ”‚ โ”‚WebSocket โ”‚ โ”‚  Local    โ”‚ โ”‚
โ”‚  โ”‚   Mesh    โ”‚ โ”‚    P2P     โ”‚ โ”‚  (WASM)  โ”‚ โ”‚ Network   โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ” Configuration Profiles

Development

let config = BitChatConfig::development();
// Optimized for testing with relaxed security

Production

let config = BitChatConfig::production();
// Balanced security and performance

High Privacy

let config = BitChatConfig::high_privacy();
// Maximum privacy: ephemeral messages, cover traffic, rotating IDs

WASM

let config = BitChatConfig::wasm();
// Browser-optimized with WebSocket transport

๐Ÿ“Š Performance

  • Message Latency: <50ms (local), <200ms (mesh hop)
  • Throughput: 10,000+ msg/sec (native), 5,000+ msg/sec (WASM)
  • Memory Usage: ~10MB base + 1KB per peer
  • Compression Ratio: 40-60% for text messages
  • Crypto Overhead: ~5% for hybrid mode

๐Ÿงช Testing

# Run all tests
cargo test

# Run with all features
cargo test --all-features

# Run WASM tests
wasm-pack test --headless --chrome

๐Ÿค Contributing

Contributions are welcome! Please read our Contributing Guidelines before submitting PRs.

๐Ÿ“„ License

This project is dual-licensed under:

  • MIT License
  • Apache License 2.0

You may choose either license for your use.

๐Ÿ”— Links

๐Ÿ™ Acknowledgments

  • BitChat team for the original protocol design
  • QuDAG community for quantum-resistant implementations
  • NIST for ML-KEM and ML-DSA standardization
Commit count: 0

cargo fmt