BitChat: Decentralized Mesh Messaging for iOS and macOS

BitChat: Decentralized Mesh Messaging for iOS and macOS

BitChat enables offline and global communication via a dual-transport architecture

BitChat is a decentralized peer-to-peer messaging application for iOS and macOS that eliminates the need for central servers, phone numbers, or user accounts. It achieves this by utilizing a hybrid transport system that switches between local Bluetooth mesh networks for offline proximity communication and the Nostr protocol for global internet connectivity.

Hybrid Transport Architecture

BitChat uses two complementary layers to ensure messages are delivered regardless of internet availability.

Bluetooth Mesh Network (Offline)

For local communication, BitChat employs a Bluetooth Low Energy (BLE) mesh network. This layer is designed for scenarios where cellular and Wi-Fi networks are unavailable, such as during natural disasters, protests, or in remote areas.

  • Multi-hop Relay: Messages can route through nearby devices up to a maximum of 7 hops, extending the reach beyond the same-device range.
  • Security: The Noise Protocol is used for end-to-end encryption with forward secrecy.
  • Efficiency: The app uses a binary protocol and adaptive power duty cycling to minimize battery drain on mobile devices.
  • Automatic Discovery: Peers are discovered and connected automatically without manual pairing.

Nostr Protocol (Internet)

When internet access is available, BitChat leverages the Nostr protocol to provide global reach.

  • Global Relay Network: Messages are routed through a distributed network of over 290 relays.
  • Location-Based Channels: BitChat implements geographic chat rooms using geohash coordinates. These channels are categorized by precision:
    • Block level: 7 characters
    • Neighborhood level: 6 characters
    • City level: 5 characters
    • Province level: 4 characters
    • Region level: 2 characters
  • Privacy: Private messages use NIP-17 "gift-wrapped" encryption for internet-based privacy.

Intelligent Message Routing

BitChat automatically selects the most efficient transport method for direct messages based on availability:

  1. Bluetooth First: The app prefers a direct BLE connection with an established Noise session for maximum privacy and speed.
  2. Nostr Fallback: If Bluetooth is unavailable, the app routes the message through the global Nostr relay network using the recipient's public key.
  3. Smart Queuing: If neither transport is available, messages are queued and delivered automatically once a connection is established.

Technical Features and Security

  • Privacy-First Design: The system uses ephemeral keys for different geohash areas and requires no persistent identifiers.
  • Emergency Wipe: A triple-tap gesture allows users to instantly clear all local data.
  • Performance: The app integrates LZ4 message compression to optimize data transfer over constrained BLE links.
  • Interface: The app supports IRC-style commands such as /slap, /msg, and /who.

Community Insights and Real-World Testing

User reports indicate that the effectiveness of the Bluetooth mesh depends heavily on node density. One user reporting from the Fusion Festival noted that while they saw approximately 20 devices, the lack of density meant most messages only traveled 2 hops, limiting the effective distance across large grounds.

Additionally, the project has faced external pressures, with reports that the Indian government requested the removal of the BitChat repository from GitHub, leading to its presence on Radicle.

"I tested it and it's surreal to text without WiFi or cellular."

Development and Setup

BitChat is released into the public domain. Developers can build the project using Xcode or the just command-line tool. Setup requires configuring local .xcconfig files and manually updating entitlements to match the developer's bundle ID.

Sources