matches

fun matches(envelope: JsonObject, payload: JsonElement): Boolean

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.


fun matches(envelope: JsonObject, payload: JsonElement, requireCanonicalEnvelope: Boolean): Boolean

Like matches with an option for verifiers that accept only RFC 8785 anchors.

Parameters

requireCanonicalEnvelope

when true, a legacy envelope (no canon member) never matches. Legacy digests cover the kotlinx serialization bytes, which depend on key order and number spelling, so a strict verifier may prefer to reject them outright. Default behaviour (matches without this flag) keeps accepting legacy envelopes so old anchors keep verifying.


fun matches(envelope: JsonObject, payloadBytes: ByteArray): Boolean

Whether envelope is a digest envelope whose digest matches payloadBytes. Uses a constant-time comparison; malformed envelopes or undecodable digests yield false.