← Back to Blog

Deterministic Graph Hashing with RFC 8785 and Ed25519

How Consyllus guarantees that the same curriculum graph produces the exact same SHA-256 content hash across Electron, Node CLI, and Cloudflare Workers.

When sharing curriculum graphs across a decentralized community marketplace, a subtle engineering challenge arises: standard JSON.stringify() is not deterministic across runtimes or key insertion orders.

Why Canonical JSON Matters for Knowledge Graphs

If a creator signs a Linear Algebra graph on Windows Desktop and a learner verifies that signature in memory before saving to disk, a single reordered property key or whitespace difference would invalidate the Ed25519 signature.

Consyllus solves this by enforcing RFC 8785 (JSON Canonicalization Scheme) combined with a strict 5-field metadata whitelist (subject, subject_type, references, author_id, gen_by):

  1. Deterministic Array Ordering: Nodes are sorted by hierarchical ID (id), edges by (from, to), and concepts by id.
  2. Recursive Lexicographical Key Sorting: Every JSON object key is sorted by UTF-16 code units with zero whitespace.
  3. Volatile Metadata Exclusion: Fields like last_updated, content_hash, and signature are excluded from the hashable payload, allowing the main process to write meta.signature back into graph.json without mutating content_hash or breaking local progress.json bindings.