AnchorDigest
Builds and recognises the compact digest envelope anchored on-chain when a client runs in digest payload mode (see AbstractBlockchainAnchorClient.OPTION_PAYLOAD_MODE).
The envelope is a small JSON object that replaces the full payload on-chain so no payload content (PII, business data, …) ever leaves the caller's custody:
{"alg":"SHA-256","canon":"JCS","digest":"<base64url(sha256(JCS(payload)))>","mediaType":"application/json"}Payload bytes are the RFC 8785 (JCS) canonical UTF-8 serialization of the payload (JsonCanonicalization), so any structurally equal payload — whatever its key order, whitespace or number spelling — verifies. The canon member records this.
Legacy envelopes (written before canonicalization was introduced) have no canon member; their digest is over the payload exactly as Json.encodeToString(JsonElement .serializer(), payload) serialized it, i.e. key-order sensitive. They are still recognised and verified with those legacy bytes, so existing anchors keep verifying. The version is explicit in the envelope rather than guessed by trying both encodings, so a JCS anchor can never be satisfied by a legacy-encoded payload or vice versa.
The digest is base64url-encoded without padding (RFC 4648 §5).
Properties
FIELD_CANONICALIZATION value for RFC 8785 JSON Canonicalization Scheme.
Envelope field naming the canonicalization applied before hashing (absent: legacy).
Envelope field holding the unpadded base64url digest value.
Envelope field holding the media type of the original (off-chain) payload.
Functions
Unpadded base64url encoding of sha256(payloadBytes).
Builds a legacy (pre-canonicalization) digest envelope over raw payloadBytes.
Builds the RFC 8785 digest envelope anchored on-chain in digest payload mode: the digest is over JCS(payload) and the envelope carries canon = "JCS".
Whether envelope is a JCS (RFC 8785) envelope rather than a legacy one.
Whether element has the shape of a digest envelope: a JSON object whose key set is exactly {alg, canon, digest, mediaType} with canon == "JCS", or the legacy {alg, digest, mediaType}, with alg == "SHA-256" and a string digest that base64url-decodes to exactly 32 bytes (the SHA-256 digest length).
Whether envelope is a digest envelope whose digest matches payloadBytes. Uses a constant-time comparison; malformed envelopes or undecodable digests yield false.
Whether envelope attests to payload, hashing the payload the way the envelope says it was hashed: JCS(payload) for envelopes with canon = "JCS", the legacy kotlinx serialization bytes for envelopes without it.
Like matches with an option for verifiers that accept only RFC 8785 anchors.