VertRule JCS Glovebox
RFC 8785 JSON Canonicalization Scheme (JCS)
This crate is the single authorized location for JSON canonicalization
in the VertRule ecosystem. All receipt serialization and digest computation
MUST use these functions to ensure deterministic hashing.
The implementation enforces the RFC 8785 rules that materially affect wire compatibility:
- UTF-16 code-unit sorting for object property names
- ECMAScript-compatible primitive serialization
- UTF-8 output without insignificant whitespace
- duplicate-property rejection on raw JSON parse paths
- I-JSON string / number validation
API
- [
to_canon_bytes] — Serialize anySerializetype to canonical JSON bytes - [
to_canon_string] — Serialize anySerializetype to a canonical JSON string - [
to_canon_bytes_from_slice] — Parse raw JSON and return canonical bytes (rejects duplicates) - [
to_canon_string_from_str] — Parse raw JSON string and return canonical string - [
canonicalize] — Sort object keys recursively in aserde_json::Value(in-place)
Usage
use to_canon_string;
use Serialize;
let receipt = Receipt ;
let json = to_canon_string.expect;
assert_eq!;
Enforcement
Any code path that computes a digest over JSON MUST use this crate.
Using serde_json::to_string() directly for digest input is forbidden.