Skip to content

Windows Client Architecture ​

Last updated

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? ​

  1. 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.exe directly shares Go validation packages (internal/identity, internal/store) alongside Go HTTP/SSE and LiveKit / Pion WebRTC.
  2. Zero local port exposure: Spawned by ProtocolClient.cs over inherited stdin/stdout pipes, nothing binds 127.0.0.1 ports, preventing local port hijacking by untrusted co-located software.
  3. Deterministic shutdown: Closing the final WinUI window signals clean teardown, wiping temporary caches and terminating both Chirp.exe and Chirp.Protocol.exe.

Two-Process Module Breakdown ​

1. Desktop UI & Native Audio (Client/windows/Chirp/) ​

FileResponsibility & Implementation Notes
App.xaml.cs · MainWindow.xaml.csSingle-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.xamlThree semantic resource dictionaries (Light, Dark, HighContrast) derived from design-tokens.json.
WindowsHelloLoginKey.cs · LoginResumption.cs · LoginLock.csOpt-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.csNAudio 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.csCamera 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/) ​

FileResponsibility & Implementation Notes
main_windows.go · login_windows.go · resumption_windows.goDispatches 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.goProtects 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.goLoads sibling AuthorizationTrust.json and maintains fresh signed snapshots plus highest observed log checkpoints.
room_windows.go · media_windows.goRoom state machine, SAS verification, dual-slot smooth rotation, and encrypted Pion WebRTC audio/chat transport.
files_windows.go · attachment_session_windows.goManages transient session-* ciphertext cache, 1 MiB chunking, and AES-256-GCM record encryption.
chirplog_store_windows.goAsync batched UTC hourly .chirplog writer and 24-hour exporter.

Windows E2EE & Audio Pipeline Details ​

  1. 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 writing DataChannel frames, while clearing all external ICE servers on connect.
  2. Dual-slot crypto & replay map: mediaSession holds two keySlot buffers derived via HKDF into cipher.AEAD alongside per-sender seen map[[12]byte]struct{} replay sets, overwriting retiring slots after rotation.
  3. Sleep-aware clock & software AEC: chirp_mls_native.dll tracks monotonic elapsed time including system sleep via Win32 GetTickCount64(), 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.