Skip to content

R3 hash verification: add explicit "no canonicalization, hash bytes as served" guidance #13

@rohanharikr

Description

@rohanharikr

The R3 spec currently mandates RFC 8785 canonical JSON serialization for the hash:

"computed as the SHA-256 hash of the canonical JSON serialization ([@!RFC8785]) of the R3 document" (§ R3 hash)
"Compute the SHA-256 hash of the fetched document using canonical JSON serialization ([@!RFC8785])" (§ R3 fetch verification)

Suggestion: remove the canonicalization requirement. Hash the bytes the resource serves, not a re-canonicalized form.

Rationale:

  • Canonicalization adds an implementation dependency (RFC 8785 libraries, edge cases) that's hard to get right.
  • The resource is the authoritative source of bytes — its serialization IS the document.
  • Pattern: serialize once at the RS, persist those bytes, serve them verbatim. Verifier hashes received bytes directly.

Practical implications:

  • Replace "canonical JSON serialization" with "the bytes returned by the resource"
  • Add implementer guidance: serialize once, store, serve verbatim — re-serialization between hash computation and serving will break the chain
  • RSes that build R3 documents on the fly need to persist serialized bytes (e.g. KV) rather than re-build/re-serialize per request

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions