Skip to main content

Module credentials

Module credentials 

Source
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§

BuildCredentialOptions
Inputs to build an unsigned Vouch Credential.
DidWebvhVerifyOutcome
The outcome of verify_with_did_webvh_log.
VerifyResult
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 vouchVersion this 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_digest of the direct parent grant). A sub-grant carries no delegationChain; its delegatee is handed the whole grant chain instead (crate::grant_chain::grant_chain). Matches the reference builder’s parent_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: @context is an array starting with the VC 2.0 context, type is an array holding “VerifiableCredential” and “VouchCredential”, and credentialSubject and its intent are objects.
check_intent_resource
Refuse a credential whose credentialSubject.intent.resource is 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.vouchVersion is missing or not one of SUPPORTED_VOUCH_VERSIONS.
issuer_did
The issuer DID of a credential: the issuer string, or the id of 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)), where proof_value is the proofValue of 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 intent carries 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 VerifyResult and, when the chain is refused, its reason. opts carries the trusted roots, grant keys for non-did:key issuers, the post-quantum requirement and any explicit budget (see crate::delegation::ChainOptions). The credential’s own proof must be a single eddsa-jcs-2022 proof here; verify_with_keys also 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_keys as 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_iso falls within [validFrom, validUntil] allowing clock_skew_seconds of 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 own expires. 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 in logs with 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
verify with the trusted starting points for a delegation chain: the chain’s first grant must be issued by one of trusted_roots. With an empty list a credential carrying a chain is refused.