From 47d88d224c5c8fa42b4f30b8ec37c7e5deb83ea2 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 13 Nov 2026 03:16:33 +0000 Subject: screen: a twin of this node's actor switches it only signed with its key A node switched to a fresh actor whenever a peer showed it a change of its own actor that it didn't hold, signed or not. So any peer made a node start a writer at will, by sending a copy of its last change with another value: and every writer costs every node memory in proportion to the document's history. Copies of a node's data directory hold its key, and sign their changes with it; a stranger can't. A twin switches the node only where a signature by the node's own key of it is kept or waiting. Unsigned, it is refused as forged as before, and nothing switches. --- src/document/signatures.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/document') diff --git a/src/document/signatures.rs b/src/document/signatures.rs index 79c8569..f9dd94b 100644 --- a/src/document/signatures.rs +++ b/src/document/signatures.rs @@ -594,6 +594,17 @@ impl Signatures { signed } + /// Whether a signature of `hash` by the node whose public key is `key` is kept or + /// waiting for its change (`pending`): checked here, the change not needed. + pub(crate) fn signed_by(&self, hash: &ChangeHash, key: &[u8; 32]) -> bool { + let message = message(hash); + self.by_change + .get(hash) + .into_iter() + .chain(self.pending.by_change.get(hash).into_iter().flatten()) + .any(|signature| crate::identity::verify(key, &message, signature)) + } + /// Whether a valid signature of `hash` is kept: it vouches for its change and the /// changes of its actor it builds on. pub(crate) fn signed(&self, hash: &ChangeHash) -> bool { -- cgit v1.3.1