verify

fun verify(vpJwt: String)

Verifies the integrity and authenticity of a Verifiable Presentation (VP) encoded as a JSON Web Token (JWT).

This function performs several crucial validation steps to ensure the trustworthiness of the provided VP:

  • Verifies that the vcJwts inside the VP are valid

  • Parses and validates the structure of the JWT.

  • Ensures the presence of critical header elements alg and kid in the JWT header.

  • Resolves the Decentralized Identifier (DID) and retrieves the associated DID Document.

  • Validates the DID and establishes a set of valid verification method IDs.

  • Identifies the correct Verification Method from the DID Document based on the kid parameter.

  • Verifies the JWT's signature using the public key associated with the Verification Method.

If any of these steps fail, the function will throw a SignatureException with a message indicating the nature of the failure.

Parameters

vpJwt

The Verifiable Presentation in JWT format as a String.

Throws

if the verification fails at any step, providing a message with failure details.

if critical JWT header elements are absent.

Example:

try {
VerifiablePresentation.verify(signedVpJwt)
println("VP Verification successful!")
} catch (e: SignatureException) {
println("VP Verification failed: ${e.message}")
}