acdp-rs
Rust library for the Agent Context Distribution Protocol (ACDP v0.1.0).
ACDP lets agents publish immutable, producer-signed context descriptors,
retrieve and verify them locally, discover them by keyword, and follow signed
acdp:// references across registries.
Spec: agentcontextdistributionprotocol/spec (RFC-ACDP-0001/0002/0003/0007).
Documentation
Guides that complement the rustdoc live in docs/:
- Getting Started — install, features, first publish/verify.
- Architecture — the hash/sign/state layering and module map.
- Producing contexts · Consuming & verifying · Errors & retries
- Security model — the SSRF/HTTPS/size defenses applied by default.
- Implementing a registry · CLI reference · Language bindings · Conformance & testing
These docs are additive to the specification and cite the relevant RFC sections rather than restating them.
Install
Conformance
This crate implements the acdp-consumer profile (RFC-ACDP-0001 §9.1):
- Verifies producer signatures end-to-end on every retrieved context.
- Resolves cross-registry
acdp://references with cycle detection, depth caps, SSRF defenses, and registry-DID web-binding verification. - Applies visibility rules client-side and tolerates unknown fields for forward compatibility.
The library also ships the building blocks (PublishValidator,
SsrfPolicy, validate_publish_request, compute_embedded_hash) that
registry implementers compose into acdp-registry-core /
acdp-registry-discovery / acdp-registry-federated services. See
acdp::profile for the typed profile vocabulary.
Glossary
- Body — the immutable JSON object representing a context.
- ProducerContent — the Body with the §5.7 exclusion set removed
(everything except the producer-controlled fields). The producer
signs ProducerContent; the SHA-256 of its JCS-canonicalized bytes
is the body's
content_hash. - RegistryState — the mutable, registry-derived state (
statusin v0.1.0) returned alongside the Body on retrieval. - Lineage — a chain of contexts representing successive versions of
the same logical work, identified by a stable
lineage_idderived from the v1 ctx_id. - JCS — JSON Canonicalization Scheme (RFC 8785). The deterministic
serialization used as the SHA-256 input for
content_hash. - DID — Decentralized Identifier (W3C). v0.1.0 producers MUST use
did:webso their keys can be resolved over HTTPS.
Features
| Feature | Default | Description |
|---|---|---|
client |
✓ | RegistryClient, VerifiedContext, WebResolver, CrossRegistryResolver |
server |
✗ | PublishValidator for registry implementations |
tracing |
✗ | #[instrument] spans on async ops; pulls in tracing (no subscriber) |
Security defaults
The library applies these defenses out of the box (RFC-ACDP-0006 §7, RFC-ACDP-0008):
- HTTPS-only for all outbound requests; HTTP is rejected.
- IP-literal rejection in
SsrfPolicy(forces DNS resolution). - Private-range blocking: RFC 1918, loopback, link-local,
multicast, IMDS (
169.254.169.254), IPv6 equivalents. - Response-size caps: 1 MB for context retrievals, 64 KB for capabilities and DID documents.
- Redirect cap: max 3 follows, same-authority only.
- Algorithm-downgrade rejection: signatures are checked against the algorithm declared by the resolved DID verification method.
- Ed25519 mandatory (RFC-ACDP-0001 §5.10).
DNS-rebinding protection (§7.6) is active: SafeDnsResolver is wired into
every HTTP client's dns_resolver hook, so resolved IPs are filtered through
the SsrfPolicy at DNS time, before any TCP connect. See
docs/security.md.
Quick start
Producer — build and sign a request
use ;
let seed = ;
let key = from_bytes;
let producer = new;
let req = producer
.publish_request
.title
.context_type
.visibility
.build
.expect;
// req.content_hash and req.signature are computed automatically
println!;
acdp_version field
The builder omits acdp_version by default. Conformant consumers treat an absent
field as "0.1.0" (RFC-ACDP-0001 §6), so this is safe. To emit it explicitly:
builder.acdp_version // adds "acdp_version": "0.1.0" to the body
Note: absent and explicit "0.1.0" are semantically identical but produce
different content_hash values (the JCS byte sequences differ). Pick one and
stay consistent within a lineage. The sig-001 golden vector was signed without
the field; using the omission default keeps round-trip tests byte-stable.
Consumer — retrieve and verify
#
# async
Server — verify and publish a context (RFC-ACDP-0003 §2.1)
#
# async
RegistryServer::publish_unverified_for_testsis provided for unit tests that cannot run a live DID resolver. It MUST NOT be used in production — it skips DID resolution and signature verification, which is a protocol violation (RFC-ACDP-0003 §2.1).
Cryptographic design
The library implements three protocol-critical operations exactly:
| Operation | Spec reference | Rust impl |
|---|---|---|
| JCS canonicalization | RFC 8785 | src/crypto/jcs.rs (inline, handles -0.0) |
content_hash |
RFC-ACDP-0001 §5.7 | src/crypto/hash.rs |
| Ed25519 sign/verify | RFC-ACDP-0001 §5.8/11 | src/crypto/{sign,verify}.rs |
The signature input is the ASCII bytes of the full "sha256:<hex>" string —
not the raw 32-byte digest. See src/crypto/sign.rs for details.
Examples
Testing
The suite includes:
- Spec golden vectors (
tests/golden_vector.rs—sig-001,can-001). - Property tests for JCS canonicalization (
proptest). - HTTP-mocked tests for
RegistryClientandWebResolver(wiremock). - Unit tests in every module.
Building docs
RUSTDOCFLAGS="--cfg docsrs -D warnings"
Dependencies
| Crate | Purpose |
|---|---|
ed25519-dalek |
Ed25519 signing and verification |
sha2 |
SHA-256 |
serde/serde_json |
JSON |
reqwest/rustls |
HTTPS (client feature, no OpenSSL) |
zeroize |
zeroes signing-key bytes on drop |
Contributing
See CONTRIBUTING.md for the dev workflow and quality bars. Security issues should follow SECURITY.md.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.