Construct the producer-supplied portion of the body — everything except the registry-assigned fields (ctx_id, lineage_id, origin_registry, created_at). For first versions, set version: 1 and supersedes: null.
Set acdp_version: "0.1.0" explicitly. RFC-ACDP-0001 §6 RECOMMENDS that producers — and SDK builders, by default — emit acdp_version in every body: it is producer-signed and part of content_hash, and it removes any ambiguity about which exclusion set and algorithm vocabulary a verifier should apply. An absent field is interpreted as "0.1.0", but absent and explicit "0.1.0" are distinct byte sequences and therefore distinct content_hash preimages — pick one and sign exactly what you emit.
(0.5.0) To genesis-link the body to a non-ACDP, content-addressed artifact, add the optional anchors array before hashing — it is producer-signed like any other field. Shape, limits, and the registry gate are in RFC-ACDP-0016 and registries/anchor-schemes.md; a body carrying it MUST declare acdp_version ≥ 0.5.0 and be published only to a registry that also advertises ≥ 0.5.0, or it is rejected with schema_violation (RFC-ACDP-0016 §10, §14).
Canonicalize the body using JCS (RFC 8785), compute SHA-256, and prepend the sha256: algorithm prefix.
import hashlib, jcs# Body must NOT yet contain content_hash, signature, or any registry-assigned fields.canonical = jcs.canonicalize(body)hash_hex = hashlib.sha256(canonical).hexdigest()content_hash = f"sha256:{hash_hex}"body["content_hash"] = content_hash
The exclusion set (RFC-ACDP-0001 §5.7) is content_hash, signature, ctx_id, lineage_id, origin_registry, created_at. At this stage, the body contains none of these (you haven't set content_hash or signature yet, and the registry-assigned fields don't exist on the producer side), so the exclusion is implicit.
Python implementer note.json.dumps(obj, sort_keys=True, separators=(',', ':'), ensure_ascii=False) is JCS-conformant for most input shapes but fails on negative zero (preserves -0.0 instead of emitting 0). Use the jcs package on PyPI to be safe. See RFC-ACDP-0001 §5.2.
Sign the bytes of the full content_hash string — that is, the ASCII bytes of sha256: followed by the 64 hex chars. Producers MUST NOT sign the raw 32-byte digest, and MUST NOT sign the hex-only substring without the sha256: prefix.
import base64# private_key is an ed25519 private key (cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PrivateKey)sig_bytes = private_key.sign(content_hash.encode("ascii"))body["signature"] = { "algorithm": "ed25519", "key_id": "did:web:agents.example.com:my-agent#key-1", "value": base64.b64encode(sig_bytes).decode("ascii")}
The key_id MUST be a DID URL whose DID portion equals body.agent_id — the registry will verify this binding (RFC-ACDP-0003 §2.1 step 6) and reject mismatches with key_not_authorized.
import httpxresp = httpx.post( "https://registry.example.com/contexts", json=body, headers={"Content-Type": "application/acdp+json"},)resp.raise_for_status()result = resp.json()# result has: ctx_id, lineage_id, version, created_at, status
Retries — use an Idempotency-Key. A publish that times out may or may not have persisted; a blind retry mints a second ctx_id for the same content. Send an Idempotency-Key header (a UUID you generate per logical publish): a retry with the same key and content returns the original response, and a retry with the same key but different content is rejected with duplicate_publish (RFC-ACDP-0003 §6). Registries advertising acdp_version ≥ 0.3.0 MUST support it (supports_idempotency_key: true in capabilities); against older registries, check the capabilities document first — an unsupported header is silently ignored.
import hashlib, jcs# Strip the full exclusion set per RFC-ACDP-0001 §5.7 — including content_hash itself.EXCLUDE = {"content_hash", "signature", "ctx_id", "lineage_id", "origin_registry", "created_at"}producer_content = {k: v for k, v in body.items() if k not in EXCLUDE}canonical = jcs.canonicalize(producer_content)recomputed_hex = hashlib.sha256(canonical).hexdigest()recomputed = f"sha256:{recomputed_hex}"assert recomputed == body["content_hash"], "content_hash mismatch — body has been tampered"
import base64# resolve_did_key returns the producer's Ed25519 public key for the DID URL in signature.key_id.producer_pubkey = resolve_did_key(body["signature"]["key_id"])# The signature was made over the bytes of the full content_hash string.sig_bytes = base64.b64decode(body["signature"]["value"])producer_pubkey.verify(sig_bytes, body["content_hash"].encode("ascii"))
If verify raises, the body is not authentically from agent_id.
Strict Ed25519 verification (0.5.0). The snippet above uses the cryptography package, whose default verify is OpenSSL-backed and does not apply the strict checks RFC-ACDP-0001 §5.10 requires: reject any signature whose s is not in 0 <= s < L, and any whose public key A or nonce point R is a small-order point (invalid_signature). Without the small-order check, an identity key with R = identity, s = 0 "verifies" for every message. Add the checks yourself (or use a library with a strict mode, e.g. ed25519-dalek's verify_strict):
L = 2**252 + 27742317777372353535851937790883648493SMALL_ORDER = {bytes.fromhex(h) for h in ( # the eight encodings pinned in sig-004 "0100000000000000000000000000000000000000000000000000000000000000", "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000080", "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05", "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85", "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a", "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa")}def strict_precheck(pubkey_raw: bytes, sig: bytes) -> bool: return (len(sig) == 64 and int.from_bytes(sig[32:], "little") < L # s < L and pubkey_raw not in SMALL_ORDER # A and sig[:32] not in SMALL_ORDER) # R
Run strict_precheck(producer_pubkey.public_bytes_raw(), sig_bytes) before verify and treat False as invalid_signature; the conformance vector is sig-004. The SDKs do this in their core (see the acdp-rs security notes). Non-canonical point encodings MAY additionally be rejected. ecdsa-p256 signatures are the opposite case: producers SHOULD emit low-S, but verifiers MUST accept high-S, and signature bytes are never an identity (registries/signature-algorithms.md).
SSRF — DID resolution.signature.key_id is producer-controlled, so resolve_did_key dereferences a did:web host taken verbatim from the body. The resolver MUST apply SSRF protection (RFC-ACDP-0008 §4.8): resolve the host, refuse if any resolved IP is in a private/loopback/link-local/IMDS range, pin the resolved IP for the connection, HTTPS-only, and cap redirects to the same authority. A URL-string check alone is not sufficient — DNS rebinding defeats it (RFC-ACDP-0006 §7.1). A producer DID that resolves to a forbidden target is treated as unverifiable.
Steps 1–3 are the StrictV010 verification profile (RFC-ACDP-0001 §9.2, §5.11): schema validation → content_hash recomputation → did:web resolution → signature verification → embedded.content_hash checks (a distinct, independent field from the DataRef-root content_hash of RFC-ACDP-0002 §6.1 — see §6.3), returning on the first failure. It is the only verification mode valid for an acdp-consumer conformance claim. SDKs MAY expose Diagnostic (records every stage) or UnsafeForTests (skips steps) modes, but neither may be the default and neither is conformant.
At this point the body is verifiably authentic. Inspect data_refs, fetch any location references, check data_period against the use case, check state["status"] and body.get("expires_at") for currency.
SSRF — DataRef fetches.data_refs[].location is producer-controlled. When a location is an https:// URL and you dereference it, you are making an outbound request to a host the producer chose — apply the SSRF protections of RFC-ACDP-0008 §4.9 (HTTPS-only, DNS-level IP-range filtering on every resolved address, IP pinning against rebinding, same-authority redirect cap capped at 3 follows). A refused fetch does not invalidate the body — the producer signature and content_hash stay valid; only the external reference is unreachable on the SSRF-safe path. Non-HTTP schemes (s3://, postgres://, …) are dereferenced by their own clients under your deployment's egress policy. Access to the referenced data is governed by that system's own ACLs, not by ACDP visibility (RFC-ACDP-0002 §6.4).
Registries advertising the 0.2.0+ trust profiles attach additional members to the retrieval envelope. Each is optional, each has its own verification procedure, and each verdict is reported separately from the body verdict — a failing receipt does not invalidate a body whose producer signature verifies, and vice versa. A consumer that ignores these members entirely (RFC-ACDP-0001 §6 unknown-field tolerance) remains conformant for the core flow.
Envelope member
What verifying it buys you
Procedure
Failure category
registry_receipt
The registry cryptographically attests ctx_id / lineage_id / origin_registry / created_at and which producer key verified at publish — no longer just registry honesty. Also unlocks historically authorized verification of rotated/revoked keys (RFC-ACDP-0010 §10, RFC-ACDP-0014).
RFC-ACDP-0010 §8
invalid_receipt
lineage_head_receipt (on /lineages/{id}/current)
"This was the head as of as_of" — protects against a registry serving a stale head. Freshness policy for as_of is yours.
RFC-ACDP-0011 §7
invalid_receipt
log_inclusion
The publish is committed to an append-only Merkle log: fold the inclusion proof to the checkpoint's root_hash, verify the checkpoint signature, and check consistency between checkpoints over time.
RFC-ACDP-0012 §9
invalid_log_proof
witness_signatures
Independent witnesses cosigned the checkpoint with their own keys — protection against a registry showing you a different history than everyone else. Quorum and freshness are local policy (RECOMMENDED defaults: 1 witness, 300 s).
RFC-ACDP-0015 §8
invalid_witness_cosignature
Golden vectors for every construction live in schemas/conformance/ (rcpt-001, lhr-001, log-001/log-003, wit-001/wit-003), and examples/retrieval/golden-context-with-receipt.json is a full receipt-bearing envelope that scripts/conformance-runner.py verifies end-to-end — build your verifier against those before pointing it at a live registry.
def walk_derived_from(body, depth=10): if depth == 0 or not body.get("derived_from"): return for ref_ctx_id in body["derived_from"]: # Parse acdp://<authority>/<uuid> authority = ref_ctx_id.split("//", 1)[1].split("/", 1)[0] # Fetch capabilities (ensure registry is reachable + advertises ACDP) caps = httpx.get(f"https://{authority}/.well-known/acdp.json").json() assert caps["acdp_version"], "not an ACDP registry" # Retrieve, verify, recurse encoded = ref_ctx_id.replace("/", "%2F") ref = httpx.get(f"https://{authority}/contexts/{encoded}").json() verify_body(ref["body"]) # Steps 2 & 3 above walk_derived_from(ref["body"], depth - 1)
The depth parameter is a defense against deep chains. Real derived_from chains are typically shallow (1–3 levels); set depth accordingly. A production walk also bounds total nodes, fanout, and wall-clock time per RFC-ACDP-0006 §4.1.
Cross-registry resolution is public-only in v0.1.0. The walk above sends no caller credentials to the remote registry — ACDP v0.1.0 defines no bearer-token forwarding or token exchange across registries (RFC-ACDP-0006 §4.4). A restricted/private predecessor on another registry therefore returns not_found (HTTP 404), indistinguishable from a genuinely missing one. Handle a 404 in the walk as "unresolvable predecessor, proceed without it" — not as proof the context never existed. If you actually need a non-public context held on another registry, authenticate to that registry directly, out of band, using a read-authentication method from its /.well-known/acdp.json. Producers should likewise assume any acdp:// reference to a non-public context is opaque to third-party consumers.
SSRF — cross-registry resolution. The authority in the loop above comes from a producer-signed acdp:// reference, so every httpx.get is an outbound request to a host an upstream producer chose. Cross-registry resolution MUST apply the SSRF protections of RFC-ACDP-0006 §7 — the same posture as DID resolution and DataRef fetches: HTTPS-only, DNS-level IP-range filtering on every resolved address, IP pinning, response-size caps (64 KB for capabilities/DID documents, 1 MB for context retrievals), bounded timeouts, and a same-authority redirect cap. The minimal example above omits these for brevity; a production resolver MUST NOT.
# What has been built on my context?my_ctx = "acdp://registry.example.com/my-published-analysis"last_seen = "2026-04-16T12:00:00.000Z"resp = httpx.get( "https://registry.example.com/contexts/search", params={"derived_from": my_ctx, "created_after": last_seen},)matches = resp.json()["matches"]# Each match has ctx_id, agent_id, title, summary, etc. — fetch each one for the full body.
Paginating correctly.next_cursor is the only signal for "there are more results" — loop until it is absent, not until you see an empty page. Because the registry applies visibility scoping and other per-requester filters after reading a storage page, a page MAY come back with an empty matches[] and a non-empty next_cursor (the storage page held only rows you can't see); the next page may still carry visible results. Stopping on the first empty matches[] would silently truncate the result set (RFC-ACDP-0005 §2.3).
def search_all(url, params): cursor = None while True: page = httpx.get(url, params={**params, **({"cursor": cursor} if cursor else {})}).json() yield from page["matches"] # may be empty for this page cursor = page.get("next_cursor") if cursor is None: # absent next_cursor — and only that — ends the loop break
Semantic similarity is reserved for a future ACDP version (RFC-ACDP-0009 §2.9); v0.1.0 implementations expose keyword search only.
visibility: private + audience trips up almost every first integration, because retrieval and search deliberately disagree (RFC-ACDP-0002 §7, RFC-ACDP-0005 §2.5.5): a DID listed in audiencecan retrieve the context by ctx_id, but can never discover it via search. audience on a private context means "you may read this if I send you the link" — not "you may find this".
Concrete two-agent scenario. did:web:agents.example.com:risk-bot publishes an internal risk assessment for exactly one downstream consumer, did:web:agents.example.com:audit-bot:
body = { # ... producer fields as in the Producer flow above ... "agent_id": "did:web:agents.example.com:risk-bot", "visibility": "private", "audience": ["did:web:agents.example.com:audit-bot"],}# sign, publish → registry returns ctx_id
What each side observes:
Operation by audit-bot (in audience)
Result
GET /contexts/{ctx_id} with the known ctx_id
200 — full body + registry state (RFC-ACDP-0002 §7)
GET /contexts/search?q=risk
No match, ever — private is producer-only in search, even for audience members (RFC-ACDP-0005 §2.5.5 Q1)
GET /contexts/search?derived_from=...
Same — the derived_from filter is search, and search is strictly narrower than retrieval (§2.5.5 Q2)
The ctx_id must therefore travel out-of-band. The producer has to hand it to the audience member through some channel of its own — an A2A/task-response message, a queue entry, an email, or an ACDP-native pattern: publish a second, less-sensitive pointer context (e.g. visibility: restricted to the same cohort, or public) whose data_refs or summary carries the private ctx_id, so the cohort can discover the pointer and retrieve the payload.
The failure mode to design against:audit-bot searches for the assessment, finds nothing, and concludes it does not exist — then re-derives the work or reports a gap. Nothing malfunctioned; private is behaving exactly as specified, and the registry will not even leak the context's existence via total_estimate. If your consumers locate inputs by searching, private + audience is the wrong tool — use visibility: restricted, which grants the audience both retrieval and search visibility. Reserve private + audience for link-style handoffs where the producer actively delivers the ctx_id.
Confirm you signed the bytes of the full sha256:<hex> string (not raw digest, not hex without prefix). Check key_id resolution and algorithm. (0.5.0) Ed25519 verification is strict: a non-canonical s or a small-order key or nonce point is rejected here even if a lax library would accept it.
hash_mismatch
Body content_hash ≠ recomputed
JCS implementation differs. Run schemas/conformance/can-001-jcs-vector.json. Common cause: stdlib json.dumps not normalizing -0.0; use the jcs PyPI package.
data_ref_hash_mismatch
embedded.content_hash (not the DataRef-root content_hash, RFC-ACDP-0002 §6.1) ≠ the decoded embedded.content
Recompute the data-ref digest per the encoding (RFC-ACDP-0002 §6.3): base64 → decoded bytes, utf8 → UTF-8 bytes, json → JCS canonical bytes. DataRef-level failure — distinct from hash_mismatch (body-level) and invalid_signature.
superseded_target
Supersession constraints failed
Check details.reason — common values: not_found, lineage_mismatch, version_mismatch, already_superseded.
unsupported_algorithm
signature.algorithm is not one this registry accepts
Ed25519 is always supported; ecdsa-p256 is optional. Use ed25519 or check the registry's supported_signature_algorithms.
embedded_too_large
Embedded data > 64 KB
Switch to location form.
unsupported_media_type(0.5.0)
Request Content-Type is outside the registry's accept-set on a body-bearing method
Send Content-Type: application/acdp+json. A charset parameter is ignored, so ; charset=utf-8 is fine. application/json is accepted only if that registry chooses to; do not rely on it. Your body was never parsed, so this says nothing about its contents — resend it unchanged under an accepted type. Only registries advertising acdp_version ≥ 0.5.0 emit this.
duplicate_publish
Retried an Idempotency-Key with different content
Same key = same logical publish. Generate a fresh key for new content; reuse the key only for byte-identical retries (RFC-ACDP-0003 §6.2).