Skip to main content

Module integrity

Module integrity 

Source
Expand description

FEP-8b32 Object Integrity Proof verification (eddsa-jcs-2022 and mldsa44-jcs-2024).

Fedify-based servers (GoToSocial, hackers.pub, …) attach a Data Integrity proof to the activities they deliver, authenticating the activity itself rather than the HTTP transport. This lets a recipient accept an activity whose HTTP Signature it can’t verify (a different signature spec, a shared inbox, or a forwarded/relayed delivery) as long as the author’s proof holds.

The algorithm mirrors Fedify’s verifyProof (packages/fedify/src/sig/proof.ts) and the W3C “Data Integrity EdDSA Cryptosuites” eddsa-jcs-2022 suite:

  1. proofConfig = the document’s @context plus the fixed proof metadata (type, cryptosuite, verificationMethod, proofPurpose, created).
  2. unsecuredDocument = the activity with every proof form removed.
  3. hashData = SHA-256(JCS(proofConfig)) ‖ SHA-256(JCS(unsecuredDocument)).
  4. Verify the proofValue over hashData with the key resolved from the proof’s verificationMethod.

mldsa44-jcs-2024 (W3C “Verifiable Credential Data Integrity — Quantum Resistant Cryptosuites”) is the same algorithm over ML-DSA-44 instead of Ed25519, with one deliberate difference in step 1 that the specification itself calls out: the proof configuration always takes the document’s @context, rather than keeping whatever the proof carried.

Enums§

Cryptosuite
The cryptosuites this module can verify.
PublicKey
A public key resolved from a proof’s verificationMethod.

Constants§

DATA_INTEGRITY_CONTEXT
The Data Integrity context that defines proof, version 1: what a document is to carry before a proof is attached to it, for a JSON-LD reader to find the proof at all.

Functions§

decode_ed25519_multikey
Decode a Multikey publicKeyMultibase value into a raw 32-byte Ed25519 key.
decode_mldsa44_multikey
Decode a Multikey publicKeyMultibase value into an ML-DSA-44 public key.
decode_multikey
Decode whichever key type a Multikey carries.
ed25519_public_key
The public key of a raw 32-byte Ed25519 seed.
encode_ed25519_multikey
The Multikey publicKeyMultibase for an Ed25519 public key: the ed25519-pub multicodec header, base58btc, with multibase’s z prefix.
extract_integrity_proof
Find a usable assertion-method integrity proof on document, if present, and not expired at now, in seconds since the Unix epoch.
generate_ed25519_key
Generate an Ed25519 signing key, returned as a PKCS#8 PEM.
generate_ed25519_seed
A fresh raw 32-byte Ed25519 seed.
integrity_proofs
Every usable assertion-method integrity proof on document, in order, as extract_integrity_proof returns one. A document may carry several, in different suites or by different keys, and one that does not verify says nothing about the others.
parse_ed25519_key
The raw 32-byte seed and public key of a PKCS#8 PEM Ed25519 key.
sign_object_integrity_proof
Attach an eddsa-jcs-2022 integrity proof to document.
verify_object_integrity_proof
Verify an integrity proof on document against public_key, the key resolved from the proof’s verificationMethod.
with_data_integrity_context
document with DATA_INTEGRITY_CONTEXT in its @context, however that is shaped — added to an array, made an array with a single context, or set when there is none — and as it was if it is there already. None when document is not an object.