open-agent-id
Rust SDK for the Open Agent ID protocol (V2). Sign and verify HTTP requests and P2P messages using Ed25519.
Installation
[]
= "0.2"
Enable optional features:
= { = "0.2", = ["client", "signer"] }
Quick Start
The most common use case is adding agent authentication headers to outbound requests:
use sign_agent_auth;
let headers = sign_agent_auth;
// Returns HashMap with:
// "X-Agent-DID" => "did:oaid:base:0x1234..."
// "X-Agent-Timestamp" => "1708123456"
// "X-Agent-Nonce" => "a3f1b2c4d5e6f7089012abcd"
// "X-Agent-Signature" => "<base64url signature>"
let resp = new
.post
.headers
.json
.send
.await?;
Registry Client
Requires the client feature.
use RegistryClient;
let client = new; // uses https://api.openagentid.org
All methods
| Method | Auth required | Description |
|---|---|---|
client.challenge(wallet_address) |
No | Request a wallet auth challenge |
client.wallet_auth(&WalletAuthRequest) |
No | Verify wallet signature, returns auth token |
client.register(token, &RegistrationRequest) |
Yes | Register a new agent |
client.lookup(did) |
No | Look up an agent by DID |
client.list_my_agents(token, cursor, limit) |
Yes | List agents owned by the authenticated wallet |
client.update_agent(token, did, &UpdateAgentRequest) |
Yes | Update agent metadata |
client.revoke(token, did) |
Yes | Revoke an agent identity |
client.rotate_key(token, did, &RotateKeyRequest) |
Yes | Rotate an agent's public key |
client.deploy_wallet(token, did) |
Yes | Deploy an on-chain smart wallet for an agent |
client.get_credit(did) |
No | Look up an agent's credit score |
client.verify(&VerifyRequest) |
No | Verify a signature against the agent's registered key |
Wallet auth flow
use WalletAuthRequest;
// 1. Request challenge
let challenge = client.challenge.await?;
// 2. Sign the challenge text with your wallet
// let wallet_signature = ...;
// 3. Verify and get auth token
let auth = client.wallet_auth.await?;
let token = auth.token;
Register an agent
use RegistrationRequest;
let agent = client.register.await?;
Look up and list agents
let info = client.lookup.await?;
let agents = client.list_my_agents.await?;
Manage agents
client.update_agent.await?;
client.rotate_key.await?;
client.revoke.await?;
client.deploy_wallet.await?;
Credit Score
let credit = client.get_credit.await?;
println!; // 300
println!; // "verified"
HTTP Signing
Sign and verify an HTTP request
use ;
let = generate_keypair;
let output = sign_http.unwrap;
let valid = verify_http.unwrap;
assert!;
Signer daemon client
Requires the signer feature.
use SignerClient;
let client = connect.await?;
let signature = client.sign.await?;
Message Signing
Sign and verify a P2P message
use ;
let = generate_keypair;
let body = json!;
let output = sign_msg;
let valid = verify_msg.unwrap;
assert!;
E2E Encryption
use crypto;
let ciphertext = encrypt_for?;
let plaintext = decrypt_from?;
Uses NaCl box (X25519-XSalsa20-Poly1305).
DID Utilities
Parse a DID
use Did;
let did = parse.unwrap;
assert_eq!;
println!; // did:oaid:base:0x7f4e...
Canonical helpers
use signing;
// Canonical URL (lowercased host, sorted query params, no fragment)
let url = canonicalize_url.unwrap;
assert_eq!;
// Canonical JSON (sorted keys, no whitespace)
let val: Value = from_str.unwrap;
assert_eq!;
Testing
License
Apache-2.0