Skip to main content

Module canonical

Module canonical 

Source
Expand description

Canonical-JSON (RFC 8785 / JCS) + content-addressed identity. For our string-only payload, serde_json’s default output (sorted BTreeMap keys, compact separators, raw non-ASCII, no /-escape) IS JCS — verified by the golden vectors. Liveness arrays are sorted+deduped here so set-valued fields are order-insensitive; grounds[] keeps authored order.

Functions§

canonical_json
Canonical bytes for our string-only hashed Value. serde_json’s compact output over a sorted-key Value equals RFC-8785/JCS only because the payload contains no numbers/bools/nulls (JCS number canonicalization is not applied). Do not reuse on a number-bearing Value (see module header).
compute_id
id = first 12 hex of SHA-256 over the canonical-JSON of the hashed fields.
hashed_value
The Value containing ONLY the hashed fields (decision, observe, grounds, parent_id).