Installation
Requirements
- Go 1.23
Quick Start
1. Initialize Identity
Create a local agent identity once:2. Certify Your Agent
Create identity bindings for signed requests:3. Send Signed Requests
API Reference
Certify(options)
Creates Sigilum identity bindings for signed requests.
Parameters:
options: CertifyOptionsNamespace: string- Namespace to load (defaults to first found)HomeDir: string- Custom identity directory (defaults to~/.sigilum)APIBaseURL: string- API base URL (defaults tohttps://api.sigilum.idorSIGILUM_API_URL)HTTPClient: *http.Client- Custom HTTP client (defaults tohttp.DefaultClient)
(*SigilumBindings, error)
Example:
SigilumBindings
Bindings returned by Certify():
Fields
Namespace: string- Agent’s namespaceDID: string- Agent’s DID (for example:did:sigilum:alice:default#agent-abc123#alice)KeyID: string- Agent’s key IDPublicKey: string- Agent’s Ed25519 public key (ed25519:...)Certificate: SigilumCertificate- Agent’s certificate with proofAPIBaseURL: string- Resolved API base URLHTTPClient: *http.Client- HTTP client for requests
Methods
Sign(input)
Signs a request without sending it.
Parameters:
input: SignRequestInputURL: string- Request URL (absolute or relative) (required)Method: string- HTTP method (defaults toGET)Headers: map[string]string- Request headersBody: []byte- Request bodySubject: string- Override subject for this requestCreated: int64- Unix timestamp for signature (defaults to now)Nonce: string- Custom nonce (defaults to random UUID)
(SignedRequest, error)
Example:
Do(ctx, input)
Signs and sends a request.
Parameters:
ctx: context.Context- Request context (required)input: SignRequestInput- Request details (required)
(*http.Response, error)
Example:
Request(ctx, path, method, headers, body)
Convenience method that resolves paths relative to the namespace API base.
Parameters:
ctx: context.Context- Request context (required)path: string- Path relative to/v1/namespaces/{namespace}/(required)method: string- HTTP method (required)headers: map[string]string- Request headersbody: []byte- Request body
(*http.Response, error)
Example:
InitIdentity(options)
Programmatically initialize a new agent identity.
Parameters:
options: InitIdentityOptionsNamespace: string- Namespace for this identity (required)HomeDir: string- Custom identity directoryForce: bool- Overwrite existing identity
(InitIdentityResult, error)
Example:
LoadIdentity(options)
Load an existing agent identity.
Parameters:
options: LoadIdentityOptionsNamespace: string- Namespace to load (defaults to first found)HomeDir: string- Custom identity directory
(SigilumIdentity, error)
Example:
SignHTTPRequest(identity, input)
Low-level signing function.
Parameters:
identity: SigilumIdentity- Loaded identity (required)input: SignRequestInput- Request details (required)
(SignedRequest, error)
Example:
VerifyHTTPSignature(input)
Verify an incoming signed request (server-side).
Parameters:
input: VerifySignatureInputURL: string- Request URL (required)Method: string- HTTP method (required)Headers: map[string]string- Request headers (required)Body: []byte- Request bodyExpectedNamespace: string- Require specific namespaceExpectedSubject: string- Require specific subjectMaxAgeSeconds: int64- Maximum signature ageNowUnix: int64- Current Unix timestamp (defaults to now)SeenNonces: map[string]struct{}- Nonce map for replay detection
VerifySignatureResult
Example:
RetryWithBackoff(operation, options)
Retry helper with exponential backoff for idempotent operations.
Parameters:
operation: func() (T, error)- Operation to retry (required)options: RetryOptions[T]Idempotent: bool- Required. Must betruewhenAttempts > 1Attempts: int- Max attempts (defaults to 3)BaseDelaySeconds: float64- Initial delay (defaults to 0.1)MaxDelaySeconds: float64- Maximum delay (defaults to 2.0)JitterRatio: float64- Jitter ratio (defaults to 0.2)ShouldRetryResult: func(T) bool- Retry predicate for resultsShouldRetryError: func(error) bool- Retry predicate for errorsSleep: func(float64)- Custom sleep implementation
(T, error)
Example:
ShouldRetryHTTPStatus(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 | Constant | Meaning |
|---|---|---|
SIG_CONTENT_DIGEST_MISMATCH | verifyCodeContentDigestMismatch | Request body tampered |
SIG_VERIFICATION_FAILED | verifyCodeVerificationFailed | Signature cryptographically invalid |
SIG_CERT_INVALID | verifyCodeCertInvalid | Agent certificate proof failed |
SIG_TIMESTAMP_OUT_OF_RANGE | verifyCodeTimestampOutOfRange | Signature expired or not yet valid |
SIG_REPLAY_DETECTED | verifyCodeReplayDetected | Nonce already seen (replay attack) |
SIG_NAMESPACE_MISMATCH | verifyCodeNamespaceMismatch | Namespace header doesn’t match cert |
SIG_SUBJECT_MISSING | verifyCodeSubjectMissing | Required subject header missing |
SIG_MISSING_SIGNATURE_HEADERS | verifyCodeMissingSignatureHeaders | Missing Signature-Input or Signature |
SIG_ALGORITHM_UNSUPPORTED | verifyCodeAlgorithmUnsupported | 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 HTTP Client
Certificate Encoding/Decoding
Context Cancellation
Next Steps
SDK Overview
Learn about the common SDK contract
TypeScript SDK
View the TypeScript SDK documentation