linked-vp only.Expand description
DIF Linked Verifiable Presentation: verifiable presentations a DID controller publishes for
anyone to discover, through a LinkedVerifiablePresentation service in its DID document.
The service entry is the normative part of the specification: type is
SERVICE_TYPE and serviceEndpoint one URL or a non-empty array of them. service
builds one, services reads them out of a document. Each URL serves one presentation;
this crate handles the JSON Web Token form (a VCDM 1.1 presentation in the vp claim, its
credentials as JWTs) and reports the JSON-LD form as unsupported.
LinkedPresentationBuildersigns a presentation for publishing:iss,subandholderthe DID, noaudand nononce, which a presentation published for anyone cannot carry.LinkedVpValidatorvalidates one presentation for the DID whose document lists it: holder andissare that DID, the holder signed with a key of the DID underauthentication,expholds when present, and every credential validates with its subject the holder (the specification’s SHOULD, configurable).LinkedVpClientfetches what a document’s services point to through anHttpClientand validates each presentation, reporting per URL: every linked presentation stands on its own.
§A linked presentation proves control at link time only
Anyone can fetch a linked presentation and replay it, and it says nothing about who
controls the DID now. A verifier must not grant access on a linked presentation alone, but
ask the holder for an interactive proof of control, as the specification’s security
considerations require. Hashlinks (hl= in a URL) are passed through and not verified.
§typ
The specification does not constrain typ. Its example presentation carries the literal
'vp+ld+jwt', stray quotes included, and its credential 'vc+ld+jwt'; the validator
accepts these (PRESENTATION_TYP, CREDENTIAL_TYP) next to JWT and no typ. The
builder writes JWT.
§Examples
The specification’s example document lists two presentations, one over HTTPS and one on IPFS:
use identity_kit::did::DidDocument;
use identity_kit::linked_vp::services;
use serde_json::json;
let document: DidDocument = serde_json::from_value(json!({
"@context": ["https://www.w3.org/ns/did/v1", "https://identity.foundation/linked-vp/contexts/v1"],
"id": "did:example:123",
"service": [
{
"id": "did:example:123#foo",
"type": "LinkedVerifiablePresentation",
"serviceEndpoint": ["https://bar.example.com/verifiable-presentation.jsonld"]
},
{
"id": "did:example:123#baz",
"type": "LinkedVerifiablePresentation",
"serviceEndpoint": "ipfs://bafybeihkoviema7g3gxyt6la7vd5ho32ictqbilu3wnlo3rs7ewhnp7lly/verifiable-presentation.jwt"
}
]
}))?;
let urls: Vec<String> = services(&document)
.map(|service| service.map(|service| service.urls[0].to_string()))
.collect::<Result<_, _>>()?;
assert_eq!(urls, [
"https://bar.example.com/verifiable-presentation.jsonld",
"ipfs://bafybeihkoviema7g3gxyt6la7vd5ho32ictqbilu3wnlo3rs7ewhnp7lly/verifiable-presentation.jwt",
]);Structs§
- Linked
Presentation Builder - Builds a linked presentation in the JSON Web Token form: a VCDM 1.1 presentation of
credential JWTs held by
holder, withiss,subandholderthe holder,jtithe presentation’sid,iatandnbfthe issuance time,expwhen an expiration is set, and neitheraudnornonce. - Linked
Presentation Report - What became of one URL of a
LinkedVerifiablePresentationservice. - Linked
VpClient - Fetches the presentations a DID document links with an
HttpClientand validates them with aLinkedVpValidator. - Linked
VpService - A
LinkedVerifiablePresentationservice of a DID document, with its URLs. - Linked
VpValidation Options - Options of
LinkedVpValidator. The audience and nonce are fixed: a linked presentation has neither. - Linked
VpValidator - Validates linked presentations:
JwtPresentationValidatorwith the options fixed to the specification, plus the holder and the signer being the DID that links the presentation.
Enums§
- Linked
VpError - Why a linked presentation could not be found, fetched or validated.
Constants§
- CONTEXT
- The JSON-LD context defining
SERVICE_TYPE, for the@contextof a DID document that lists linked presentations. - CREDENTIAL_
TYP - The header
typvalues a credential in a linked presentation may carry besidesJWT:vc+ld+jwt, and the literal'vc+ld+jwt'of the specification’s example. - PRESENTATION_
TYP - The header
typvalues a linked presentation may carry besidesJWT:vp+ld+jwt, and the literal'vp+ld+jwt'with the single quotes of the specification’s example. - SERVICE_
TYPE - The service type,
LinkedVerifiablePresentation.
Functions§
- decode
- Decodes a linked presentation and its credentials without verifying or validating
anything, accepting
PRESENTATION_TYPandCREDENTIAL_TYP. - service
- A
LinkedVerifiablePresentationservice ofidpointing tourls. - services
- The
LinkedVerifiablePresentationservices ofdocument, in document order. A service of that type whose endpoint is a map, or names something other than a URL, is anLinkedVpError::InvalidServicerather than silently skipped.