aitp-rs

Rust reference implementation of the Agent Identity & Trust Protocol

CI crates.io docs.rs License

Rust reference implementation of the Agent Identity & Trust Protocol (AITP).

Status: tracks the AITP v0.3 wire protocol (aitp/0.3) at the spec commit pinned in tests/schemas/SPEC_VERSION. The current crate version is in Cargo.toml and the release notes; history is in crates/aitp/CHANGELOG.md. Conformance results at the pin, and what they do and do not prove, are in docs/conformance.md.

Hello world

Install the CLI, enroll a key with the public interop peer and complete a real handshake with it. aitp echo hands back the TCT the peer issued, with proof of possession:

cargo install aitp-cli
aitp enroll https://interop.agentidentitytrustprotocol.io
aitp echo https://interop.agentidentitytrustprotocol.io

readme-smoke runs this block daily, as written, against the public peer. On every pull request it runs the same block against a peer built from the checkout. cli.md covers the other commands.

What is AITP?

AITP (Agent Identity & Trust Protocol) lets two agents establish mutual trust without a shared verifier. The protocol is defined normatively by the RFCs in the spec repository; for how this implementation maps onto it, read docs/architecture.md. The ecosystem map lists the sibling repositories (independent verifier, control plane, playground, website) and what each one owns.

Workspace layout

aitp-rs/
├── crates/
│   ├── aitp/                the library: one module per protocol layer
│   │   └── src/
│   │       ├── core/        types, JCS, base64url, AID — pure, no I/O
│   │       ├── crypto/      Ed25519 + P-256 keys, compact JWS, JWK thumbprint
│   │       ├── envelope/    envelope signing and verification — sync, no I/O
│   │       ├── manifest/    Manifest issuance and verification
│   │       ├── handshake/   Mutual handshake state machine
│   │       ├── tct/         TCT issuance and verification, PoP exchange
│   │       ├── delegation/  Delegation tokens (single-hop; multi-hop opt-in)
│   │       ├── transport/   HTTP client/server (feature-gated, async)
│   │       └── facade.rs    async handshake helpers
│   ├── aitp-experimental/   Session Trust Bundle, multi-hop delegation, TCT renewal, A2A Agent Card binding; no stability promise
│   ├── aitp-cli/            `aitp` command-line tool (keygen, verify, handshake)
│   └── aitp-conformance/    conformance runner + the canonical Rust adapter (`aitp-rs-adapter` binary)
├── bindings/                language SDKs — excluded from the Cargo workspace
│   ├── aitp-py/             Python SDK (PyO3)
│   ├── aitp-node/           Node.js SDK (NAPI-rs)
│   └── interop/             cross-language interop tests — `make interop`
├── examples/                runnable demos — see examples/README.md
│   ├── two-agents/          handshake demo + OIDC / revocation / renewal / delegation bins
│   └── observability/       tracing / metrics integration example
├── tools/                   fixture- and example-minting binaries
├── adapters/                example conformance adapters in other languages
├── docs/                    implementation guides + design/ decision notes
└── scripts/                 build and release helpers

Status by module

Crate / moduleStatusNotes
aitp::core✅ completeAID, JCS, base64url, timestamps, envelope, error codes.
aitp::crypto✅ completeEd25519 (verify_strict) + P-256/ES256 (canonical low-S, high-S rejected), compact-JWS profile (jws.rs), JWK thumbprint. No RSA code: the RSA-2048 floor lives in aitp::handshake (OIDC JWK, jwk.rs) and aitp::transport (JWKS fetch, common.rs).
aitp::envelope✅ completesign_envelope / verify_envelope_signature — sync, no I/O; wrapped by aitp::transport.
aitp::manifest✅ completeBuilder + verifier + HTTP wrapper.
aitp::tct✅ completeBuilder + verifier + downstream PoP; strict TctVerifyContext::builder() forces explicit revocation / manifest-expiry-cap decisions (*_dangerous waivers).
aitp::delegation✅ completeBuilder + verifier, single-hop (RFC-0006); a chain-bearing token is rejected with DELEGATION_MULTIHOP_NOT_SUPPORTED. Multi-hop chains (RFC-0011) are in aitp_experimental::delegation.
aitp::handshake✅ completeInitiator + Responder + OIDC + pinned-key (with trust store + grant policy); RSA-2048 floor on OIDC RSA keys.
aitp::transport✅ completeManifest fetcher (cache-correct, oversize-capped), JWKS resolver (RFC-0007 §2.3 branch), handshake server (AITP error envelopes), revocation endpoint. SSRF HostGuard on peer fetches, pluggable ReplayGuard, optional metrics feature.
aitp::facade✅ completeAsync run_initiator_handshake + TctStore; InitiatorConfig with with_http_timeout / with_host_guard.
aitp-experimental✅ opt-inSession Trust Bundle (RFC-0010) at aitp_experimental::session_bundle: builder + verifier, plus SessionBundleServer behind its http-server feature. No stability promise.
aitp-cli✅ completeaitp binary (cargo install aitp-cli): offline keygen, aid, tct inspect/verify, manifest verify, plus manifest fetch and handshake <url> against a live peer. Stdin-friendly, non-zero exit with the AITP error code on failure. See docs/cli.md.
aitp-conformance✅ Tier A–DSubprocess adapter, fixture loader, runner, and the aitp-rs-adapter binary (aitp_conformance::rs_adapter): all conformance ops, including verify_handshake_payload (id-* / mh-*), verify_session_bundle / issue_session_bundle, and the tct-007 PoP-enforcement ops (authorize_capability_invocation, expect_pop_challenge_issued, withhold_pop_response). Results: docs/conformance.md.

Language SDKs (bindings/)

SDKPathBuilt withTests
aitp-pybindings/aitp-pyPyO3 / maturinpytest (in-process handshake)
aitp-nodebindings/aitp-nodeNAPI-rsnode --test (in-process handshake)

Thin SDKs over the aitp crate: an AitpAgent plus initiator/responder session types whose methods exchange JSON strings (HTTP request/response bodies), so agent code never touches a Rust type. They are excluded from the Cargo workspace — cargo test --workspace does not build them. bindings/interop/ cross-checks the two SDKs against each other; see Cross-language interop below.

RFC compliance matrix

The Status column is the state of this implementation. The RFCs' own status is in the RFC index: RFC-0001 to RFC-0011 are Community Standards Track (Draft), with 0010 and 0011 opt-in; RFC-0012 is Reserved and RFC-0013 and RFC-0014 are Draft, opt-in.

RFCTitleStatusNotes
0001Core wire format✅ implementedJCS canonicalization, envelope, error codes, replay deny list.
0002Identity binding✅ implementedPinned-key v1 (5-field domain-prefixed proof) + OIDC with cnf.jkt. Trust store enforced. SPIFFE (§6, JWT-SVID and X509-SVID) is experimental: aitp_experimental::spiffe::SpiffeVerifier (feature spiffe-identity), attached through the aitp::handshake::IdentityVerifier hook.
0003Manifest✅ implementedBuilder + verifier + HTTP server + cache-correct fetcher.
0004Mutual handshake✅ implementedFour-message exchange + identity-aware grant policy + Manifest-bound TCT expiry + replay protection.
0005TCT✅ implementedIssuance, verification, downstream PoP, renewal flow.
0006Single-hop delegation✅ implementedverify_delegation runs §4 steps 1–8; the step-9 downstream PoP exchange is run by the caller (aitp::tct::sign_pop_response / verify_pop_response). Tokens carrying a chain claim are rejected unless the caller opts into RFC-0011 (row below).
0007Key resolution✅ implementedKeyResolutionPolicy: cache, then the pinned issuer store, then the network. The network step is the §2.3 branch: OIDC discovery first; /.well-known/aitp-keys only when discovery is not validly exposed (JwksFetcher::resolve in client.rs). Three fail modes.
0008Revocation✅ implementedSnapshot signing/verification + per-issuer cache + HTTP endpoint + Manifest extension.
0009Security considerations✅ honoredReplay window, timestamp tolerance, HTTPS-only fetches, fail-closed defaults; SSRF HostGuard (redirect-block + address classification + DNS-rebind-safe pinning), canonical low-S P-256, RSA-2048 floor. See docs/transport-hardening.md.
0010Session Trust Bundle✅ Draft, opt-inBuilder + verifier in the aitp-experimental crate (aitp_experimental::session_bundle); conformance fixtures bundle-* exercise issuance + verify when the feature is enabled, SKIP otherwise.
0011Multi-hop delegation✅ Draft, opt-inIn the aitp-experimental crate (aitp_experimental::delegation): ChainedDelegationBuilder and verify_chained_delegation, with a hop budget of DEFAULT_MAX_DELEGATION_HOPS = 3. The stable aitp::delegation::verify_delegation rejects chains with DELEGATION_MULTIHOP_NOT_SUPPORTED; the conformance runner's --feature experimental-multihop-delegation flag exercises the del-mh-* fixtures.
0012Extensions◐ container onlyThe §1 container is carried: ExtensionsMap on JCS payloads, the ext claim on JWS artifacts, unknown keys ignored; revocation URL extension wired. No ZK/TEE extension family is implemented.
0013TCT renewal✅ Draft, opt-inIn aitp_experimental::renewal: the holder's PoP request, the issuer's §4 checks and signed tct / error response envelope, the holder's §6.1 response check, the renew_tct client (feature http-client) and RenewalServer at the advertised rfc-aitp-0005.renew_uri (feature http-server); the conformance runner's --feature experimental-renewal flag exercises the ren-* fixtures. See docs/tct-renewal.md.
0014A2A Agent Card binding✅ Draft, opt-inIn aitp_experimental::a2a (feature a2a-agent-card): client-side §4.2 steps 2 to 5 and §4.3. Server-side §5.2 and A2A request headers are not implemented. a2a-001 to a2a-006 pass under --feature aitp-a2a-agent-card. See docs/a2a-agent-card.md.

Known limitations (v0.3)

  • Single-hop delegation only in aitp. aitp::delegation::verify_delegation rejects multi-hop chains (RFC-0011); they verify with aitp_experimental::delegation::verify_chained_delegation. See docs/multihop-delegation.md and, for why the default must stay strict, docs/architecture.md.
  • Session Trust Bundle, renewal and the A2A binding are opt-in. N-party trust artifacts (RFC-0010, Draft, opt-in) live in the separate aitp-experimental crate, as do TCT renewal (RFC-0013, Draft) and the A2A Agent Card binding (RFC-0014, Draft). The published language SDKs include none of them; a source build adds them with the bindings' experimental feature.
  • Revocation is fail_closed (RFC-AITP-0008 §3.1). A verifier with no revocation status for a TCT treats it as revoked (TCT_REVOKED). The HandshakeServer and run_initiator_handshake fetch the peer's advertised ListRevoked snapshot, so a peer whose Manifest carries no reachable rfc-aitp-0008.revocation_list_uri is refused unless the verifier sets RevocationFailMode::FailOpen. TctVerifyContext::builder() will not build until a revocation source is named with .revocation(..): RevocationSource::Check with a lookup, or RevocationSource::FailOpen to skip it. Under soft_fail the verified TCT, delegation and handshake carry effective_grants, the grants narrowed to the safe subset. The SDKs take a caller-supplied revoked-jti list ([] means nothing is revoked), and omitting it fails closed unless revocation="fail_open".
  • JWKS resolution does no I/O in the handshake step. The synchronous JwksResolver::resolve answers from the cache and the pinned-issuer store only. KeyResolutionPolicy fetches over the network in the async JwksResolver::prefetch, which HandshakeServer and run_initiator_handshake await for the peer's OIDC issuer before each synchronous step. A caller driving the state machine itself awaits prefetch first; without it an unpinned issuer fails with the retryable KEY_RESOLUTION_FAILED.

Conformance matrix

aitp-conformance runs the spec's fixture suite against the aitp-rs-adapter binary. The results at the pinned spec commit, the strict and opt-in run modes, and the commands to reproduce them are in docs/conformance.md. That page is the only place these docs give fixture counts.

The runner's exit-code gate keys on required_for_core by default: a required core fixture that fails, or is skipped because the adapter lacks its op, fails the run. --profile v0.1 gates on required_for_v0_1 instead. Details are under core conformance gate.

Install

cargo add aitp                                   # Rust library (crates.io)
npm install @agentidentitytrustprotocol/aitp     # Node SDK (npm)
pip install aitp-sdk                              # Python SDK (PyPI)

The aitp crate is the whole protocol library, one module per layer. The HTTP client ships by default; add the server when you need it (cargo add aitp --features http-server, or --features all). aitp carries a semver promise (experimental-* features excepted); Session Trust Bundles live in aitp-experimental, which does not (see STABILITY.md). The aitp CLI installs with cargo install aitp-cli (prebuilt binaries are on each aitp-cli-v* GitHub Release). aitp handshake <url> runs a full handshake against a peer and prints the TCT it issues you; see docs/cli.md.

Quick start

Run the two-agent demo (no external dependencies):

make demo

You should see the four-message handshake complete and an /echo capability invocation succeed. See examples/two-agents/README.md for the walkthrough.

Cross-language interop

make interop

Builds the Python and Node SDKs, then runs a real four-message AITP handshake between the two runtimes — in both directions — proving the two implementations emit wire-compatible envelopes. The Python side runs in-process under pytest; the Node side runs as a subprocess worker. See bindings/interop/README.md for the design.

Building

cargo build --workspace --all-targets --all-features
cargo test --workspace --all-features
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo doc --workspace --no-deps --all-features

make test and scripts/test.sh run fmt, clippy and the workspace tests. make ci is the full local gauntlet: version-lockstep check (check-versions), test, doc, cargo deny and cargo audit. In the ci.yml workflow only the test job runs on Linux, macOS and Windows (plus an MSRV leg on Linux); cargo deny, cargo audit and the other jobs run on Linux only. See docs/testing.md.

Documentation

docs/README.md is the index and the entry point. Highlights:

The protocol itself is defined normatively by the AITP RFCs; docs here point to the relevant RFC section rather than restating it.

Roadmap

The v0.1 bootstrap, the v0.2 compact-JWS migration (portable trust artifacts re-serialized as compact JWS) and the security-hardening work are complete. See crates/aitp/CHANGELOG.md for the history and docs/transport-hardening.md for the transport-layer status register.

The runtime covers the common case: two agents, pinned-key or OIDC identity, single-hop delegation, the aitp/0.3 wire. The crates are pre-1.0, so a breaking API change bumps the minor version. The remaining work is the opt-in extensions (Session Trust Bundle, multi-hop delegation, TCT renewal, A2A Agent Card binding), which follow their RFCs through the spec lifecycle.

License

Dual-licensed under either of:

  • Apache License, Version 2.0
  • MIT License

at your option. See LICENSE-APACHE and LICENSE-MIT.