pub struct Verifier<'a> { /* private fields */ }Expand description
Stateless verifier. Requires a DID resolver to fetch producer keys.
DID-cache refresh (RFC-ACDP-0001 §5.11 “Caching”, 0.5.0). When
the signing key is missing from a cached DID document (step 4) or
is not in its assertionMethod (step 5), the verifier re-fetches the
document once, bypassing the cache, and re-runs steps 4–7 against
it. The fresh verdict is final. Forced re-fetches are rate-limited
per DID by the WebResolver
(WebResolver::with_forced_refresh_interval); when the limit
refuses one, a key absent from the stale copy is reported as
AcdpError::KeyResolutionUnreachable (transient — absence was not
proven), while a key present but outside assertionMethod keeps the
AcdpError::KeyNotAuthorized verdict.
Implementations§
Source§impl<'a> Verifier<'a>
impl<'a> Verifier<'a>
pub fn new(resolver: &'a WebResolver) -> Self
Sourcepub fn fresh_since(self, since: Instant) -> Self
pub fn fresh_since(self, since: Instant) -> Self
Treat every DID document fetched at or after since as fresh for
this verifier’s calls, so a forced re-fetch already performed by
an earlier step of the same operation (for example, an earlier
candidate in one revocation-discovery run) is not repeated.
Without it, each call uses its own start time.
Sourcepub async fn verify_body(&self, body: &Body) -> Result<(), AcdpError>
pub async fn verify_body(&self, body: &Body) -> Result<(), AcdpError>
Full end-to-end verification per RFC-ACDP-0001 §5.11.
Steps:
- (Implicit) Check
key_idhas a#fragment. - Verify
key_idDID portion equalsbody.agent_id. - Resolve the DID document.
- Find the verification method by fragment.
- Check
assertionMethodauthorization. - Extract the Ed25519 public key.
- Verify the signature over the content_hash ASCII bytes.
(Hash recomputation is step 0, performed first.)
Sourcepub async fn verify_body_signed(&self, body: &Body) -> Result<(), AcdpError>
pub async fn verify_body_signed(&self, body: &Body) -> Result<(), AcdpError>
Verify only the hash recomputation + DID resolution + signature
envelope, assuming structural validation has already been done by
the caller. Use when you want to separate structural failures
from cryptographic ones — e.g. Self::verify_body itself runs
acdp_validation::validate_body first and then delegates the
hash + signature phases to this method, so the two concerns stay
independently testable.
Sourcepub fn verify_body_hash(&self, body: &Body) -> Result<(), AcdpError>
pub fn verify_body_hash(&self, body: &Body) -> Result<(), AcdpError>
Step 0 only — recompute the content_hash over ProducerContent
and compare against body.content_hash. Lets diagnostic
callers record hash-pass/fail independently of the signature
stage (FEAT-05).
Typed path (verify_typed_body_hash). Prefer
Self::verify_context_hash for a retrieved context: it hashes
the raw received body (RFC-ACDP-0001 §5.7).
Sourcepub fn verify_context_hash(&self, ctx: &FullContext) -> Result<(), AcdpError>
pub fn verify_context_hash(&self, ctx: &FullContext) -> Result<(), AcdpError>
Step 0 over a retrieved context — hashes FullContext::raw_body
when present (RFC-ACDP-0001 §5.7 “Hash verification over raw
JSON”), else the typed body.
Sourcepub async fn verify_context(&self, ctx: &FullContext) -> Result<(), AcdpError>
pub async fn verify_context(&self, ctx: &FullContext) -> Result<(), AcdpError>
Self::verify_body for a retrieved context: structural
validation, raw-JSON hash recomputation, then the signature
envelope.
Sourcepub async fn verify_body_signature(&self, body: &Body) -> Result<(), AcdpError>
pub async fn verify_body_signature(&self, body: &Body) -> Result<(), AcdpError>
Steps 1–7 only — resolve the producer’s DID, find the signing
key, verify the signature over the (already-stored)
body.content_hash. Assumes Self::verify_body_hash (or an
equivalent check) has already run.
Sourcepub async fn verify_body_signature_historical(
&self,
body: &Body,
) -> Result<(), AcdpError>
pub async fn verify_body_signature_historical( &self, body: &Body, ) -> Result<(), AcdpError>
verify_body_signature_historical with this verifier’s
freshness scope.