Expand description
Canonical JSON serialization per Ratify Protocol SPEC §6.
Every implementation MUST produce byte-identical output for the same input or signatures will not verify across languages.
Rules:
- Object members in lex order (byte order on UTF-8), RECURSIVELY.
- No whitespace between tokens. No trailing newline.
- UTF-8 encoding.
- Integers as shortest decimal.
- Byte arrays as base64-standard strings with padding.
- ‘<’, ‘>’, ‘&’ pass through unmodified.
- U+2028 / U+2029 escape as \u2028 / \u2029 (matches Go behavior).
- Minimum string escaping per RFC 8259.
Modules§
- base64_
bytes - serde helper to (de)serialize Vec
as base64-standard strings.
Functions§
- base64_
std_ decode - Standard base64 decode.
- base64_
std_ encode - Standard base64 encode with padding.
- canonical_
json - Canonical JSON-encode a serde_json::Value.
- encode_
bool - Write a canonical-JSON bool into
out. - encode_
bytes_ b64 - Write a base64-standard-encoded byte slice as a canonical-JSON string.
- encode_
constraint - Write a canonical Constraint object into
out, matching the per-kind shape emitted by Constraint’s Serialize impl (alphabetical keys). - encode_
constraints - Write a canonical-JSON array of Constraint objects.
- encode_
f64 - Write a canonical-JSON f64 following the Ratify integer-valued rule: whole-number f64s emit as shortest decimal integer; others as-is.
- encode_
hybrid_ pub_ key - Write a canonical HybridPublicKey object:
{"ed25519":"...","ml_dsa_65":"..."}. Keys are already in lex order: “ed25519” < “ml_dsa_65”. - encode_
hybrid_ sig - Write a canonical HybridSignature object:
{"ed25519":"...","ml_dsa_65":"..."}. - encode_
i32 - Write a canonical-JSON i32 into
out. - encode_
i64 - Write a canonical-JSON i64 (shortest decimal) into
out. - encode_
points_ array - Write a canonical-JSON array of [f64; 2] pairs (geo polygon points).
- encode_
str - Write a canonical-JSON string (with escaping) into
out. - encode_
str_ array - Write a canonical-JSON array of strings into
out. - hex_
decode - Lower- or upper-case hex.
- hex_
encode - Lowercase hex.