From 3152af43504bcfd6285d41f6b6ff67631d01fd0e Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 15 Nov 2026 16:31:37 +0000 Subject: signed values: one reading of an envelope, everywhere Three parts read an envelope three ways: the store's order took any string with the prefix whose meta held a `seq`, its reads any whose value decoded, the checks only one with four parts and a meta of exactly its fields. A string that the first two took and the checks refused was read first, read as the registry's or the policy's value, and treated as nothing by the check of the next write there. `document::signed` reads an envelope the one way: four parts, the value JSON, the meta exactly its six fields (one more, or one twice, and it isn't one), no newline in either, the signature decoding. The store's order, its plain reads, the checks, the API and the users API all go by it. What isn't one in every respect is a plain string, wherever it is read. --- src/access/sealed.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/access/sealed.rs') diff --git a/src/access/sealed.rs b/src/access/sealed.rs index 545fe76..2b8085a 100644 --- a/src/access/sealed.rs +++ b/src/access/sealed.rs @@ -148,8 +148,8 @@ pub(crate) fn check( let JsonValue::String(text) = value else { return Err("a sealed value is a string (cs1.)".to_owned()); }; - let sealed = if text.starts_with(store::ENVELOPE) { - match envelope::read(text)?.value { + let sealed = if let Ok(payload) = envelope::read(text) { + match payload.value { JsonValue::Null => return Ok(()), JsonValue::String(sealed) => sealed, _ => return Err("signed, but not sealed".to_owned()), @@ -343,7 +343,7 @@ mod tests { let meta = json!({"swarm": "s", "path": ["notes"], "user": "alice", "at": 1, "seq": 0, "prev": ""}); format!( "{}{}.{}.c2ln", - store::ENVELOPE, + crate::document::signed::START, B64URL.encode(value.to_string()), B64URL.encode(meta.to_string()) ) -- cgit v1.3.1