54c7eba8cb Improve code organization and documentation (#325)
* Add MARK headers to improve code organization in major files

* Reorganize peer management functions in BluetoothMeshService

- Removed duplicate getCurrentPeerID(for:) function
- Consolidated peer identity functions in Peer Identity Mapping section
- Moved getPeerFingerprint(), getFingerprint(for:), isPeerIDOurs() to proper location
- Moved getCurrentPeerIDForFingerprint() and getCurrentPeerIDs() from Message Sending section
- Moved notifyPeerIDChange() to Peer Management section

* Consolidate peer management functions in BluetoothMeshService

- Moved getCachedPublicKey() and getCachedSigningKey() from Identity Cache Methods to Peer Connection Management
- Moved getPeerNicknames() and getPeerRSSI() to Peer Connection Management section
- Moved getAllConnectedPeerIDs(), notifyPeerListUpdate(), and cleanupStalePeers() to Peer Connection Management
- Removed duplicate function declarations after consolidation
- Improved code organization by grouping all peer-related functions together

* Consolidate message handling functions in ChatViewModel

- Moved handleHandshakeRequest() from floating location to Message Reception section
- Moved trimMessagesIfNeeded() and trimPrivateChatMessagesIfNeeded() to Message Batching section
- Improved code organization by grouping related message handling functions together
- Removed unnecessary comments from trim functions

* Improve ContentView organization with better documentation

- Added descriptive comments for complex inline computations
- Documented message extraction logic for private vs public chats
- Documented peer data computation and sorting logic
- Improved code readability by explaining complex operations inline
- Note: Attempted to extract complex computations into helper functions, but SwiftUI scope limitations made inline documentation a better approach

---------

Co-authored-by: jack <jackjackbits@users.noreply.github.com>
2025-07-26 00:11:23 +02:00
2025-07-23 09:33:07 +02:00
2025-07-10 11:17:08 +10:00
2025-07-10 21:00:12 +05:30
2025-07-23 00:50:43 +02:00
2025-07-25 20:57:19 +02:00

bitchat

bitchat

A decentralized peer-to-peer messaging app that works over Bluetooth mesh networks. No internet required, no servers, no phone numbers. It's the side-groupchat.

bitchat.free

Warning

Private message and channel features have not received external security review and may contain vulnerabilities. Do not use for sensitive use cases, and do not rely on its security until it has been reviewed. Now uses the Noise Protocol for identity and encryption. Public local chat (the main feature) has no security concerns.

License

This project is released into the public domain. See the LICENSE file for details.

Features

  • Decentralized Mesh Network: Automatic peer discovery and multi-hop message relay over Bluetooth LE
  • Privacy First: No accounts, no phone numbers, no persistent identifiers
  • Cover Traffic: Timing obfuscation and dummy messages for enhanced privacy
  • Private Message End-to-End Encryption: Noise Protocol
  • Store & Forward: Messages cached for offline peers and delivered when they reconnect
  • IRC-Style Commands: Familiar /join, /msg, /who style interface
  • Universal App: Native support for iOS and macOS
  • Emergency Wipe: Triple-tap to instantly clear all data
  • Performance Optimizations: LZ4 message compression, adaptive battery modes, and optimized networking

Technical Architecture

Binary Protocol

bitchat uses an efficient binary protocol optimized for Bluetooth LE:

  • Compact packet format with 1-byte type field
  • TTL-based message routing (max 7 hops)
  • Automatic fragmentation for large messages
  • Message deduplication via unique IDs

Mesh Networking

  • Each device acts as both client and peripheral
  • Automatic peer discovery and connection management
  • Store-and-forward for offline message delivery
  • Adaptive duty cycling for battery optimization

For detailed protocol documentation, see the Technical Whitepaper.

Setup

  1. Install XcodeGen if you haven't already:

    brew install xcodegen
    
  2. Generate the Xcode project:

    cd bitchat
    xcodegen generate
    
  3. Open the generated project:

    open bitchat.xcodeproj
    

Option 2: Using Swift Package Manager

  1. Open the project in Xcode:

    cd bitchat
    open Package.swift
    
  2. Select your target device and run

Option 3: Manual Xcode Project

  1. Open Xcode and create a new iOS/macOS App
  2. Copy all Swift files from the bitchat directory into your project
  3. Update Info.plist with Bluetooth permissions
  4. Set deployment target to iOS 16.0 / macOS 13.0

Option 4: just

Want to try this on macos: just run will set it up and run from source. Run just clean afterwards to restore things to original state for mobile app building and development.

S
Description
bluetooth mesh chat, IRC vibes
Readme Unlicense
247 MiB
Languages
Swift 99.1%
Shell 0.4%
Rust 0.3%
Just 0.1%