Installation
Requirements
- Python >= 3.11
Quick Start
1. Initialize Identity
Create a local agent identity once:2. Certify Your Agent
Attach identity and signed request helpers to any object:.sigilum property with identity metadata and request helpers.
3. Send Signed Requests
API Reference
certify(agent, **kwargs)
Attaches Sigilum identity bindings to an agent object.
Parameters:
agent: Any- Any object to certify (required)namespace: str | None- Namespace to load (defaults to first found)home_dir: str | None- Custom identity directory (defaults to~/.sigilum)api_base_url: str | None- API base URL (defaults tohttps://api.sigilum.idorSIGILUM_API_URL)fetcher: Fetcher | None- Custom fetch implementation
.sigilum bindings attached
Example:
agent.sigilum
Bindings attached to certified agents:
Properties
namespace: str- Agent’s namespacedid: str- Agent’s DID (for example:did:sigilum:alice:default#agent-abc123#alice)key_id: str- Agent’s key IDpublic_key: str- Agent’s Ed25519 public key (ed25519:...)certificate: SigilumCertificate- Agent’s certificate with proofapi_base_url: str- Resolved API base URL
Methods
sign(**kwargs)
Signs a request without sending it.
Parameters:
url: str- Request URL (absolute or relative) (required)method: str- HTTP method (defaults to"GET")headers: HeaderInput | None- Request headers (dict or list of tuples)body: bytes | str | None- Request bodysubject: str | None- Override subject for this requestcreated: int | None- Unix timestamp for signature (defaults to now)nonce: str | None- Custom nonce (defaults to random UUID)
SignedRequest
Example:
fetch(**kwargs)
Signs and sends a request using urllib.
Parameters:
url: str- Request URL (absolute or relative) (required)method: str- HTTP method (defaults to"GET")headers: HeaderInput | None- Request headersbody: bytes | str | None- Request bodysubject: str | None- Override subject for this request
http.client.HTTPResponse
Example:
request(path, **kwargs)
Convenience method that resolves paths relative to the namespace API base.
Parameters:
path: str- Path relative to/v1/namespaces/{namespace}/(required)method: str- HTTP method (defaults to"GET")headers: HeaderInput | None- Request headersbody: bytes | str | None- Request bodysubject: str | None- Override subject for this request
http.client.HTTPResponse
Example:
init_identity(**kwargs)
Programmatically initialize a new agent identity.
Parameters:
namespace: str- Namespace for this identity (required)home_dir: str | None- Custom identity directoryforce: bool- Overwrite existing identity (defaults toFalse)
InitIdentityResult
Example:
load_identity(**kwargs)
Load an existing agent identity.
Parameters:
namespace: str | None- Namespace to load (defaults to first found)home_dir: str | None- Custom identity directory
SigilumIdentity
Example:
verify_http_signature(**kwargs)
Verify an incoming signed request (server-side).
Parameters:
url: str- Request URL (required)method: str- HTTP method (required)headers: HeaderInput- Request headers (required)body: bytes | str | None- Request bodyexpected_namespace: str | None- Require specific namespaceexpected_subject: str | None- Require specific subjectmax_age_seconds: int | None- Maximum signature agenow_ts: int | None- Current Unix timestamp (defaults to now)seen_nonces: set[str] | None- Nonce set for replay detection
VerifySignatureResult
Example:
retry_with_backoff(operation, **kwargs)
Retry helper with exponential backoff for idempotent operations.
Parameters:
operation: Callable[[], T]- Sync operation to retry (required)idempotent: bool- Required. Must beTruewhenattempts > 1attempts: int- Max attempts (defaults to 3)base_delay_seconds: float- Initial delay (defaults to 0.1)max_delay_seconds: float- Maximum delay (defaults to 2.0)jitter_ratio: float- Jitter ratio (defaults to 0.2)should_retry_result: Callable[[T], bool] | None- Retry predicate for resultsshould_retry_error: Callable[[Exception], bool] | None- Retry predicate for errorssleep: Callable[[float], None]- Custom sleep implementation (defaults totime.sleep)
T
Example:
should_retry_http_status(status)
Helper that returns True for retryable HTTP status codes.
Retryable statuses: 429, 502, 503, 504
Example:
Subject Override
Override thesigilum-subject header for a specific request:
subject is omitted, the SDK defaults to the signer’s namespace.
Identity Model
Hierarchy:namespace -> service -> agent -> subject
DID Format: did:sigilum:{namespace}:{service}#{agent}#{subject}
Example: did:sigilum:mfs:narmi#davis-agent#customer-12345
Error Codes
Signature verification failures return deterministic codes:| Code | Meaning |
|---|---|
SIG_CONTENT_DIGEST_MISMATCH | Request body tampered |
SIG_VERIFICATION_FAILED | Signature cryptographically invalid |
SIG_CERT_INVALID | Agent certificate proof failed |
SIG_TIMESTAMP_OUT_OF_RANGE | Signature expired or not yet valid |
SIG_REPLAY_DETECTED | Nonce already seen (replay attack) |
SIG_NAMESPACE_MISMATCH | Namespace header doesn’t match cert |
SIG_SUBJECT_MISSING | Required subject header missing |
SIG_MISSING_SIGNATURE_HEADERS | Missing Signature-Input or Signature |
SIG_ALGORITHM_UNSUPPORTED | Unsupported signature algorithm |
Authentication Note
Signed headers prove agent identity. Some endpoints also require additional auth: Example:POST /v1/claims requires Authorization: Bearer <service_api_key>
Advanced Usage
Custom Fetcher
Manual Signing
Certificate Encoding/Decoding
Type Hints
The SDK provides full type hints:Next Steps
SDK Overview
Learn about the common SDK contract
Go SDK
View the Go SDK documentation