How to verify freight evidence JSON hashes with RFC 8785
Decide what you are proving before hashing. Hash the raw bytes to identify an exact file. If both systems need to hash the same JSON record despite serialization differences, agree a canonicalization scheme and publish the hash scope.
Do not confuse byte identity with JSON data identity.
RFC 8785 specifies a deterministic JSON representation for eligible inputs. Reject duplicate object keys before they can be discarded by a parser. Preserve string content and avoid silently rounding high-precision data. For exact source files such as a PDF or original API response, retain a separate raw-file digest instead of substituting a reserialized copy.
Different spacing does not mean the underlying record changed.
In a synthetic evidence pack, two exporters write the same manifest values with different object key order and spacing. Their raw file digests may differ; after applying the same canonicalization, their canonical digests should match. Changing a shipment field should break that match. A match does not establish who created the record, when it existed, or whether the underlying shipment facts are true.
Verify the contract before distributing digests.
- Record the hash algorithm, canonicalization profile and object or file scope so another system can reproduce the check.
- Test changed values, changed array order, duplicate keys and high-precision identifiers alongside formatting-only changes.
- Keep signature, custody and timestamp evidence separate. A digest alone is not a trusted signature or timestamp.