Expand description
Canonical JSON serialization (sorted keys, no whitespace).
Single source of truth used wherever two parties need to compute identical byte sequences over a JSON value:
- identity rotation attestations (
mur_common::identity) - card signing (
mur_common::card) - MCP description hashing (B0 rule 6 / M9.2)
The algorithm walks the serde_json::Value tree depth-first,
sorts object keys lexicographically, and emits each leaf without
whitespace. It does NOT attempt RFC 8785 (JCS) compliance — that
would require number-canonicalisation rules we don’t need for any
current caller. Two callers using this helper round-trip
losslessly; that’s the only invariant we promise.
Functions§
- canonical_
json - Returns the canonical-JSON byte sequence for
value. The output is deterministic across Rust runs, machine architectures, andserde_jsonversions (assuming the inputValueis the same). - canonical_
json_ for - Serialize
valuedirectly to canonical-JSON bytes without an intermediateserde_json::Value. For types that already implementSerialize, this avoids the round-trip allocation.