From 0231b7732b8c005e956a5b112c0e4fdddc38429e Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 16 Nov 2026 18:03:39 +0000 Subject: federation: the federation as the store's fold `Federation` is the store's fold for `docs/federation.md`. The state judging reads is the state of an event's history, which the store builds from the checkpoint and that history alone; so the version current there is the state's, the highest-numbered one written, and a history holding two versions of one number is refused. * A signed event's party is a party of the version current at its history. A write is signed by a key among its party's (those of its key set that counts, else those its version names) where a rule gives its party the place; a key set, node list, proposal or vote by a key its version names. * A vote is on the version current at its history, for a proposal proposed on it; a `true` only where every other proposal its party backs on that version is dead. Passing and dead go by the parties voting each way, a party with both counting for both. * A version event writes a proposal on the version current at its history, passed there, which is a version changing that one; one naming a checkpoint names heads after the current checkpoint at which it is current too, none in another's history, the version event above them. A node keeps a version event only where it changes the version it reads, or writes one it took. * What counts is read by the current version: of each party's writes at a place it may write, signed by a key among its party's, and of its key sets and node lists written under a version at least their `since`, the latest, then the lowest ID. A checkpoint keeps what counts at its heads and the proposals and votes on the version current there; a fork's root what counts at its heads by its version; the members are the nodes each party's node list names. Tests take a federation through writes, a key set, a proposal passing, one yes at a time, two versions changing one, a checkpoint and a node starting from it, and a fork. Events are read with their signature checked once, where they are judged. --- src/federation/event.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/federation/event.rs') diff --git a/src/federation/event.rs b/src/federation/event.rs index b8e89f1..fc519d0 100644 --- a/src/federation/event.rs +++ b/src/federation/event.rs @@ -53,6 +53,16 @@ impl Event { /// back to itself, the signature doesn't hold, or it is larger than federation 1 /// allows. pub(crate) fn read(bytes: &[u8]) -> Option { + Self::parse(bytes, true) + } + + /// The event `bytes` are, as `read` reads them, but for its signature, which isn't + /// checked: for bytes a store took already, whose signature held then. + pub(crate) fn read_taken(bytes: &[u8]) -> Option { + Self::parse(bytes, false) + } + + fn parse(bytes: &[u8], verify: bool) -> Option { if bytes.len() > LARGEST { return None; } @@ -81,7 +91,7 @@ impl Event { return None; } let sig = json.get("sig")?.as_str()?; - if !keys::verifies(&public, sig, &json.without("sig").bytes()) { + if verify && !keys::verifies(&public, sig, &json.without("sig").bytes()) { return None; } let what = json.get(does)?; -- cgit v1.3.1