mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 20:25:22 +00:00
Replaces destroy-then-rebuild Noise re-handshakes with an atomic reconnect protocol: prepared XX message-1 handoff tokens (claim-once, invalidated by crossed inbound initiations), receive-only quarantine of the established transport while an inbound replacement proves identity (promote on success, rollback+cooldown on failure/timeout), deterministic lower-peerID-wins crossed-initiator resolution, and a per-link-epoch BLE revalidation policy that re-proves cached sessions inside the same bleQueue critical section as the link rebind. On main, a fresh msg1 simply destroys an established session and rekey spans two non-atomic barriers. Includes the review fix: timeout-restores defer outbound queue draining until the convergence retry completes (restore reason plumbed end-to-end), so DMs are never drained under keys a restarted peer already discarded — with a deterministic interleaving test. Identity-mismatch restores drain immediately. Full local suite 1768 tests green.
22 lines
582 B
Swift
22 lines
582 B
Swift
//
|
|
// NoiseSessionError.swift
|
|
// bitchat
|
|
//
|
|
// This is free and unencumbered software released into the public domain.
|
|
// For more information, see <https://unlicense.org>
|
|
//
|
|
|
|
enum NoiseSessionError: Error, Equatable {
|
|
case invalidState
|
|
case notEstablished
|
|
case sessionNotFound
|
|
case alreadyEstablished
|
|
case peerIdentityMismatch
|
|
}
|
|
|
|
/// The manager owns the exact attempt's one bounded recovery. Packet handling
|
|
/// must not launch its historical second, immediate restart for this failure.
|
|
struct NoiseManagedHandshakeFailure: Error {
|
|
let underlying: Error
|
|
}
|