# What Core Libraries Power BitChat? A Complete Dependency Breakdown

> Discover the core Swift libraries powering BitChat: BitFoundation, BitLogger, Arti, and swift-secp256k1. Explore their roles in cryptography, logging, networking, and Tor routing for a complete dependency breakdown.

- Repository: [permissionlesstech/bitchat](https://github.com/permissionlesstech/bitchat)
- Tags: deep-dive
- Published: 2026-08-01

---

**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`](https://github.com/permissionlesstech/bitchat/blob/main/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`](https://github.com/permissionlesstech/bitchat/blob/main/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`](https://github.com/permissionlesstech/bitchat/blob/main/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`](https://github.com/permissionlesstech/bitchat/blob/main/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`](https://github.com/permissionlesstech/bitchat/blob/main/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`](https://github.com/permissionlesstech/bitchat/blob/main/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`](https://github.com/permissionlesstech/bitchat/blob/main/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`](https://github.com/permissionlesstech/bitchat/blob/main/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

```swift
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

```swift
import BitLogger

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

```

### Anonymous Connection via Arti

```swift
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`](https://github.com/permissionlesstech/bitchat/blob/main/Package.swift) | Declares all external dependencies with version constraints and local package references |
| [`bitchat/Services/UnifiedPeerService.swift`](https://github.com/permissionlesstech/bitchat/blob/main/bitchat/Services/UnifiedPeerService.swift) | Integrates BitFoundation's peer model with Arti Tor networking |
| [`bitchat/Services/RelayController.swift`](https://github.com/permissionlesstech/bitchat/blob/main/bitchat/Services/RelayController.swift) | Manages relay connections using BitFoundation and Arti APIs |
| [`bitchat/Services/VerificationService.swift`](https://github.com/permissionlesstech/bitchat/blob/main/bitchat/Services/VerificationService.swift) | Uses BitLogger for cryptographic audit trails |
| [`bitchat/ViewModels/GeoPresenceTracker.swift`](https://github.com/permissionlesstech/bitchat/blob/main/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`](https://github.com/permissionlesstech/bitchat/blob/main/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`](https://github.com/permissionlesstech/bitchat/blob/main/Package.swift) with specific line ranges for each library
- Service‑layer files like [`UnifiedPeerService.swift`](https://github.com/permissionlesstech/bitchat/blob/main/UnifiedPeerService.swift) and [`RelayController.swift`](https://github.com/permissionlesstech/bitchat/blob/main/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`](https://github.com/permissionlesstech/bitchat/blob/main/Package.swift) lines 22‑29 and used in files like [`GeoPresenceTracker.swift`](https://github.com/permissionlesstech/bitchat/blob/main/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`](https://github.com/permissionlesstech/bitchat/blob/main/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`](https://github.com/permissionlesstech/bitchat/blob/main/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`](https://github.com/permissionlesstech/bitchat/blob/main/VerificationService.swift) file demonstrates audit‑trail patterns that log event types without leaking cryptographic secrets or message contents.