# Proof 06 — Four-Law Byzantine CRDT Join-Semilattice & Non-Terminal Cold Recovery `fatext v4.0` upgrades single-writer identity logs (`microlog.json`) from a terminal-freeze model to a **four-law [Byzantine CRDT](https://martin.kleppmann.com/2025/03/31/papoc-keynote-byzantine.html) bounded join-semilattice** with non-terminal cold-key recovery inspired by [AT Protocol `did:plc`](https://web.plc.directory/spec/v0.1/did-plc) and [Decoupling Trust in BFT-CRDTs](https://arxiv.org/html/2606.31759v1). ## 1. Algebraic State Space & Merge Operator For a fixed self-certifying `agent_id` (`pow_bits >= 22` at `seq = 0`), every cryptographically verified `microlog` trace $T = [E_0, E_1, \dots, E_m]$ maps to an abstract state: $$\sigma(T) \in \mathcal{S} = \text{Revoked} \;\sqcup\; \bigcup_{r \in \mathbb{N}} \{r\} \times \left(\text{Frozen} \;\sqcup\; \mathcal{C}_r\right)$$ where $r = \text{recovery\_count}(T) \ge 0$ counts verified `recover` transitions along $T$, $\mathcal{C}_r$ is the set of prefix-consistent active chains at recovery epoch $r$, and $\text{Revoked}$ absorbs any chain ending in a valid `revoke` event signed by any historical $pk_{\text{id}}(1..kv)$. Given local state $S_A$ and incoming verified state $S_B$, `merge_peer_microlog` computes $S_A \sqcup S_B$ under strict lexicographic dominance: 1. **Law 1 (`Tombstone-Wins`)**: If $S_A \in \text{Revoked}$ or $S_B \in \text{Revoked}$, output $\text{Revoked}$ (clearing any prior equivocation freeze file). 2. **Law 2 (`Cold-Recovery-Override`)**: Otherwise, let $r_A, r_B$ denote the verified `recovery_count` values of $S_A, S_B$. If $r_B > r_A$, output $S_B$ (clearing any hot-key equivocation freeze at $r_A$); symmetrically if $r_A > r_B$, output $S_A$. 3. **Law 3 (`Equivocation-Freeze`)**: Otherwise ($r_A = r_B = r$), if either $S_A$ or $S_B$ is $\text{Frozen}$, or there exists index $i \le \min(|T_A|, |T_B|) - 1$ with $\text{SHA3-256}(E_{A,i}) \ne \text{SHA3-256}(E_{B,i})$, output $(r, \text{Frozen})$ and persist the compact two-event fraud proof `(E_{A,i}, E_{B,i})`. 4. **Law 4 (`Monotonic Valid Extension`)**: Otherwise $T_A$ and $T_B$ share a common prefix (`T_A \preceq T_B` or `T_B \preceq T_A`); output the longer chain $\arg\max(|T_A|, |T_B|)$. ## 2. Theorem 6.1 (Strong Eventual Consistency under Byzantine Hot-Key Equivocation) **Statement**: Assuming `SHA3-256` ([NIST FIPS 202](https://csrc.nist.gov/pubs/fips/202/final)) collision resistance, $(\mathcal{S}, \sqcup)$ is a commutative, associative, and idempotent join-semilattice: $$\forall X, Y, Z \in \mathcal{S}:\quad X \sqcup X = X,\quad X \sqcup Y = Y \sqcup X,\quad (X \sqcup Y) \sqcup Z = X \sqcup (Y \sqcup Z).$$ **Proof**: Define the partial order $\sqsubseteq$ on $\mathcal{S}$ as the ordinal sum: - $\text{Revoked}$ is the unique top element $\top$ ($\forall X \in \mathcal{S},\; X \sqsubseteq \text{Revoked}$). - Across distinct recovery epochs $r_1 < r_2$, every $(r_1, u_1) \sqsubset (r_2, u_2)$ regardless of whether $u_1$ was a clean chain in $\mathcal{C}_{r_1}$ or $\text{Frozen}$. - Within a fixed recovery epoch $r$, $(r, \text{Frozen})$ is the local top above $\mathcal{C}_r$: for $T_1, T_2 \in \mathcal{C}_r$, $T_1 \sqsubseteq T_2 \iff T_1$ is a prefix of $T_2$; if $T_1, T_2$ diverge at some sequence index $i$ ($\text{SHA3-256}(E_{1,i}) \ne \text{SHA3-256}(E_{2,i})$), their least upper bound in $\{r\} \times (\text{Frozen} \sqcup \mathcal{C}_r)$ is uniquely $(r, \text{Frozen})$. Because every pair of elements in an ordinal sum of join-semilattices possesses a unique least upper bound $\sup(X, Y)$ that matches Laws 1–4 case-by-case, $\sqcup$ is automatically idempotent, commutative, and associative. Consequently, honest peers observing arbitrary gossip permutations or partition heals converge deterministically to the exact same state without global consensus. $\square$ ## 3. Theorem 6.2 (Unforgeability of Cold Recovery & Anchor Immutability) **Statement**: Let an honest agent anchor `commitment` $C_{\text{rec}} = \text{SHA3-256}(\text{"fatext-v4-recovery-commit\n"} \parallel \text{agent\_id} \parallel \text{"\n"} \parallel PK_{\text{rec}})$ in a `recovery_commit` event while keeping the 32-byte `recovery.seed` air-gapped. Suppose an adversary compromises the online `master.seed` (learning all hot scalars $sk_{\text{id}}(1..kv)$) and makes $q_H$ random-oracle queries and $q_S$ signing queries. The adversary's probability of either: 1. overwriting $C_{\text{rec}}$ via hot-key events, or 2. forging an accepted `recover` event advancing $r \to r + 1$ is bounded by: $$\text{Adv}^{\text{forge-rec}}(\mathcal{A}) \le \text{Adv}^{\text{euf-cma}}_{\text{Schnorr-ristretto255}}(\mathcal{B}) + \frac{q_H + 1}{2^{256}}.$$ **Proof**: 1. **Anchor Lock**: `verify_microlog_chain` rejects any second `recovery_commit` event once `st.recovery_commit` is non-empty (`ERR_MICROLOG_RECOVERY_LOCKED`). Only a valid `recover` event can rotate `st.recovery_commit -> ev.next_recovery_commit`. 2. **Preimage + Dual-Signature Reduction**: Accepting `ev.type == "recover"` requires both $\text{SHA3-256}(\text{"fatext-v4-recovery-commit\n"} \parallel \text{agent\_id} \parallel \text{"\n"} \parallel PK'_{\text{rec}}) = C_{\text{rec}}$ and a valid [RFC 9496 `ristretto255`](https://www.rfc-editor.org/info/rfc9496/) Schnorr signature `sig_recovery` under $PK'_{\text{rec}}$ over `"fatext-v4-microlog\n" || JCS(ev_unsigned)`. - Case A ($PK'_{\text{rec}} \ne PK_{\text{rec}}$): $\mathcal{A}$ exhibits a distinct second preimage for $C_{\text{rec}}$ under `SHA3-256`, occurring with probability at most $(q_H + 1)/2^{256}$ in the Random Oracle Model. - Case B ($PK'_{\text{rec}} = PK_{\text{rec}}$): Reduction $\mathcal{B}$ embeds its Schnorr EUF-CMA challenge public key as $PK_{\text{rec}}$, computes $C_{\text{rec}}$ honestly, and hands $\mathcal{A}$ the entire online `master.seed` directly (since `recovery.seed` is cryptographically independent of `master.seed`). Any valid `sig_recovery` output by $\mathcal{A}$ is a direct existential forgery under $PK_{\text{rec}}$, reducing via the Forking Lemma to Discrete Logarithm in prime-order `ristretto255` ($\ell \approx 2^{252}$). $\square$ ## 4. Scope & Trade-off with Historical-Key Revocation Because Law 1 (`Tombstone-Wins`) intentionally allows **any** historical hot key $sk_{\text{id}}(1 \dots kv)$ to sign a terminal `revoke` event—preserving the offline pre-signed `fatext ctl kill` emergency circuit-breaker for spawned workers—cold recovery (`Law 2`) is strictly a **non-destructive hot-key rescue mechanism**: - **Protected**: Unauthorized hot-key `rotate` branches, compromised signing devices where the attacker omits `revoke`, and split-view `Equivocation-Freeze` locks caused by concurrent hot-key forks. - **Out of Scope**: Preventing a hot-key thief who already possesses `master.seed` (and therefore historical `sk_id(1)`) from issuing a destructive terminal `revoke` tombstone; in that adversarial case, Law 1 guarantees fast global kill of the compromised `ftx_` identifier and migration via `successor_id`. ## 3. Theorem 6.3 (`v4.1` Commutative & Associative Double-`revoke` Join) **Bug in Naive Tombstone Merge**: If an honest controller issues an emergency revocation $R_1$ (`reason = "controller-emergency-revoke"`, head hash $h_1$) while a compromised hot-key device concurrently broadcasts $R_2$ (`reason = "compromised"`, head hash $h_2 \ne h_1$), an asymmetric rule such as `if state_a.revoked: return state_a` violates commutativity ($R_1 \sqcup R_2 \ne R_2 \sqcup R_1$) and causes replicas to diverge on `successor_id` and `reason`. **Statement (`v4.1` Deterministic Law 1 Join)**: When two verified states $(A, B)$ both satisfy `revoked = true`: - If `head_hash(A) == head_hash(B)`, preserve any already-marked `revoke_equivocated = true` state cleanly (`idempotent` & `commutative`). - If `head_hash(A) != head_hash(B)`, select `chosen = argmin_{head_hash}(A, B)` lexicographically and set `revoke_equivocated = true`, `revoke_reason = "equivocated-revoke"`, and `successor_id = null`. **Proof**: Lexicographic total ordering over SHA3-256 hex digests `head_hash` guarantees a unique global minimum $\min(h_1, \dots, h_m)$ over any finite set of conflicting `revoke` heads regardless of merge bracketing or delivery permutation. Clearing `successor_id` and fixing `revoke_reason = "equivocated-revoke"` whenever $|H| \ge 2$ yields identical state fields across $(A \sqcup B) \sqcup C = A \sqcup (B \sqcup C)$ and $A \sqcup B = B \sqcup A$, preserving the join-semilattice laws under conflicting revocations.