JCS (JSON Canonicalization Scheme)
RFC 8785, the deterministic JSON serialization Truestamp applies to a JSON map (claims, the item, entropy, observation, block, epoch, handover and proof records, and the genesis object) before SHA-256 hashing, so the same data always yields the same bytes and hash, whatever its key order.
Overview
JCS (JSON Canonicalization Scheme, RFC 8785) is the deterministic JSON serialization Truestamp applies to a JSON map before hashing it. Item claims, the item record (its claims hash, id and witness hashes), an entropy observation’s entropy object (its captured value with its source and, for Stellar and Bitcoin, its network) and observation record, the block record (block metadata included), the genesis object, the epoch record, a key handover and the proof object are each JCS-canonicalized and then hashed with SHA-256 under their own byte prefix, so the same logical data always produces the same bytes, and therefore the same hash, regardless of key order or whitespace. A verifier reproducing a claims hash or an entropy hash must canonicalize with JCS first, or the recomputed hash will not match the stored one. See the item’s composite fingerprint for where canonicalization sits in item hashing and entropy verification levels for its role in re-checking entropy observations.
A proof bundle carries every map a verifier has to canonicalize: the subject’s claims or entropy object, the subject’s own record, the record of every block and every epoch it names, and the entropy object of each entropy witness it carries. Checking such a bundle is therefore a matter of canonicalizing each of those with JCS and rehashing it under the matching prefix, so no hash has to be taken on trust. The bundle is canonical too: its bytes are the JCS form of the proof object and its signature, and the signature is over the proof_hash, the hash under 0x50 of the proof object’s JCS form. The field layout is in the proof bundle wire format.
Citations
- RFC 8785: JSON Canonicalization Scheme (JCS). Defines the canonical JSON byte form Truestamp hashes.