Windows Client Architecture
Targeting Windows 11 x64 24H2 (Build ≥ 26100), the Windows client pairs a C# / WinUI 3 desktop UI shell with a dedicated Go protocol subprocess (Chirp.Protocol.exe) communicating exclusively over anonymous stdin/stdout JSON pipes—opening zero local TCP callback listeners.
Why Split WinUI 3 from a Go Engine Subprocess?
- Best tool for each boundary: WinUI 3 delivers native Fluent windows, high-contrast theming, WASAPI low-latency audio, Concentus Opus coding, and camera/image QR handling; meanwhile
Chirp.Protocol.exedirectly shares Go validation packages (internal/identity,internal/store) alongside Go HTTP/SSE and LiveKit / Pion WebRTC. - Zero local port exposure: Spawned by
ProtocolClient.csover inheritedstdin/stdoutpipes, nothing binds127.0.0.1ports, preventing local port hijacking by untrusted co-located software. - Deterministic shutdown: Closing the final WinUI window signals clean teardown, wiping temporary caches and terminating both
Chirp.exeandChirp.Protocol.exe.
Two-Process Module Breakdown
1. Desktop UI & Native Audio (Client/windows/Chirp/)
| File | Responsibility & Implementation Notes |
|---|---|
App.xaml.cs · MainWindow.xaml.cs | Single-instance protocol activation (cn.youzifeile.chirp.windows://auth/callback), shared multi-window state (DesktopState.cs), static taskbar/Alt-Tab preview protection, and responsive panes. |
App.xaml | Three semantic resource dictionaries (Light, Dark, HighContrast) derived from design-tokens.json. |
WindowsHelloLoginKey.cs · LoginResumption.cs · LoginLock.cs | Opt-in Microsoft Passport KSP RSA key enrollment in Settings (verifies NCryptDecrypt blocks silent reads), multi-window shared lock state, clock-checked foreground Windows Hello unlock, and background interruption handling. |
DesktopAudio.cs · AudioService.cs | NAudio WASAPI I/O, Concentus (+ OpusSharp.Natives DTX decode) Opus coding, and P/Invoke bindings to Chirp.RNNoise.dll and chirp_windows_audio.dll (Rust Sonora AEC3/AGC2). |
PairingCamera.cs · PairingImages.cs | Camera capture & single-frame image QR scanning via QRCoder / ZXing.Net, gated behind Windows Hello local user verification. |
2. Protocol, Identity & Media Subprocess (Client/windows/engine/)
| File | Responsibility & Implementation Notes |
|---|---|
main_windows.go · login_windows.go · resumption_windows.go | Dispatches JSON pipe commands, Passkey login (including up-to-60s exponential-backoff browser handoff polling POST /api/auth/login/windows-handoff), phone QR polling, .chirpkey handling, and AES-256-GCM + Hello-RSA-wrapped cold-launch login resumption (keeping business Bearers strictly in engine RAM). |
vault_windows.go | Protects per-user identities.v5 via Windows DPAPI (CryptProtectData) with atomic write + fsync, immediately clear()ing plaintext buffers and transient signing seeds. |
authority_windows.go · authorization_trust_windows.go | Loads sibling AuthorizationTrust.json and maintains fresh signed snapshots plus highest observed log checkpoints. |
room_windows.go · media_windows.go | Room state machine, SAS verification, dual-slot smooth rotation, and encrypted Pion WebRTC audio/chat transport. |
files_windows.go · attachment_session_windows.go | Manages transient session-* ciphertext cache, 1 MiB chunking, and AES-256-GCM record encryption. |
chirplog_store_windows.go | Async batched UTC hourly .chirplog writer and 24-hour exporter. |
Windows E2EE & Audio Pipeline Details
- No unready or plaintext DataChannel writes: A custom Go SDK overlay exposes only
ChirpReliable()and re-checks lease deadlines and provider state immediately prior to writingDataChannelframes, while clearing all external ICE servers on connect. - Dual-slot crypto & replay map:
mediaSessionholds twokeySlotbuffers derived via HKDF intocipher.AEADalongside per-senderseen map[[12]byte]struct{}replay sets, overwriting retiring slots after rotation. - Sleep-aware clock & software AEC:
chirp_mls_native.dlltracks monotonic elapsed time including system sleep via Win32GetTickCount64(), while Rust Sonora (lib.rs) delivers software AEC3 and AGC2 for desktop mics lacking hardware processing.
Uninstaller removes local identity state
Unlike macOS Keychain persistence, the Windows Setup.exe Inno Setup uninstaller (Chirp.iss) cleans the local app data directory (including identities.v5). Keep a valid .chirpkey backup and passphrase ready before uninstalling or reinstalling. See Native Client Builds · Windows.
