Skip to main content

validate_chain

Function validate_chain 

Source
pub fn validate_chain(ucan: &Ucan, now: u64) -> Result<(), ChainError>
Expand description

Recursively validate the delegation chain rooted at ucan (structural + temporal — run signatures separately, or use validate).

Checks, on EVERY node (the leaf, every intermediate, and the root):

  • absolute validity at now via Ucan::is_valid_at — the link must be live (not expired, not future-dated) at the single caller-supplied instant;
  • for each proof in ucan.proofs, the edge ucan ⟶ proof (linkage + attenuation + relative window containment), then recurses into the proof.

A UCAN with no proofs is a root and authorizes whatever it self-asserts (its capabilities become the ceiling) — but it is STILL clock-checked.

now is a single trusted clock value supplied by the caller, threaded down UNCHANGED to every link. It is never taken from a token’s own fields, so a forged not_before/expiration cannot self-certify validity — it can only narrow (the relative-window check) or fail the absolute check against the one authoritative now.

link is the depth from the original leaf, used both for diagnostics and as the MAX_PROOF_DEPTH DoS bound.