SophaxChat
The code
Every line of it, to read like a book.
The iPhone, Mac and Android apps, the cryptography, the network, the tests — 208 files and 47,809 lines in 13 chapters. Read them in order, page by page, or open any one. This is the code as of 7 October 2026, shared under the MIT licence.
I built SophaxChat by directing AI. It has not been independently audited, so please don’t rely on it where your safety depends on it.
Contents
-
01
Start here
What SophaxChat is, why it exists, what has changed, and the terms it is shared under.
-
02
In words, before code
What it protects against and what it does not, and how the protocol and the cryptography work — explained in plain documents.
-
03
Who you are
Your identity is two pairs of keys made on your own device. Here they are created, kept in the Keychain, backed up, split among friends if you choose, and watched for changes.
-
04
The lock
How two phones agree on a secret (X3DH) and keep changing it with every message (the Double Ratchet).
-
05
The heart
One file ties everything together: it sends and receives, starts sessions, relays for others and holds messages until they can go.
-
06
Finding each other
How messages travel: over Bluetooth and Wi‑Fi nearby, from phone to phone, over TCP further away — and a shared table for finding people without any server.
- Sources/SophaxChatCore/Network/MessageTransport.swift
- Sources/SophaxChatCore/Network/NetworkProtocol.swift
- Sources/SophaxChatCore/Network/MeshManager.swift
- Sources/SophaxChatCore/Network/RelayRouter.swift
- Sources/SophaxChatCore/Network/LanDiscovery.swift
- Sources/SophaxChatCore/Network/TCPTransport.swift
- Sources/SophaxChatCore/Crypto/TLSCertManager.swift
- Sources/SophaxChatCore/DHT/DHTBootstrap.swift
- Sources/SophaxChatCore/DHT/DHTEngine.swift
- Sources/SophaxChatCore/DHT/DHTStorage.swift
- Sources/SophaxChatCore/DHT/DHTStore.swift
- Sources/SophaxChatCore/DHT/KBucket.swift
-
07
Anywhere in the world
Tor, built into the app so no other app is needed, and the .onion address it gives each person.
- SophaxChat/Tor/TorManager.swift
- SophaxChat/Tor/HiddenServiceKeyWriter.swift
- SophaxChat/Tor/TorFramework/NSBundle+GeoIP.h
- SophaxChat/Tor/TorFramework/NSBundle+GeoIP.m
- SophaxChat/Tor/TorFramework/NSCharacterSet+PredefinedSets.h
- SophaxChat/Tor/TorFramework/NSCharacterSet+PredefinedSets.m
- SophaxChat/Tor/TorFramework/TORAuthKey.h
- SophaxChat/Tor/TorFramework/TORAuthKey.m
- SophaxChat/Tor/TorFramework/TORCircuit.h
- SophaxChat/Tor/TorFramework/TORCircuit.m
- SophaxChat/Tor/TorFramework/TORConfiguration.h
- SophaxChat/Tor/TorFramework/TORConfiguration.m
- SophaxChat/Tor/TorFramework/TORControlCommand.h
- SophaxChat/Tor/TorFramework/TORControlReplyCode.h
- SophaxChat/Tor/TorFramework/TORController.h
- SophaxChat/Tor/TorFramework/TORController.m
- SophaxChat/Tor/TorFramework/TORLogging.h
- SophaxChat/Tor/TorFramework/TORLogging.m
- SophaxChat/Tor/TorFramework/TORNode.h
- SophaxChat/Tor/TorFramework/TORNode.m
- SophaxChat/Tor/TorFramework/TOROnionAuth.h
- SophaxChat/Tor/TorFramework/TOROnionAuth.m
- SophaxChat/Tor/TorFramework/TORThread.h
- SophaxChat/Tor/TorFramework/TORThread.m
- SophaxChat/Tor/TorFramework/TORX25519KeyPair.h
- SophaxChat/Tor/TorFramework/TORX25519KeyPair.m
- Sources/SophaxChatCore/Crypto/OnionAddress.swift
- Sources/SophaxChatCore/Crypto/Keccak.swift
- Frameworks/tor.xcframework/Info.plist
- Frameworks/tor.xcframework/ios-arm64/tor.framework/Info.plist
- Frameworks/tor.xcframework/ios-arm64_x86_64-simulator/tor.framework/Info.plist
-
08
Groups
Group chats: sender keys, and MLS — a standard for group encryption — in a small Rust library joined to Swift.
- Sources/SophaxChatCore/Group/GroupTypes.swift
- Sources/SophaxChatCore/Group/ChatManager+MLS.swift
- Sources/SophaxChatCore/Group/GroupCryptoMigration.swift
- Sources/SophaxChatCore/Group/MLSGroupManager.swift
- Sources/SophaxChatCore/MLS/Generated/sophax_mls.swift
- Sources/SophaxChatCore/MLS/Generated/sophax_mlsFFI.h
- Sources/SophaxChatCore/MLS/Generated/sophax_mlsFFI.modulemap
- rust/.gitignore
- rust/Cargo.lock
- rust/Cargo.toml
- rust/bindgen/main.rs
- rust/build.rs
- rust/src/lib.rs
- scripts/build_mls_xcframework.sh
-
09
What stays on the phone
Messages and attachments, kept encrypted on the device; backups and exports that never go to a cloud; an error log that stays private.
-
10
The iPhone and Mac app
Everything you see and touch — the SwiftUI screens, settings, the assistant that runs on the device — and the project files, icons and pictures that make the app.
- SophaxChat/App/AppState.swift
- SophaxChat/App/SophaxChatApp.swift
- SophaxChat/Views/AI/AIAssistantView.swift
- SophaxChat/Views/Chat/AudioMessageView.swift
- SophaxChat/Views/Chat/CameraPickerView.swift
- SophaxChat/Views/Chat/ChatListView.swift
- SophaxChat/Views/Chat/ChatView.swift
- SophaxChat/Views/Chat/ChatViewModel.swift
- SophaxChat/Views/Chat/CreateGroupView.swift
- SophaxChat/Views/Chat/FullScreenImageView.swift
- SophaxChat/Views/Chat/GroupChatView.swift
- SophaxChat/Views/Chat/GroupChatViewModel.swift
- SophaxChat/Views/Chat/MessageBubbleView.swift
- SophaxChat/Views/Chat/NoteToSelfView.swift
- SophaxChat/Views/Chat/VideoMessageView.swift
- SophaxChat/Views/Chat/VoiceRecorder.swift
- SophaxChat/Views/DuressEmptyView.swift
- SophaxChat/Views/Onboarding/OnboardingView.swift
- SophaxChat/Views/Settings/AppLockView.swift
- SophaxChat/Views/Settings/BackupView.swift
- SophaxChat/Views/Settings/ContactCardView.swift
- SophaxChat/Views/Settings/ContactScannerView.swift
- SophaxChat/Views/Settings/CrashLogView.swift
- SophaxChat/Views/Settings/DuressPINSetupView.swift
- SophaxChat/Views/Settings/FindByPeerIDView.swift
- SophaxChat/Views/Settings/FullExportView.swift
- SophaxChat/Views/Settings/IdentityView.swift
- SophaxChat/Views/Settings/LinkedDevicesView.swift
- SophaxChat/Views/Settings/SettingsView.swift
- SophaxChat/Assets.xcassets/AppIcon.appiconset/Contents.json
- SophaxChat/Assets.xcassets/Contents.json
- SophaxChat/Info.plist
- SophaxChat/NFC/NFCContactManager.swift
- SophaxChat/PrivacyInfo.xcprivacy
- SophaxChat/Resources/cs.lproj/Localizable.strings
- SophaxChat/Resources/en.lproj/Localizable.strings
- SophaxChat/SophaxChat-Bridging-Header.h
- SophaxChat/SophaxChat.entitlements
- SophaxChat.xcodeproj/project.pbxproj
- SophaxChat.xcodeproj/project.xcworkspace/contents.xcworkspacedata
- project.yml
- Package.swift
- make_icon.swift
-
11
Android
The same messenger for Android, in Kotlin and Jetpack Compose.
- android/README.md
- android/app/build.gradle.kts
- android/app/proguard-rules.pro
- android/app/src/main/AndroidManifest.xml
- android/app/src/main/kotlin/com/sophax/sophaxchat/.gitkeep
- android/app/src/main/kotlin/com/sophax/sophaxchat/AppState.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ChatManager.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/MainActivity.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/SophaxForegroundService.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/SophaxRestartWorker.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/crypto/CryptoTypes.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/crypto/DoubleRatchet.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/crypto/GroupTypes.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/crypto/HiddenServiceKeyWriter.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/crypto/IdentityManager.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/crypto/OnionAddress.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/crypto/PreKeyManager.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/crypto/X3DH.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/network/DHTBootstrap.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/network/DHTEngine.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/network/DHTStorage.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/network/DHTStore.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/network/KBucketTable.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/network/LanDiscovery.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/network/NearbyManager.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/network/TcpTransport.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/network/TorManager.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/network/WifiDirectManager.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/notifications/NotificationHelper.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/protocol/NetworkProtocol.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/storage/AttachmentStore.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/storage/MessageStore.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/AppLockScreen.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/SafetyNumberScreen.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/chat/ChatListScreen.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/chat/ChatScreen.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/chat/CreateGroupScreen.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/chat/FindByPeerIDScreen.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/chat/GroupChatScreen.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/chat/SharedComponents.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/onboarding/OnboardingScreen.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/settings/BackupScreen.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/settings/ContactQRSheet.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/settings/DuressPinScreen.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/settings/LinkedDevicesScreen.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/settings/SettingsScreen.kt
- android/app/src/main/kotlin/com/sophax/sophaxchat/ui/theme/Theme.kt
- android/app/src/main/res/drawable/ic_launcher.xml
- android/app/src/main/res/mipmap-hdpi/ic_launcher_background.xml
- android/app/src/main/res/mipmap-mdpi/ic_launcher_background.xml
- android/app/src/main/res/mipmap-xhdpi/ic_launcher_background.xml
- android/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.xml
- android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.xml
- android/app/src/main/res/values/strings.xml
- android/build.gradle.kts
- android/gradle.properties
- android/gradle/libs.versions.toml
- android/settings.gradle.kts
-
12
Tests
Checks that the cryptography, the groups, the network and the relay behave as they should.
-
13
Making and shipping
Scripts and settings for building, checking and releasing, and notes for anyone who wants to help.
- scripts/generate_android_icons.sh
- scripts/generate_icons.sh
- scripts/setup-github.sh
- scripts/setup_frameworks.sh
- .github/CONTRIBUTING.md
- .github/FUNDING.yml
- .github/ISSUE_TEMPLATE/bug_report.md
- .github/ISSUE_TEMPLATE/feature_request.md
- .github/pull_request_template.md
- .github/workflows/android-ci.yml
- .github/workflows/android-release.yml
- .github/workflows/codeql.yml
- .github/workflows/swift.yml
- .gitignore