documentDigest<P> function

String documentDigest<P>(
  1. TrustTaskDocument<P> doc,
  2. Object? payloadToJson(
    1. P payload
    )
)

The content identity of a document, per SPEC §7.2's keying paragraph: SHA-256 over the canonical serialization of the whole document, as hex.

Consumer-local. Never on the wire, and not the §4.9.3 task digest.

Implementation

String documentDigest<P>(
  TrustTaskDocument<P> doc,
  Object? Function(P payload) payloadToJson,
) =>
    sha256HexOfString(canonicalJson(doc.toJson(payloadToJson)));