RFC 0002 — Canonical JSON v1
Goal
Make signatures and digests stable across languages.
Canonicalization id
json.c14n.v1
Rules
- UTF‑8 bytes only
- Objects: keys sorted lexicographically by Unicode codepoint
- No insignificant whitespace
- Numbers:
- Disallow NaN and Infinity
- Disallow floats unless explicitly permitted by schema
- Prefer integers or decimal strings
- Arrays: order preserved
- No duplicate keys
- All digests represented as strings:
sha256:+ 64 lowercase hex
Engineering note
Canonicalization is part of the security boundary:
- Every signature is computed over canonical JSON bytes.
- Every digest field in contracts is defined in terms of canonical JSON bytes or raw bytes, explicitly.