vc only.Expand description
Validation of credential and presentation JWTs: signature, binding to the issuer or holder, validity period, audience, nonce and status.
The validators take two extension points: a KeyResolver (from
resolver, re-exported here), which turns the KeyReference of a JWT
into the public key of its signer, and a JwsVerifier, which
checks the signature and is DefaultVerifier unless an
application substitutes its own. The crate’s Resolver
resolves DID URLs; a CompositeKeyResolver adds
keys by value (JwkResolver) or the key sets of HTTPS
issuers (JwksResolver, feature jwks). A StatusCheck is a third, optional extension
point, for credentialStatus and the status claim, shared with the SD-JWT validators.
§What is checked
For a credential (JwtCredentialValidator):
- The token is a compact JWS whose header names its key
(
KeyReference::from_jws, with the issuer asiss): akidthat is a DID URL of the formdid:…#fragment, a#fragmentrelative to a DID issuer, akidinto the key set of an HTTPS issuer, or ajwk,x5corjkuheader. A path or DID parameters such asversionIdin a DID URL are refused, so the signer cannot pick the document version its key is looked up in (ADR 0004). Whentypis present it names the profile:JWTfor VCDM 1.1,vc+jwtfor VCDM 2.0, or one of the values the options add (CredentialValidationOptions::additional_typ). - The payload is a claims set that maps to a
Credential(or aCredentialV2), with its registered claims agreeing with the credential. A payload with_sdor_sd_algas a member name anywhere, or an array element{"...": "<digest>"}, is the issuer-signed JWT of an SD-JWT and is refused (ValidationError::SdJwtPayload), typed or not: read as a plain JWT, its digests would be properties and its concealed claims would look absent. Thetypcheck alone does not catch it, since an untyped token is accepted;SdJwtCredentialValidatorofsd_jwt_vcvalidates it. - The key the reference names is resolved for
KeyRole::Issuer(assertionMethodin a DID document) and verifies the signature. - The key belongs to the issuer (
KeyReference::binds_to): the issuer is the DID of the DID URL, thedid:jwkor thumbprint of a key by value, or the HTTPS issuer of the key set. nbf,expandiat, and the credential’s own validity period, hold at the validation time, within the leeway.credentialStatuspasses theStatusCheck, per theStatusPolicy, and so does astatusclaim, which the Token Status List defines for any JWT (§6.1), asCredentialStatus::StatusClaimafter thecredentialStatusentries. With thestatus-listfeature (whichsd-jwtimplies) astatusclaim that does not parse, or names no status mechanism, is refused; without it the claim cannot be checked, so it fails underStatusPolicy::Strictand is ignored otherwise.
For a presentation (JwtPresentationValidator): the same for the presentation JWT, with
the key resolved for KeyRole::Subject (authentication) and bound to the holder, plus the expected
audience and nonce; then every credential it carries is validated as above, and its subject
is checked against the holder per the SubjectHolderRelationship. A VCDM 1.1
presentation (typ JWT, validate) carries
credential JWTs in its vp claim; a VCDM 2.0 one (typ vp+jwt,
validate_v2) is the payload itself and envelopes
vc+jwt credentials and, with the sd-jwt feature, vc+sd-jwt ones (validated as
SdJwtCredentialValidator::validate_v2 of sd_jwt_vc does, with the key binding the
presentation options require); an envelope of another media type fails for that
credential alone.
Everything a verifier decides by policy (which issuers to trust, which credential types to
accept, what the claims must say) is left to the application, which gets the decoded
credential back. decode_credential, decode_credential_v2, decode_presentation
and decode_presentation_v2 decode without verifying, for a look at a token before
deciding how to validate it, and refuse an SD-JWT payload as the validators do; extract_issuer and extract_holder read just the signer’s DID.
Re-exports§
pub use crate::resolver::KeyReference;pub use crate::resolver::KeyReferenceError;pub use crate::resolver::KeyResolutionError;pub use crate::resolver::KeyResolver;pub use crate::resolver::KeyRole;
Structs§
- Credential
Validation Options - Options of
JwtCredentialValidator. - Decoded
Credential - A validated or decoded VCDM 1.1 credential JWT: its header, its claims (custom ones included) and the credential they map to.
- Decoded
Credential V2 - A validated or decoded VCDM 2.0 credential JWT: its header, its claims and the credential.
- Decoded
Presentation - A validated or decoded VCDM 1.1 presentation JWT: its header, its claims (custom ones included), the presentation, and its credentials decoded.
- Decoded
Presentation V2 - A validated or decoded VCDM 2.0 presentation JWT (
vp+jwt): its header, its claims, the presentation, and its enveloped credentials unwrapped and decoded. - JwtCredential
Validator - Validates credential JWTs, see the module documentation for the checks.
- JwtPresentation
Validator - Validates presentation JWTs and the credential JWTs they carry, see the module documentation for the checks.
- Presentation
Validation Error - Why a presentation did not validate: the presentation itself, or some of its credentials.
- Presentation
Validation Options - Options of
JwtPresentationValidator. - Time
Options - The validation time and the clock skew allowed around it.
Enums§
- Credential
Status - A status entry of a credential, of either credential format, for a
StatusCheck. - Fail
Fast - Whether to stop at the first failing credential of a presentation.
- Presented
Credential V2 - A credential unwrapped from an
EnvelopedVerifiableCredentialof a VCDM 2.0 presentation: secured as a JWT (application/vc+jwt) or, with thesd-jwtfeature, with SD-JWT (application/vc+sd-jwt). - Status
Error - Why a
StatusCheckdid not pass. - Status
Policy - What to do about a status entry: a
credentialStatusentry, or thestatusclaim of an SD-JWT credential or of a JWT credential. - Subject
Holder Relationship - How the subject of a presented credential must relate to the holder presenting it.
- Validation
Error - Why a credential or presentation JWT did not validate.
Traits§
- Status
Check - Checks the status of a credential: fetches the status list, bitmap or registry an entry points to and reports whether the credential is still good.
Functions§
- decode_
credential - Decodes a VCDM 1.1 credential JWT without verifying or validating anything.
- decode_
credential_ v2 - Decodes a VCDM 2.0 credential JWT without verifying or validating anything.
- decode_
presentation - Decodes a VCDM 1.1 presentation JWT and its credentials without verifying or validating anything.
- decode_
presentation_ v2 - Decodes a VCDM 2.0 presentation JWT and unwraps and decodes its credentials without
verifying or validating anything. A credential secured with SD-JWT (feature
sd-jwt) has its disclosures processed, which checks the digests, but no signature is verified. - extract_
holder - The DID of the holder of a presentation JWT, read without verifying anything:
iss, else theholderof thevpclaim (VCDM 1.1) or of the payload (VCDM 2.0). - extract_
issuer - The DID of the issuer of a credential JWT, read without verifying anything:
iss, else theissuerof thevcclaim (VCDM 1.1) or of the payload (VCDM 2.0).