trust_tasks_proof/lib.rs
1//! Pluggable [`ProofVerifier`](trust_tasks_rs::ProofVerifier)
2//! implementations for the Trust Tasks framework.
3//!
4//! The framework's [`ProofVerifier`](trust_tasks_rs::ProofVerifier) trait is
5//! the seam where cryptosuite implementations plug in; this crate is the
6//! umbrella that hosts those implementations behind Cargo features so a
7//! single dependency line opts in to a specific backend without dragging
8//! in the others.
9//!
10//! ## Backends
11//!
12//! | Cargo feature | Module | Backed by |
13//! |---------------|---------------------------|----------------------------------------|
14//! | `affinidi` ✱ | [`affinidi`] | `affinidi-data-integrity` (EdDSA suites) |
15//!
16//! ✱ = enabled by default. Disable default features and opt in to the
17//! backends you want via `default-features = false` + an explicit
18//! `features = [...]` list.
19//!
20//! ## Quickstart (`affinidi` backend)
21//!
22//! ```rust,ignore
23//! use trust_tasks_proof::affinidi::Verifier;
24//! use trust_tasks_rs::ProofVerifier;
25//!
26//! // did:key only — offline, no I/O. Good for tests and self-issued docs.
27//! let verifier = Verifier::for_did_key();
28//! verifier.verify(&inbound_doc).await?;
29//! ```
30//!
31//! Producers sign with the same backend's
32//! [`affinidi::sign_trust_task`] — defaults to `eddsa-jcs-2022` /
33//! `assertionMethod` and enforces the issuer↔verificationMethod binding
34//! at sign time, so its output verifies with the stock
35//! [`affinidi::Verifier`] by construction:
36//!
37//! ```rust,ignore
38//! use trust_tasks_proof::affinidi::{sign_trust_task, SignOptions};
39//!
40//! let signed = sign_trust_task(&doc_value, &secret, SignOptions::new()).await?;
41//! ```
42//!
43//! ## Signing a *typed* document
44//!
45//! [`sign_trust_task`](affinidi::sign_trust_task) works on
46//! [`serde_json::Value`], which is the right shape for the primitive and
47//! the wrong one for a producer holding a
48//! [`TrustTask<P>`](trust_tasks_rs::TrustTask). [`ProofExt`] is the typed
49//! wrapper: import it and both halves of the round-trip become methods on
50//! the document, with the same canonicalisation and the same defaults.
51//!
52//! ```rust,ignore
53//! use trust_tasks_proof::{affinidi::{SignOptions, Verifier}, ProofExt};
54//!
55//! doc.sign(&secret, SignOptions::new()).await?; // producer
56//! doc.verify(&Verifier::for_did_key()).await?; // consumer
57//! ```
58//!
59//! # Versioning
60//!
61//! This crate exposes `trust-tasks-rs` types in its own public API, so a
62//! breaking change there breaks this crate's callers even when nothing here
63//! changes. `cargo-semver-checks` cannot catch that: it compares each crate's
64//! rustdoc against that crate's own published baseline, and does not track
65//! type identity across dependency versions. The crates that share
66//! `trust-tasks-rs` in their public API are therefore released as one
67//! compatibility unit with a single shared version — see `version_group` in
68//! `release-plz.toml`.
69
70#![warn(missing_docs)]
71#![warn(rust_2018_idioms)]
72
73#[cfg(feature = "affinidi")]
74pub mod affinidi;
75
76mod proof_ext;
77
78pub use proof_ext::ProofExt;