Skip to content

R3: hash bytes as served, remove canonicalization mandate#16

Open
rohanharikr wants to merge 1 commit into
dickhardt:mainfrom
rohanharikr:r3-remove-canonicalization
Open

R3: hash bytes as served, remove canonicalization mandate#16
rohanharikr wants to merge 1 commit into
dickhardt:mainfrom
rohanharikr:r3-remove-canonicalization

Conversation

@rohanharikr
Copy link
Copy Markdown
Contributor

Closes #13

Changes the R3 hash to be computed over the bytes the resource serves, removing the RFC 8785 canonical JSON serialization requirement.

Diff summary

Content Addressing section (around line 320):

  • Hash is now computed over "the bytes of the R3 document as served by the resource"
  • Adds an implementer-guidance paragraph: serialize once, store, serve verbatim. Flags common breakage (middleware re-stringification, CDN minification, framework helpers that reorder keys). Recommends persisting serialized bytes for resources that build R3 docs on the fly.

AS Processing step 3 (around line 386):

  • "Compute the SHA-256 hash of the bytes received" replaces the canonical-JSON-serialization phrasing.

Why

Per discussion in #13: the resource is the authoritative source of bytes, and canonicalization libraries (RFC 8785) add an implementation dependency that's hard to get right. Hashing the served bytes avoids the canonicalization-drift class of bugs entirely.

Practical consequence for RSes: serialize the R3 document once, store those bytes (e.g. KV), serve them verbatim on every request for the same r3_uri. The reference implementation (r3demo) already follows this pattern.

The R3 hash is now computed over the bytes the resource serves, not
over a canonicalized form. The resource's serialization is the
document. Adds implementer guidance: serialize once, store, serve
verbatim — re-serialization between hash computation and serving
will break the chain.

Removes RFC 8785 dependency. Resources that build documents on the
fly should persist serialized bytes (e.g. KV) rather than re-build
per request.

Closes dickhardt#13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant