What Core Libraries Power BitChat? A Complete Dependency Breakdown

BitChat runs on four purpose‑built Swift libraries—BitFoundation, BitLogger, Arti, and swift‑secp256k1—that handle cryptography, logging, networking, and Tor routing.

The open‑source messaging app BitChat (permissionlesstech/bitchat) is engineered for privacy‑first, peer‑to‑peer communication. Its architecture relies on a minimal, auditable set of core dependencies rather than a sprawling third‑party ecosystem. All libraries are declared in the project's Package.swift manifest and integrated directly into the service layer.

Core Libraries Used by BitChat

The functional backbone of BitChat consists of four Swift packages. Each serves a distinct role in the stack.

BitFoundation: Data Structures and Networking Primitives

BitFoundation provides the foundational layer for BitChat's operations. According to the source code in Package.swift (lines 19‑30), this library supplies:

  • Core data structures for peer‑to‑peer messaging
  • Cryptography utilities
  • Networking primitives
  • P2P messaging abstractions

The library is imported throughout the service layer. In bitchat/Services/UnifiedPeerService.swift, BitFoundation's peer model integrates directly with Tor networking to establish anonymous connections.

BitLogger: Structured, Privacy‑Preserving Logging

BitLogger handles all observability in BitChat. Declared in Package.swift (lines 19‑31), it offers:

  • Structured logging with multiple output targets
  • Privacy‑preserving metadata handling
  • Audit‑trail capabilities for security‑critical operations

The bitchat/Services/VerificationService.swift file demonstrates BitLogger in practice for cryptographic verification flows.

Arti: Embedded Tor Client

Arti is BitChat's local Tor implementation for anonymous routing. The Package.swift manifest (lines 19‑32) references Arti as a local dependency, enabling:

  • Full Tor client operation without external binaries
  • Hidden‑service connection support
  • Stream isolation for concurrent circuits

The bitchat/Services/RelayController.swift file manages relay connections using Arti's APIs alongside BitFoundation networking.

swift‑secp256k1 (P256K): Elliptic‑Curve Cryptography

swift‑secp256k1, packaged as P256K, supplies high‑performance secp256k1 operations. Referenced in Package.swift (lines 22‑29), this library powers:

  • Elliptic‑curve key generation
  • Schnorr‑compatible signature creation and verification
  • Bitcoin‑compatible cryptographic primitives

The bitchat/ViewModels/GeoPresenceTracker.swift file shows P256K in action for location‑aware cryptographic attestations.

Code Examples: Using BitChat's Core Libraries

Cryptographic Signing with BitFoundation and P256K

import BitFoundation
import P256K   // from swift‑secp256k1

let payload = Data("Hello, world!".utf8)
let privateKey = try Secp256k1.PrivateKey()
let signature = try privateKey.sign(message: payload)

Structured Logging with BitLogger

import BitLogger

let logger = Logger(label: "com.example.bitchat")
logger.info("Message sent", metadata: ["peer": .string("alice")])

Anonymous Connection via Arti

import Arti

let tor = Tor()
tor.start()                         // launches an embedded Tor client
let conn = tor.createConnection(to: .onion("example.onion"))

Key Integration Files

The following source files demonstrate how BitChat's core libraries combine in production code:

File Role
Package.swift Declares all external dependencies with version constraints and local package references
bitchat/Services/UnifiedPeerService.swift Integrates BitFoundation's peer model with Arti Tor networking
bitchat/Services/RelayController.swift Manages relay connections using BitFoundation and Arti APIs
bitchat/Services/VerificationService.swift Uses BitLogger for cryptographic audit trails
bitchat/ViewModels/GeoPresenceTracker.swift Implements P256K elliptic‑curve operations for presence verification

Native Framework Complement

Beyond these four core libraries, BitChat leverages Apple's native frameworks for non‑functional concerns:

  • SwiftUI and Combine for reactive user interfaces
  • AVFoundation and CoreImage for media capture and processing
  • Foundation and Network for baseline system integration

These frameworks do not appear in Package.swift but are imported throughout the codebase for UI, concurrency, and hardware access.

Summary

  • BitFoundation, BitLogger, Arti, and swift‑secp256k1 (P256K) form BitChat's complete core library stack
  • All dependencies are declared in Package.swift with specific line ranges for each library
  • Service‑layer files like UnifiedPeerService.swift and RelayController.swift demonstrate production integration patterns
  • Native Apple frameworks handle UI and media without expanding the trusted dependency surface

Frequently Asked Questions

What cryptography library does BitChat use for signatures?

BitChat uses swift‑secp256k1, imported as the P256K package, for all secp256k1 elliptic‑curve operations including key generation and Schnorr‑compatible signatures. This dependency is declared in Package.swift lines 22‑29 and used in files like GeoPresenceTracker.swift.

Does BitChat require an external Tor installation?

No. BitChat embeds Arti, a Rust‑based Tor implementation exposed through Swift bindings. Arti is declared as a local package in Package.swift lines 19‑32 and started programmatically via tor.start() without external binaries.

Where are BitChat's dependencies declared?

All core library dependencies appear in the root Package.swift file. The manifest specifies remote URLs for BitFoundation, BitLogger, and P256K, plus a local path reference for Arti.

How does BitChat handle logging without exposing sensitive data?

BitChat uses BitLogger, which provides structured logging with privacy‑preserving metadata features. The VerificationService.swift file demonstrates audit‑trail patterns that log event types without leaking cryptographic secrets or message contents.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →