Skip to main content

open_agent_id/
lib.rs

1//! # Open Agent ID — Rust SDK
2//!
3//! Sign, verify, and manage AI agent identities using the
4//! [Open Agent ID](https://openagentid.org) protocol (V2).
5//!
6//! ## DID Format
7//!
8//! ```text
9//! did:oaid:{chain}:{agent_address}
10//! ```
11//!
12//! - `chain`: lowercase chain identifier (e.g. `"base"`)
13//! - `agent_address`: `0x` + 40 lowercase hex chars (CREATE2-derived contract address)
14//!
15//! ## Quick Start
16//!
17//! ```rust
18//! use open_agent_id::{crypto, did::Did, signing};
19//!
20//! // Generate a keypair
21//! let (signing_key, verifying_key) = crypto::generate_keypair();
22//!
23//! // Parse a DID
24//! let did = Did::parse("did:oaid:base:0x7f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e").unwrap();
25//!
26//! // Sign an HTTP request
27//! let output = signing::sign_http(
28//!     &signing::HttpSignInput {
29//!         method: "POST",
30//!         url: "https://api.example.com/v1/agents",
31//!         body: b"{}",
32//!         timestamp: None,
33//!         nonce: None,
34//!     },
35//!     &signing_key,
36//! ).unwrap();
37//!
38//! // Verify
39//! let valid = signing::verify_http(
40//!     "POST",
41//!     "https://api.example.com/v1/agents",
42//!     b"{}",
43//!     output.timestamp,
44//!     &output.nonce,
45//!     &output.signature,
46//!     &verifying_key,
47//! ).unwrap();
48//! assert!(valid);
49//! ```
50
51pub mod crypto;
52pub mod did;
53pub mod error;
54pub mod signing;
55pub mod types;
56
57#[cfg(feature = "client")]
58pub mod client;
59
60#[cfg(feature = "signer")]
61pub mod signer;
62
63// Re-export primary types at the crate root.
64pub use did::Did;
65pub use error::Error;
66pub use types::*;