Skip to main content

Crate turul_ai_catalog_trust

Crate turul_ai_catalog_trust 

Source
Expand description

§turul-ai-catalog-trust

Trust for AI Catalog documents: sign a catalog or a trust manifest, accept a signature against the signer’s did:web DID document, check artifact digests, and build a per-signature trust report for a resolved catalog tree. Built on turul-ai-catalog and turul-ai-catalog-client.

Part of turul-agent-card.

The crate implements the did-web-v1 signature profile: ES256 detached JWS over the RFC 8785 canonical form of the signed object, with the signer’s key taken from its root did:web DID document. Every outcome is reported per signature; there is no catalog-wide verdict.

§Quick start

cargo add turul-ai-catalog-trust

Sign a catalog, then accept the signature against the signer’s DID document. The DID document is built in memory here; resolve fetches the real one over HTTPS.

use std::time::{Duration, UNIX_EPOCH};

use turul_ai_catalog::identity::{ArtifactType, EntryIdentifier};
use turul_ai_catalog::model::{AiCatalog, ArtifactSource, CatalogEntry};
use turul_ai_catalog_client::Fetched;
use turul_ai_catalog_trust::{
    DidWebRoot, SignedObject, SignerParams, SigningKey, TrustPolicy, accept_document, sign_catalog,
    verify_signature,
};

let signer = DidWebRoot::parse("did:web:example.com").ok_or("not a root did:web DID")?;

let catalog = AiCatalog::new(vec![CatalogEntry::new(
    EntryIdentifier::new("urn:air:example.com:a2a:research"),
    ArtifactType::A2A_AGENT_CARD,
    ArtifactSource::Url("https://agents.example.com/.well-known/agent-card.json".into()),
)]);
let params = SignerParams {
    signer: signer.clone(),
    key_fragment: "key-1".into(),
    issued_at: "2026-09-12T10:00:00Z".into(),
    expires_at: None,
};
let signed = sign_catalog(catalog, &params, &SigningKey::from_pkcs8_der(&KEY_DER))?;

// The DID document the signer would publish at https://example.com/.well-known/did.json.
let did_json = format!(
    r#"{{"id":"did:web:example.com","verificationMethod":[{{"id":"did:web:example.com#key-1",
    "type":"JsonWebKey2020","controller":"did:web:example.com","publicKeyJwk":{PUBLIC_JWK}}}],
    "assertionMethod":["did:web:example.com#key-1"]}}"#
);
let fetched = Fetched::new(200, Some("application/did+json".into()), did_json.into_bytes());
let doc = accept_document(&fetched, &signer)?;

let now = UNIX_EPOCH + Duration::from_secs(1_789_207_200);
let accepted = verify_signature(SignedObject::Catalog(&signed), &doc, &TrustPolicy::default(), now)?;
assert_eq!(accepted.kid.as_str(), "did:web:example.com#key-1");

For a whole resolved tree, verify fetches each signer’s DID document once and returns a TrustReport with one signature outcome per catalog and per trust manifest, grouped by entry.

§Modules

ModulePurpose
payloadThe canonical bytes a detached JWS covers.
signES256 signing of a manifest or a catalog.
headerThe JWS protected-header policy and kid check.
did_webDID document retrieval, acceptance and verification-key selection.
acceptAcceptance of one signature under a TrustPolicy.
digestArtifact digests and integrity checks.
reportEntry coverage, publisher authority, endorsement, the trust report and verify_entry.
endorseendorse_entry and endorse_catalog: digest and publisher manifest per entry.
parameter_storeFeature ssm: the signing key held in an SSM Parameter Store SecureString.
registrationFeature registration: the publisher verifier for runtime registration.
identitydid:web root and urn:air identifier shapes.

§Feature flags

  • registration (off by default): DidWebPublisherVerifier, the PublisherVerifier of turul-ai-catalog-storage. It accepts an entry only when its urn:air publisher signed a trust manifest that covers it. Adds turul-ai-catalog-storage (without default features, so without a backend), async-trait and tokio (rt).
  • ssm (off by default): ParameterKeyStore, which creates the signing key as a SecureString (never overwriting one) and loads it in process. Adds aws-sdk-ssm.

§Licence

Apache-2.0.

Re-exports§

pub use accept::AcceptedSignature;
pub use accept::Reason;
pub use accept::TrustPolicy;
pub use accept::verify_signature;
pub use did_web::DidDocument;
pub use did_web::KeySelectionError;
pub use did_web::PublicJwk;
pub use did_web::ResolveError;
pub use did_web::accept_document;
pub use did_web::did_document;
pub use did_web::document_url;
pub use did_web::resolve;
pub use did_web::select_key;
pub use digest::IntegrityError;
pub use digest::Unsupported;
pub use digest::artifact_digest;
pub use digest::check_artifact;
pub use digest::compute;
pub use digest::fetch_artifact;
pub use digest::verify_artifact;
pub use endorse::EndorseError;
pub use endorse::EndorseErrorKind;
pub use endorse::endorse_catalog;
pub use endorse::endorse_entry;
pub use header::DID_WEB_V1_FORBIDDEN_HEADERS;
pub use header::ES256;
pub use header::HeaderError;
pub use header::Kid;
pub use header::TYP_CATALOG;
pub use header::TYP_TRUST_MANIFEST;
pub use header::inspect;
pub use header::kid_matches_signer;
pub use header::policy;
pub use identity::DidWebRoot;
pub use object::SignedObject;
pub use parameter_store::KeyStoreError;
pub use parameter_store::ParameterKeyStore;
pub use payload::PayloadError;
pub use payload::catalog_payload;
pub use payload::manifest_payload;
pub use registration::DidWebPublisherVerifier;
pub use registration::publisher_verdict;
pub use report::CatalogReport;
pub use report::Coverage;
pub use report::CoverageGap;
pub use report::DidDocuments;
pub use report::Endorsement;
pub use report::EntryReport;
pub use report::ManifestReport;
pub use report::Selection;
pub use report::SignatureOutcome;
pub use report::TrustReport;
pub use report::catalog_endorsed;
pub use report::entry_release_coverage;
pub use report::publisher_authorized;
pub use report::select_current;
pub use report::verify;
pub use report::verify_entry;
pub use report::verify_entry_resolved;
pub use report::verify_resolved;
pub use sign::SignError;
pub use sign::SignerParams;
pub use sign::SigningKey;
pub use sign::sign_catalog;
pub use sign::sign_manifest;

Modules§

accept
Acceptance of one signature (#verification-procedures, #profile-selection, #signature-acceptance-and-time): every refusal is a per-signature Reason, never a catalog-wide verdict.
did_web
did:web resolution, the DID document the profile reads, and verification-key selection (#did-document-resolution-and-key-selection, #current-state-verification).
digest
Artifact digests and integrity (#digest-format, #verifying-artifact-integrity).
endorse
Endorsing the entries of a catalog: the artifact digest and the signer’s own trust manifest (#entry-release-coverage, #level-3-trusted-catalog).
header
The JWS protected header of a did-web-v1 signature (#signed-payload-and-jws-construction, #jws-algorithm-and-key-requirements). Parsing and every header rule but kid belong to the JWS validator; this module builds its policy and checks kid.
identity
Signer identity: a root did:web DID.
object
The two kinds of object that carry a signature.
parameter_store
The signing key held in AWS Systems Manager Parameter Store as a SecureString.
payload
The bytes a detached JWS covers (#signed-payload-and-jws-construction, #catalog-snapshot-coverage).
registration
The publisher verifier for runtime registration: a stored entry is accepted when its urn:air publisher signed a trust manifest that covers it (#the-did-web-publisher-profile).
report
Coverage, authority, endorsement, selection among updates and the per-entry trust report (#entry-release-coverage, #the-did-web-publisher-profile, #catalog-authorization, #independent-contributions-and-updates, #verification-result). The report holds one outcome per signature and no catalog-wide verdict.
sign
ES256 signing of a manifest or a catalog (#signed-payload-and-jws-construction).