Metadata-Version: 2.4
Name: creduent
Version: 2.0.5
Summary: Creduent is the open application-layer protocol for cryptographic identity and trust verification of autonomous AI agents using Ed25519 and DNS.
Home-page: https://github.com/idevsec/creduent-python
Author: IDevSec
Author-email: IDevSec <contact@idevsec.com>
Project-URL: Homepage, https://idevsec.com/creduent
Project-URL: Documentation, https://idevsec.com/creduent/docs
Project-URL: Repository, https://github.com/idevsec/creduent-python
Project-URL: Changelog, https://github.com/idevsec/creduent-python/blob/main/CHANGELOG.md
Keywords: creduent,ai-agent,agent-identity,agent-trust,cryptographic-signing,ed25519,attestation,agent-json,open-standard,mcp,model-context-protocol,dns-verification,ai-security,autonomous-agent,jcs,rfc8785,idevsec
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 4 - Beta
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography
Requires-Dist: requests
Requires-Dist: jcs
Requires-Dist: PyYAML
Provides-Extra: crewai
Requires-Dist: crewai; extra == "crewai"
Provides-Extra: langgraph
Requires-Dist: langgraph; extra == "langgraph"
Provides-Extra: autogen
Requires-Dist: autogen; extra == "autogen"
Provides-Extra: all
Requires-Dist: crewai; extra == "all"
Requires-Dist: langgraph; extra == "all"
Requires-Dist: autogen; extra == "all"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# Creduent Python SDK

[![PyPI version](https://img.shields.io/pypi/v/creduent.svg?color=blue)](https://pypi.org/project/creduent/)
[![License](https://img.shields.io/github/license/idevsec/creduent.svg)](https://github.com/idevsec/creduent/blob/main/LICENSE)
[![Python Compatibility](https://img.shields.io/pypi/pyversions/creduent.svg)](https://pypi.org/project/creduent/)

The official Python SDK for the **Creduent Protocol** — a federated, open trust-verification layer and cryptographic identity infrastructure for autonomous AI agents.

### What is Creduent?
**Creduent** is an open application-layer protocol for cryptographic identity and trust verification of autonomous AI agents. Originated and stewarded by IDevSec, it provides a vendor-neutral standard to definitively verify who controls an AI agent, its authenticity, and its capabilities using Ed25519 cryptography and DNS records.

Creduent enables autonomous agents to cryptographically sign metadata, verify identities across administrative domains via DNS bindings, and interact with the Creduent registry for secure, machine-to-machine trust checks.

---

## Key Features

- **Cryptographic Identity Management**: Generate secure Ed25519 keypairs for AI agents (multi-key support enabled).
- **RFC 8785 Canonical Signatures**: Compute cryptographic signatures over JSON agent documents using JCS and Ed25519.
- **DNS Trust Binding**: Verify cryptographic bindings between `agent://` identifiers and web domains.
- **Registry Integration**: Register agents and resolve signed attestations from the Creduent Registry.
- **Discovery API**: Directly fetch and parse an agent's `agent.json` from their well-known endpoint without needing the registry.
- **Framework Integrations**: Native middleware/tools for **CrewAI**, **LangGraph**, and **AutoGen**.
- **Unified CLI `creduent`**: Out-of-the-box CLI commands for CRD scaffolding, signing, and capability discovery.

---

## Installation

```bash
pip install creduent
```

To install with specific framework integration support:
```bash
pip install "creduent[crewai]"
pip install "creduent[langgraph]"
pip install "creduent[autogen]"
pip install "creduent[all]"
```

---

## Agent Framework Integrations

Creduent provides native verification adapters for major AI agent frameworks, ensuring you can verify another agent's identity before interacting with it.

### CrewAI
```python
from creduent.integrations.crewai import CreduentVerificationTool
from crewai import Agent, Task, Crew

verify_tool = CreduentVerificationTool()

security_agent = Agent(
    role='Security Verifier',
    goal='Verify the identity of external agents before interacting',
    backstory='You are a strict security officer enforcing the Creduent protocol.',
    tools=[verify_tool]
)
```

### LangGraph
```python
from creduent.integrations.langgraph import create_verification_node
from langgraph.graph import StateGraph

def my_agent_node(state):
    # your logic
    pass

workflow = StateGraph(MyState)
# Insert verification middleware before interaction
workflow.add_node("verify_agent", create_verification_node("agent://example/target_agent"))
workflow.add_node("interact", my_agent_node)
workflow.add_edge("verify_agent", "interact")
```

### AutoGen
```python
from creduent.integrations.autogen import CreduentAgentMiddleware
import autogen

# Wrap your assistant to automatically verify incoming/outgoing agent messages
secure_assistant = CreduentAgentMiddleware(
    autogen.AssistantAgent(name="assistant", llm_config=llm_config)
)
```

---

## Command Line Interface (CLI v2)

The new unified `creduent` CLI uses a YAML-first CRD (Custom Resource Definition) approach to manage your agent identities.

### 1. Scaffold `agent.yaml`
```bash
creduent init
```
*Creates a draft `agent.yaml` in the current directory.*

### 2. Generate Keys
```bash
creduent keygen
```
*Generates Ed25519 keys inside `.creduent/keys/` and prints your public key.*

### 3. Build & Sign `agent.json`
```bash
creduent build
```
*Reads `agent.yaml` and `.creduent/keys/private.pem` (or `CREDUENT_PRIVATE_KEY` env var) and compiles a fully canonicalized, signed `agent.json` ready for deployment.*

### 4. Discover Agent Capabilities
```bash
# Public discovery
creduent discover agent://idevsec/steward

# Authenticated discovery (presents your agent identity)
creduent discover agent://idevsec/steward --as agent://my_org/my_agent
```

---

## API Reference

### `discover(target_agent_id: str, my_agent_id: str = None, private_key_pem: str = None) -> DiscoveryResult`
Resolves an agent's URL from the registry, fetches their `agent.json`, verifies its cryptographic signature and DNS bindings offline, and returns their capabilities. Can optionally perform authenticated discovery using your own key.

### `sign(draft: dict, private_key_pem: str) -> dict`
Signs a draft agent document using JCS canonicalization (RFC 8785) + Ed25519. Returns signed document with the `keys` and `signature` fields.

### `verify(target: str | dict) -> VerifyResult`
Verifies a self-signed agent.json. Accepts dict, HTTPS URL, domain, local path, or `agent://` URI.
- `result.valid` — bool
- `result.agent_id`, `result.keys`, `result.endpoint`, `result.capabilities`
- `result.error` — str or None

### `register(agent_id, domain, agent_json_url, registry_url?) -> RegisterResult`
Registers an agent with the Creduent registry.
- `result.success` — bool
- `result.attestation` — dict (level, issued_at, expires_at, ...)

### `attest(agent_id, registry_url?) -> AttestResult`
Fetches attestation status for an agent from the registry.

---

## Contributing
Bugs, feature requests, and pull requests welcome via [GitHub Issues](https://github.com/idevsec/creduent/issues).

## Security & Hardening

The Creduent Python SDK enforces key safety and signature verification practices:

- **Strict Key Storage Permissions:** Key generation commands (`creduent keygen` in the CLI and `creduent-sign generate-keys` in the signing tool) automatically restrict the saved private key file's permissions to `0o600` (read/write by owner only) on Unix-based systems.
- **Fail-Closed Verification:** Any validation parsing error or timestamp format discrepancy defaults to marking the verification or attestation status as invalid, guarding against format injection attacks.

---

## License

Licensed under the **[Apache License 2.0](LICENSE)**. See the [LICENSE](LICENSE) file for the full legal text.
