From 6be5646df342b21fe82c63f59cfec5a369ab54f8 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 15 Nov 2026 12:28:33 +0000 Subject: signed values: value and meta apart, numbered; the highest seq is read A member could put a user's older signed value back beside a newer one: a change made with dependencies from before both is judged where the place was empty, so the older envelope (`prev` empty) is taken; and of values written at once, the one read was the one with the highest operation, which whoever writes the change steers. A revoked capability, a lifted ban or an earlier policy came back that way, signed by whoever signed it then. An envelope is now `cv2...`: the value as its user wrote it, and apart from it what continuum adds (swarm, path, user, at, seq, prev), the signature over the value's line and the meta's. `seq` is one more than that of the envelope it replaces, 0 where it replaces none; every node checks it with `prev`. Of the values a place holds, written at once, signed ones are read before any other, the highest `seq` first, of equal ones the lower digest (`store::candidates`): reads, snapshots and writes all go by it. An older envelope beside a newer one changes nothing. `application/continuum-signed` is the value's line, the meta's, then the signature; `scripts/continuum-signed` writes and checks it so. The wire version goes up: nodes must agree on what a place's value is. --- src/simtest/policy.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/simtest/policy.rs') diff --git a/src/simtest/policy.rs b/src/simtest/policy.rs index 4162a8c..4182b11 100644 --- a/src/simtest/policy.rs +++ b/src/simtest/policy.rs @@ -214,7 +214,9 @@ async fn write_signed( use crate::document::typed::{TimestampFormat, Val}; let at = path(at); let previous = match store::read_path(&node.doc.read().await.doc, &at) { - Ok(Some(serde_json::Value::String(text))) if text.starts_with("cv1.") => Some(text), + Ok(Some(serde_json::Value::String(text))) if text.starts_with(store::ENVELOPE) => { + Some(text) + } _ => None, }; let swarm = store::read_path(&node.doc.read().await.doc, &path("_continuum/swarm")) @@ -223,14 +225,18 @@ async fn write_signed( .and_then(|swarm| swarm.as_str().map(str::to_owned)) .unwrap_or_default(); let payload = envelope::Payload { + value, swarm, path: at.clone(), - value, user: user.to_owned(), at: 1, + seq: previous + .as_deref() + .and_then(envelope::seq) + .map_or(0, |seq| seq + 1), prev: envelope::digest(previous.as_deref()), }; - let bytes = serde_json::to_vec(&payload).unwrap(); + let bytes = payload.signed(); let sealed = envelope::seal(&bytes, &sshsig::sign(key, envelope::NAMESPACE, &bytes)).unwrap(); let sign = Sign::Write { path: at.clone(), @@ -371,14 +377,18 @@ async fn a_strict_swarm() { .flatten() .and_then(|value| value.as_str().map(str::to_owned)); let payload = envelope::Payload { + value: json!({"mode": "elsewhere"}), swarm: "elsewhere".to_owned(), path: path("config"), - value: json!({"mode": "elsewhere"}), user: "alice".to_owned(), at: 2, + seq: previous + .as_deref() + .and_then(envelope::seq) + .map_or(0, |seq| seq + 1), prev: envelope::digest(previous.as_deref()), }; - let bytes = serde_json::to_vec(&payload).unwrap(); + let bytes = payload.signed(); envelope::seal(&bytes, &sshsig::sign(&key, envelope::NAMESPACE, &bytes)).unwrap() }; forge(&c, "alice", "config", json!(elsewhere)).await; -- cgit v1.3.1