A Rust workspace for building secure, privacy-preserving applications using decentralised identity technologies. The TDK provides libraries and tools for DID resolution, DIDComm messaging, data integrity proofs, cryptographic primitives, and more.
Disclaimer: This project is provided "as is" without warranties or guarantees. By using this framework, users agree to assume all risks associated with its deployment and use, including implementing security and privacy measures in their applications. Affinidi assumes no liability for any issues arising from the use or modification of the project.
The workspace is organised into dependency layers under crates/: core →
identity → credentials / protocols / messaging → trust →
applications, with the tdk facade on top. The graph shows the main
dependency paths; the crate index lists every member.
graph TD
TDK["affinidi-tdk<br/><i>facade</i>"]
subgraph Messaging["crates/messaging"]
SERVICE["messaging-didcomm-service"]
SDK["messaging-sdk"]
DELIVERY["messaging-delivery"]
DIDCOMM["messaging-didcomm"]
TSP["affinidi-tsp"]
CORE["messaging-core"]
MTYPES["messaging-mediator-types"]
end
subgraph Identity["crates/identity"]
CACHESDK["did-resolver-cache-sdk"]
CACHESERVER["did-resolver-cache-server"]
METHODS["did-methods/*<br/><i>web, webs, scid, ebsi, ethr, jwk, pkh</i>"]
DIDCOMMON["did-common"]
AUTH["did-authentication"]
end
subgraph Credentials["crates/credentials + crates/protocols"]
VC["affinidi-vc / sd-jwt / mdoc / status-list"]
DI["data-integrity"]
OID4VC["oid4vc-core / openid4vci / openid4vp / siopv2"]
end
subgraph Core["crates/core"]
CRYPTO["affinidi-crypto"]
SECRETS["secrets-resolver"]
ENCODING["affinidi-encoding"]
end
TDKCOMMON["tdk-common"]
MP["meeting-place"]
TRUST["trust-lists"]
TDK --> SDK
TDK --> TSP
TDK --> MP
TDK --> CACHESDK
TDK --> VC
TDK --> DI
TDK --> OID4VC
TDK --> TRUST
TDK --> TDKCOMMON
SERVICE --> SDK
SERVICE --> TSP
SDK --> DIDCOMM
SDK --> TSP
SDK --> DELIVERY
SDK --> MTYPES
SDK --> CACHESDK
SDK --> AUTH
DELIVERY --> CORE
DIDCOMM --> CORE
TSP --> CORE
MP --> DIDCOMM
MP --> TDKCOMMON
CACHESERVER --> CACHESDK
CACHESDK --> METHODS
CACHESDK --> DIDCOMMON
AUTH --> SECRETS
TDKCOMMON --> AUTH
DI --> CRYPTO
SECRETS --> CRYPTO
SECRETS --> ENCODING
The mediator (affinidi-messaging-mediator, -mediator-common, the
affinidi-messaging-test-mediator fixture, and the -mediator-admin /
-mediator-tui console) lives in its own repository:
affinidi/affinidi-messaging-mediator.
Every workspace member, generated from cargo metadata. Crates marked not
published are workspace tools and never reach crates.io.
affinidi-tdk re-exports the TDK libraries
behind feature flags so you can depend on one crate and enable only what you
need.
| Crate | Description |
|---|---|
affinidi-tdk |
Facade re-exporting the TDK behind capability features |
affinidi-tdk-common |
Shared structs, TLS config, and cross-crate utilities |
affinidi-tdk-test-support |
In-process test fixtures: did:web mocks, deterministic resolvers, seeded DIDs, credential scenarios |
Foundational primitives with no domain dependencies.
| Crate | Description |
|---|---|
affinidi-bbs |
BBS Signatures (IETF draft) over BLS12-381 |
affinidi-cesr |
CESR (Composable Event Streaming Representation) codec |
affinidi-crypto |
Cryptographic primitives and JWK types — Ed25519, P-256, secp256k1 |
affinidi-encoding |
Multibase and multicodec encoding utilities |
affinidi-net-guard |
Egress guard for attacker-influenceable URLs: IP classification, URL vetting, a DNS-pinning resolver and a hardened HTTP client |
affinidi-rate-limit |
Request rate limiting for axum services: per-IP middleware and keyed limiters |
affinidi-secrets-resolver |
DID secret management and key resolution |
affinidi-task-utils |
Background-task supervision with restart-on-failure and an observable health registry |
DID Document types and high-performance resolution with local and network caching (250k+ resolutions/sec cached).
| Crate | Description |
|---|---|
affinidi-did-authentication |
Authentication via proof of DID ownership |
affinidi-did-common |
DID Document types, builders, and common utilities |
affinidi-did-resolver-cache-sdk |
SDK for local and network DID resolution with caching |
affinidi-did-resolver-cache-server |
Standalone network DID resolution server |
affinidi-did-resolver-traits |
Pluggable resolver traits for custom DID methods |
did-ebsi |
did:ebsi method for legal entities |
affinidi-did-ethr |
did:ethr DID method resolver |
did-example |
did:example method for testing |
affinidi-did-jwk |
did:jwk DID method resolver |
affinidi-did-pkh |
did:pkh DID method resolver |
did-scid |
did:scid Self-Certifying Identifier method |
affinidi-did-web |
did:web DID method resolver |
affinidi-did-webs |
did:webs — did:web discovery with KERI-verified key state |
agent-names |
Agent Name (DID shortcut) parsing, resolution and verification |
W3C Verifiable Credentials and selective-disclosure formats.
| Crate | Description |
|---|---|
affinidi-data-integrity |
W3C Data Integrity proofs (eddsa-jcs-2022, eddsa-rdfc-2022) |
affinidi-mdoc |
ISO/IEC 18013-5 mdoc (mobile driving licences, eIDAS attestations) |
affinidi-rdf-encoding |
RDFC-1.0 canonicalization and JSON-LD expansion |
affinidi-sd-jwt |
SD-JWT (Selective Disclosure JWT) per RFC 9901 |
affinidi-status-list |
Credential status and revocation lists (Bitstring Status List, IETF Token Status List, eIDAS ASL/ARL) |
affinidi-vc |
W3C Verifiable Credentials Data Model 1.1 and 2.0 |
OpenID for Verifiable Credentials (OID4VC) protocol family.
| Crate | Description |
|---|---|
affinidi-oid4vc-core |
Shared types for the OID4VC protocol family |
affinidi-openid4vci |
OpenID for Verifiable Credential Issuance (OpenID4VCI) — draft-13 message types |
affinidi-openid4vp |
OpenID for Verifiable Presentations (OpenID4VP) |
affinidi-siopv2 |
Self-Issued OpenID Provider v2 (SIOPv2) |
Secure, private messaging built on DIDComm v2 and TSP.
| Crate | Description |
|---|---|
affinidi-messaging-core |
Protocol-agnostic messaging traits |
affinidi-messaging-delivery |
Reliable delivery layer: durable outbox and drain over the MessageTransport trait |
affinidi-messaging-didcomm |
DIDComm v2.1 protocol implementation |
affinidi-messaging-didcomm-service |
Always-online service framework: mediator connection, message lifecycle and handler dispatch for DIDComm, with TSP multiplexed behind the tsp feature (AffinidiMessageService) |
affinidi-messaging-didcomm-v1 |
DIDComm v1 (Aries RFC 0019) messaging implementation |
affinidi-messaging-helpers |
Example runners and mediator-administration CLI tools (environment files are hand-written; see its README) — not published |
affinidi-messaging-mediator-types |
Protocol types shared by the mediator and its clients |
affinidi-messaging-sdk |
SDK for integrating Affinidi Messaging into your application |
affinidi-messaging-text-client |
Terminal-based DIDComm chat client — not published |
affinidi-tsp |
Trust Spanning Protocol (TSP) implementation (HPKE-Base, CESR) |
| Crate | Description |
|---|---|
affinidi-trust-lists |
EU Trusted Lists (ETSI TS 119 612) for eIDAS 2.0 trust infrastructure |
| Crate | Description |
|---|---|
affinidi-meeting-place |
Discover and connect with others using DIDs and DIDComm, securely and privately |
- Rust 1.95.0+ (2024 Edition). The workspace MSRV is
rust-versioninCargo.toml;scripts/check-toolchain-sync.shkeeps this line and the badges in step with it.
Add the unified TDK crate to your project (cargo picks the latest release):
cargo add affinidi-tdkOr depend on individual crates for finer control:
cargo add affinidi-did-resolver-cache-sdk affinidi-messaging-sdk affinidi-data-integrityAll crates are 0.x: a minor bump is a breaking release, so keep every
affinidi-* dependency on the versions cargo add resolves together rather than
mixing in older pins.
crates/tdk/affinidi-tdk/examples/resolve_did.rs
(built in CI, so it tracks the current API):
use affinidi_tdk::did_resolver::{DIDCacheClient, config::DIDCacheConfigBuilder};
// Local-mode resolver: did:key / did:peer resolve with no network.
let resolver = DIDCacheClient::new(DIDCacheConfigBuilder::default().build()).await?;
let response = resolver.resolve("did:key:z6MkiToqovww7vYtxm1xNM15u9JzqzUFZ1k7s7MazYJUyAxv").await?;
println!("{}", serde_json::to_string_pretty(&response.doc)?);cargo run -p affinidi-tdk --example resolve_did -- \
did:key:z6MkiToqovww7vYtxm1xNM15u9JzqzUFZ1k7s7MazYJUyAxvcrates/tdk/affinidi-tdk/examples/did_auth.rs— DID authentication against a service through the facade.- The messaging SDK README
covers creating an
ATM, adding a profile and connecting to a mediator; the runnable messaging helpers examples (trust_ping,mediator_ping,alice_bob,oob_invite) send real messages through a mediator.
You can write messaging / DID / credential integration tests with no external infrastructure — no Redis, no network, no standing services. Two paths:
- Rust fixtures — pull a fixture crate in as a
dev-dependency:affinidi-messaging-test-mediator(in the mediator's repository) for embedded mediators (TestMediator/TestEnvironment/TestTopology), andaffinidi-tdk-test-supportfor did:web mocks, deterministic resolvers, seeded DIDs, and credential scenarios. A mediator is three lines; an issue/present/verify round trip is a handful. - Language-agnostic — the mediator repository's composed test stack
(
docker-compose.test.yml) brings up a known-good mediator + Redis + did:web host with fixed TEST-ONLY identities for any client to point at.
Copy-paste scenarios are in the testing cookbook.
This workspace's root Cargo.toml defines a non-trivial
[patch.crates-io] table that redirects every workspace crate to its local
source. Cargo's patch tables are only honoured by the workspace that defines
them — when an external repository depends on any affinidi-* crate via a git
rev or local path, that consumer must replicate the same patch table, or
different parts of the dependency closure will end up resolving the affinidi-*
crates from a mix of crates.io and the git/path source. Type-graph divergence
shows up as confusing trait mismatches at compile time (expected MediatorACLSet, found MediatorACLSet).
This is a known cargo limitation — see rust-lang/cargo#4452.
The simplest approach is to depend on published versions only, added together so they come from the same release wave:
cargo add affinidi-tdk affinidi-messaging-sdk
cargo add --dev affinidi-messaging-test-mediatorNo patch table is needed — cargo resolves a single version of each affinidi-*
crate from crates.io and the type graph is unified by construction. If cargo
reports two versions of the same affinidi-* crate (cargo tree -d), one of
your pins is a stale 0.x minor: raise it rather than adding a patch.
If you need a change that hasn't reached crates.io yet, pin the affinidi-* crates you use to one git rev, and mirror the workspace's patch table so transitive dependencies go through the same rev. Generate the block for a given commit — it reads the live table, so it never drifts:
./tools/generate-consumer-patch.sh <git-rev>Paste the output into your own Cargo.toml. The rev must match — and stay
matched — to the version constraints in your own [dependencies]; when you
bump an affinidi-* dependency, regenerate the block for the new rev.
If you face any issues or have suggestions, please don't hesitate to contact us using this link.
If you have a technical issue, you can open an issue directly in GitHub. Please include a title and clear description, as much relevant information as possible, and a code sample or executable test case demonstrating the expected behaviour.
Want to contribute? Head over to our CONTRIBUTING guidelines.
This project is licensed under the Apache-2.0 license.