Expand description
RDF, and its canonical form: what a Linked Data Signature signs.
A Linked Data Signature (RsaSignature2017, which Mastodon makes and
checks) does not sign the JSON. It signs the RDF dataset the JSON-LD
means, written out in the canonical N-Quads that the URDNA2015 algorithm
gives — so two documents that say the same thing in different words carry
the same signature, and verifying one means turning it into RDF exactly as
its signer did.
canonize does that, from expansion in this crate, through the JSON-LD
1.1 “Deserialize JSON-LD to RDF” algorithm, to the “Universal RDF Dataset
Normalization Algorithm 2015” (URDNA2015, which RDFC-1.0 standardised
without changing its output).
Two things make it stricter than a general processor, both deliberate:
- A context the registry does not hold is an error here, not
ActivityStreams. A signer resolved it to something; without it, the
dataset cannot be rebuilt, and guessing would only make the signature
fail later. A caller that fetches contexts asks
unresolved_contextswhich ones to add first. - The work is bounded. Expansion is held to
Limits; the blank-node labelling, whose worst case is factorial in the number of blank nodes that look alike, is held to a budget of its own and gives up withError::CanonicalizationBudgetExceededrather than run away.
Structs§
- Quad
- One RDF statement, in the default graph or a named one.
Enums§
- Term
- A node or value in an RDF statement.
Functions§
- canonicalize
- URDNA2015: the dataset’s canonical N-Quads, one statement a line, sorted.
- canonize
- The canonical N-Quads of
document: what anRsaSignature2017hashes. - canonize_
with canonize, with limits of the caller’s choosing.- expand_
for_ rdf - Expand
documentthe way RDF needs it, refusing a context ojak does not ship. - to_rdf
- The JSON-LD “Deserialize JSON-LD to RDF” algorithm, over a document
expand_for_rdfexpanded. - unresolved_
contexts - Every context
documentnames, directly or through a context it names, thatregistrydoes not hold: what a caller that fetches contexts has to fetch beforecanonizecan succeed.