Vincenzo Palazzo 46de1a3623 fix: skip unknown file TLVs instead of dropping the transfer
`BitchatFilePacket.decode` resolved every tag through the four-value
`TLVType` enum and bailed on the first miss:

    val t = TLVType.from(data[off].toUByte()) ?: return null

So a file packet carrying one tag this build does not know is not
partially understood — it is discarded whole, media included. The
receiver shows nothing and logs nothing; the sender sees a successful
transfer. Both apps look healthy.

iOS has always skipped unknown tags (`case nil: continue` in its own
`BitchatFilePacket.decode`), so the two implementations disagreed about
what a valid packet is, and the tag list stopped being extensible in
practice: any optional field added by a newer or third-party client
costs every Android peer the whole file rather than just that field.

Unknown tags now advance past the value, exactly as iOS does. Known-tag
handling, the 4-byte CONTENT length, multi-CONTENT concatenation and
every existing rejection are unchanged.

The skip path is deliberately allocation- and log-free per TLV, because
its iteration count is chosen by the sender: a zero-length unknown TLV
costs 3 bytes, so a padded packet would otherwise mean millions of empty
array copies and formatted log lines monopolising the mesh handler. The
count is reported once after the loop instead.

Tests: `decode should skip unknown TLV types instead of dropping the
whole file` (extension before CONTENT), `decode should skip an unknown
TLV that trails the content` (after it), and `decode should handle a
packet padded with many zero-length unknown TLVs` (200k of them). The
first two fail on the old decoder.
2026-07-30 00:11:18 +02:00
2025-07-08 20:37:46 +02:00
2025-07-08 20:37:46 +02:00
2026-07-29 03:05:01 +02:00

icon_128x128@2x

bitchat for Android

A decentralized peer-to-peer messaging app with dual transport architecture: local Bluetooth mesh networks for offline communication and internet-based Nostr protocol for global reach. No accounts, no phone numbers, no central servers.

This is the Android implementation of bitchat, fully protocol-compatible with the iOS version for cross-platform mesh communication.

bitchat.free

GitHub Releases

Get it on Google Play

License

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

Features

  • Dual Transport Architecture: Bluetooth LE mesh for offline messaging, Nostr relays for internet-based messaging
  • Location-Based Channels: Geographic chat rooms using geohash coordinates over Nostr relays
  • Intelligent Message Routing: Automatically chooses the best transport, with queuing and retry when a peer is unreachable
  • End-to-End Encryption: Noise Protocol (XX pattern, X25519 + ChaCha20-Poly1305) for private messages over the mesh
  • Decentralized Mesh Network: Automatic peer discovery and multi-hop relay over Bluetooth LE (max 7 hops)
  • Wi-Fi Aware Transport: Higher-bandwidth local mesh on supported devices
  • Channel Chats: Topic-based group messaging with optional password protection (Argon2id + AES-256-GCM)
  • IRC-Style Commands: Familiar /join, /msg, /who style interface
  • Tor Support: Built-in Tor (Arti) for private internet connectivity
  • Emergency Wipe: Triple-tap to instantly clear all data
  • Cross-Platform: Binary protocol compatible with bitchat on iOS and macOS

Technical Architecture

Bluetooth Mesh Network (Offline)

  • Direct peer-to-peer within Bluetooth range, multi-hop relay through nearby devices
  • Noise Protocol sessions with forward secrecy; peer identities derived from static keys
  • Compact binary packet format with fragmentation, TTL routing, and deduplication
  • Adaptive duty cycling and connection limits for battery efficiency
  • Foreground service keeps the mesh alive within Android background execution limits

Nostr Protocol (Internet)

  • Global reach via public relays, geohash-based location channels
  • Private messages fall back to Nostr for mutual favorites when the mesh is unavailable
  • Ephemeral keys per geohash area

Android Stack

  • Kotlin, Jetpack Compose (Material 3), MVVM
  • Coroutines and Flow for all networking and state
  • Core components: MeshForegroundService (persistent connectivity), BluetoothMeshService / WifiAwareMeshService (transports), UnifiedMeshService (transport selection), NoiseSessionManager (encryption sessions), MessageRouter (mesh/Nostr routing with outbox retry)

Building

Requires Android Studio and the Android SDK (API 26+).

git clone https://github.com/permissionlesstech/bitchat-android.git
cd bitchat-android
./gradlew assembleDebug

Install on a connected device:

adb install -r app/build/outputs/apk/debug/app-debug.apk

The app requests Bluetooth, location (required for BLE scanning), and notification permissions at runtime.

Release APKs and the Android App Bundle can be rebuilt byte-for-byte in the pinned Linux container. Maintainers should follow the Android release guide. See Reproducible builds for the build trust model and public GitHub/Google Play verification procedures.

Testing

# Unit tests
./gradlew test

# Lint
./gradlew lint

# Instrumented tests (requires a device or emulator)
./gradlew connectedAndroidTest

Note that BLE mesh behavior is difficult to emulate; protocol and session logic is covered by unit tests, while radio-level behavior needs real devices.

Description
bluetooth mesh chat, IRC vibes
Readme
Languages
Kotlin 85.8%
Java 10.1%
Python 2.6%
Shell 1.1%
Rust 0.3%
Other 0.1%