Expand description
Linked Data Signatures: RsaSignature2017, as Mastodon makes and checks
them (ActivityPub::LinkedDataSignature).
The signature sits in the document it signs, under signature, and covers
two SHA-256 hashes: one of the signature’s own options (creator,
created, expires) read against the identity context, and one of the
document without its signature. Each hash is of the canonical N-Quads
of what the JSON-LD means ([ojak_jsonld::rdf]), so a server that passes
the document on — a relay, or a server forwarding a reply — cannot change
what it says without the signature failing, while the signature still says
who wrote it.
That cuts both ways. What verifies is the graph, not the tree: a document can be rewritten into one that reads differently to a reader of JSON keys and still verify. A caller that takes a document on the strength of this signature should read it as JSON-LD processing gives it, not as it was written; ojak’s inbox does.
Structs§
- Signed
- An
RsaSignature2017read and hashed, its key not yet tried.
Constants§
- DEFAULT_
LIFETIME_ SECONDS - How long Mastodon’s signatures last.
- IDENTITY_
CONTEXT - What the signature’s options are read against.
- RSA_
SIGNATURE_ 2017 - The one Linked Data Signature suite the fediverse uses.
- SECURITY_
CONTEXT - What a signed document’s
@contextgains, so thatsignaturemeans something to a JSON-LD reader.
Functions§
- creator
- The key an
RsaSignature2017ondocumentsays made it: itscreator. - sign
- Sign
documentaskey_id, whichprivate_keyis the key of: the document with anRsaSignature2017made atcreatedand good untilexpires(Unix seconds), and the security context added to its@context, asActivityPub::LinkedDataSignature#sign!gives it. - verify
- Check the
RsaSignature2017ondocumentagainstpublic_key_pem, the key itscreatornames, atnow(Unix seconds).