Expand description
Vouch Credential build and verify.
Byte-exact port of the TypeScript buildVouchCredential (vc.ts): same JSON
shape and field ordering. The core is deterministic and clock-free, so the
caller supplies the credential id and the validity window (the SDK/wrapper
computes them); verification takes the current instant as a parameter.
Structs§
- Build
Credential Options - Inputs to build an unsigned Vouch Credential.
- DidWebvh
Verify Outcome - The outcome of
verify_with_did_webvh_log. - Verify
Result - The outcome of verifying a credential: the proof, the temporal window, and the embedded delegation chain are reported separately so a caller can distinguish “bad signature” from “expired” from “chain refused”.
Constants§
- PROTOCOL_
VERSION - SUPPORTED_
VOUCH_ VERSIONS - Every
vouchVersionthis codebase has ever issued. A credential with a missing or different version is refused. - VC_
CONTEXT_ V2 - VC_TYPE
- VOUCH_
CONTEXT_ V1 - VOUCH_
CREDENTIAL_ TYPE
Functions§
- build_
sub_ grant - Construct an unsigned sub-grant: a Vouch Credential that names the grant it
is made under by digest, in
credentialSubject.parentGrantDigest(crate::grant_chain::grant_digestof the direct parent grant). A sub-grant carries nodelegationChain; its delegatee is handed the whole grant chain instead (crate::grant_chain::grant_chain). Matches the reference builder’sparent_grant_digest(vc.build_vouch_credential). - build_
vouch_ credential - Construct an unsigned Vouch Credential matching
buildVouchCredential. - check_
envelope - Refuse a credential whose envelope is not a Vouch Credential:
@contextis an array starting with the VC 2.0 context,typeis an array holding “VerifiableCredential” and “VouchCredential”, andcredentialSubjectand itsintentare objects. - check_
intent_ resource - Refuse a credential whose
credentialSubject.intent.resourceis missing, not a string, or empty. The resource is a non-empty string naming what the credential is for (Specification 5.4.1); relative names such as “reports/q3.txt” are valid, so no URI syntax is required. - check_
vouch_ version - Refuse a credential whose
credentialSubject.vouchVersionis missing or not one ofSUPPORTED_VOUCH_VERSIONS. - issuer_
did - The issuer DID of a credential: the
issuerstring, or theidof an issuer object. - proof_
bound_ to_ issuer - True when one proof is bound to
issuer: its proofPurpose is “assertionMethod” and its verificationMethod names a key of the issuer’s DID (the part before ‘#’ equals the issuer DID). Applies to every member of a proof set. - replay_
key - The replay key for a credential, the same in every language:
lowercase hex of
SHA-256(issuer UTF-8 || 0x00 || SHA-256(proofValue UTF-8)), whereproof_valueis theproofValueof the proof the verifier checked (for a proof set, the Ed25519 proof). A DID never contains a NUL, so the two parts cannot run together. The core is stateless: the caller keeps the replay store and marks this key after a credential verifies. - sign_
sub_ grant - Build and sign a sub-grant in one step (eddsa-jcs-2022); see
build_sub_grant. - sign_
vouch_ credential - Build and sign a Vouch Credential in one step (eddsa-jcs-2022).
- validate_
intent - Validate that
intentcarries the REQUIRED non-empty action/target/resource (Specification 5.4.1). - verify
- Verify the Data Integrity proof, the validity window against
now_iso, and the embedded delegation chain (Specification 9.3). - verify_
explained - The full verifier: returns the
VerifyResultand, when the chain is refused, its reason.optscarries the trusted roots, grant keys for non-did:keyissuers, the post-quantum requirement and any explicit budget (seecrate::delegation::ChainOptions). The credential’s own proof must be a singleeddsa-jcs-2022proof here;verify_with_keysalso takes an ML-DSA-44 key for a proof set. - verify_
request_ json verify_request_json_with_clock, with did:webvh logs checked against the system clock.- verify_
request_ json_ with_ clock verify_with_keysas one JSON request, for a credential whose issuer’s keys the caller already holds, with the delegation chain’s grant keys kept apart from its trusted roots and the did:webvh logs of grant issuers.- verify_
temporal - Check that
now_isofalls within [validFrom, validUntil] allowingclock_skew_secondsof drift at each edge, at full fraction precision (crate::time). An inverted window (validFrom after validUntil) is never valid, and neither is a proof past its ownexpires. Errors on a missing or malformed time and on a skew outside 0..120 seconds. - verify_
with_ did_ webvh_ log - Verify a credential whose issuer is a did:webvh DID, with the did:webvh
logs the caller fetched: the core keeps no state and never fetches, so the
caller fetches each log from
crate::did_webvh::log_url, puts it inlogswith the latest versionId it saw before for that DID, and remembers the versions the outcome reports. - verify_
with_ keys - The top-level verifier for every proof shape a Vouch Credential carries:
- verify_
with_ roots verifywith the trusted starting points for a delegation chain: the chain’s first grant must be issued by one oftrusted_roots. With an empty list a credential carrying a chain is refused.