Theme
SDKs and libraries
Official SDKs are Planned. Until they ship, every language calls the API directly over HTTPS with JSON: the cloud API has a dozen operations, and each needs one header and a base64 field or two.
Status by language
| Language | SDK | Use today |
|---|---|---|
| TypeScript and JavaScript | Planned | fetch (Node.js 18 or later, Deno, Bun): example |
| Python | Planned | The standard library's urllib.request: example |
| Go | Planned | net/http: example |
| Java | Planned | java.net.http.HttpClient and any JSON library |
| .NET | Planned | System.Net.Http.HttpClient and System.Text.Json |
| Rust | Planned | Any HTTPS client with a JSON library |
| C | Planned | Any HTTPS client with a JSON library |
| Shell | curl and jq: example |
The planned SDKs will be generated from the same OpenAPI documents as the API reference, with a post-quantum transport for Aegis Core written by hand. Asking for a policy name such as qbb-hybrid-1 instead of an algorithm is planned with them.
Complete examples
Each example below makes a key if it does not exist, signs a message, verifies it, checks that a changed message fails, and prints the month's usage. They read AEGIS_URL and AEGIS_API_KEY from the environment and need nothing beyond the language's standard library (the shell one needs curl and jq). Every change to these docs runs all four against a stand-in for the API.
Shell
sh
#!/usr/bin/env bash
# Sign and verify with an ML-DSA-65 key in Aegis Cloud, with curl and jq.
# Set AEGIS_URL (https://aegis.qblackbit.com) and AEGIS_API_KEY (a developer key) in the environment first.
set -euo pipefail
: "${AEGIS_URL:=https://aegis.qblackbit.com}"
: "${AEGIS_API_KEY:?set AEGIS_API_KEY to a developer key; never paste it into a file you commit}"
NAME=${AEGIS_KEY_NAME:-quickstart-signing}
aegis() { # aegis METHOD PATH [JSON]: one call; prints the body, fails on an HTTP error
curl -sS --fail-with-body -X "$1" "$AEGIS_URL$2" \
-H "Authorization: Bearer $AEGIS_API_KEY" -H "Content-Type: application/json" ${3:+-d "$3"}
}
aegis GET /api/v1/algorithms | jq -c '{plan, algorithms}'
# Make the key once; a second run answers 409 "a key of that name exists", which is fine.
aegis POST /api/v1/keys "{\"name\": \"$NAME\", \"algorithm\": \"ml-dsa-65\"}" || true
echo
MESSAGE=$(printf '%s' 'hello from my first post-quantum signature' | base64 | tr -d '\n')
SIGNED=$(aegis POST "/api/v1/keys/$NAME/sign" "{\"message\": \"$MESSAGE\"}")
SIGNATURE=$(jq -r .signature <<<"$SIGNED")
VERSION=$(jq -r .version <<<"$SIGNED")
echo "signature: $(printf '%s' "$SIGNATURE" | base64 -d | wc -c | tr -d ' ') bytes, key version $VERSION"
TAMPERED=$(printf '%s' 'hello from my first post-quantum signature!' | base64 | tr -d '\n')
for CHECK in "original $MESSAGE" "tampered $TAMPERED"; do
set -- $CHECK
VALID=$(aegis POST "/api/v1/keys/$NAME/verify" \
"{\"message\": \"$2\", \"signature\": \"$SIGNATURE\", \"version\": $VERSION}" | jq -r .valid)
echo "$1: valid = $VALID"
done
aegis GET /api/v1/usage | jq -r '"operations this month: \(.used.included) of \(.included)"'Python
py
#!/usr/bin/env python3
"""Sign and verify with an ML-DSA-65 key in Aegis Cloud, with Python's standard library only.
Set AEGIS_URL (https://aegis.qblackbit.com) and AEGIS_API_KEY (a developer key) in the environment first.
"""
import base64
import json
import os
import sys
import urllib.error
import urllib.request
BASE = os.environ.get("AEGIS_URL", "https://aegis.qblackbit.com").rstrip("/")
API_KEY = os.environ.get("AEGIS_API_KEY") or sys.exit("set AEGIS_API_KEY to a developer key")
NAME = os.environ.get("AEGIS_KEY_NAME", "quickstart-signing")
def call(method, path, body=None):
"""One call to the cloud API: returns (HTTP status, decoded JSON)."""
data = json.dumps(body).encode() if body is not None else None
request = urllib.request.Request(BASE + path, data=data, method=method)
request.add_header("Authorization", "Bearer " + API_KEY)
if data is not None:
request.add_header("Content-Type", "application/json")
try:
with urllib.request.urlopen(request, timeout=30) as response:
return response.status, json.load(response)
except urllib.error.HTTPError as error:
return error.code, json.load(error)
def must(status, answer, *expected):
if status not in expected:
sys.exit(f"{status} {answer.get('code')}: {answer.get('error')}")
return answer
def b64(raw):
return base64.b64encode(raw).decode()
plan = must(*call("GET", "/api/v1/algorithms"), 200)
print("plan:", plan["plan"], "| algorithms:", ", ".join(plan["algorithms"]))
status, made = call("POST", "/api/v1/keys", {"name": NAME, "algorithm": "ml-dsa-65"})
print("key:", NAME, "made" if status == 201 else "already exists" if status == 409 else must(status, made))
message = b"hello from my first post-quantum signature"
signed = must(*call("POST", f"/api/v1/keys/{NAME}/sign", {"message": b64(message)}), 200)
print("signature:", len(base64.b64decode(signed["signature"])), "bytes, key version", signed["version"])
for label, candidate in (("original", message), ("tampered", message + b"!")):
body = {"message": b64(candidate), "signature": signed["signature"], "version": signed["version"]}
checked = must(*call("POST", f"/api/v1/keys/{NAME}/verify", body), 200)
print(f"{label}: valid = {checked['valid']}")
usage = must(*call("GET", "/api/v1/usage"), 200)
print("operations this month:", usage["used"]["included"], "of", usage["included"])Node.js
js
// Sign and verify with an ML-DSA-65 key in Aegis Cloud, with Node's built-in fetch (Node 18 or later).
// Set AEGIS_URL (https://aegis.qblackbit.com) and AEGIS_API_KEY (a developer key) in the environment first.
const base = (process.env.AEGIS_URL ?? 'https://aegis.qblackbit.com').replace(/\/$/, '')
const apiKey = process.env.AEGIS_API_KEY
const name = process.env.AEGIS_KEY_NAME ?? 'quickstart-signing'
if (!apiKey) throw new Error('set AEGIS_API_KEY to a developer key')
/** One call to the cloud API; throws on an unexpected status with the API's error code. */
async function call(method, path, body, ...expected) {
const response = await fetch(base + path, {
method,
headers: { authorization: `Bearer ${apiKey}`, ...(body ? { 'content-type': 'application/json' } : {}) },
body: body ? JSON.stringify(body) : undefined
})
const answer = await response.json()
if (!(expected.length ? expected : [200]).includes(response.status)) {
throw new Error(`${response.status} ${answer.code}: ${answer.error}`)
}
return { status: response.status, answer }
}
const b64 = (text) => Buffer.from(text).toString('base64')
const plan = (await call('GET', '/api/v1/algorithms')).answer
console.log(`plan: ${plan.plan} | algorithms: ${plan.algorithms.join(', ')}`)
const made = await call('POST', '/api/v1/keys', { name, algorithm: 'ml-dsa-65' }, 201, 409)
console.log(`key: ${name} ${made.status === 201 ? 'made' : 'already exists'}`)
const message = 'hello from my first post-quantum signature'
const signed = (await call('POST', `/api/v1/keys/${name}/sign`, { message: b64(message) })).answer
console.log(`signature: ${Buffer.from(signed.signature, 'base64').length} bytes, key version ${signed.version}`)
for (const [label, candidate] of [['original', message], ['tampered', message + '!']]) {
const body = { message: b64(candidate), signature: signed.signature, version: signed.version }
const checked = (await call('POST', `/api/v1/keys/${name}/verify`, body)).answer
console.log(`${label}: valid = ${checked.valid}`)
}
const usage = (await call('GET', '/api/v1/usage')).answer
console.log(`operations this month: ${usage.used.included} of ${usage.included}`)Go
go
// Sign and verify with an ML-DSA-65 key in Aegis Cloud, with Go's standard library only.
// Set AEGIS_URL (https://aegis.qblackbit.com) and AEGIS_API_KEY (a developer key) in the environment first.
//
// go run quickstart.go
package main
import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"strings"
"time"
)
var (
base = strings.TrimRight(envOr("AEGIS_URL", "https://aegis.qblackbit.com"), "/")
apiKey = os.Getenv("AEGIS_API_KEY")
name = envOr("AEGIS_KEY_NAME", "quickstart-signing")
client = &http.Client{Timeout: 30 * time.Second}
)
func envOr(key, fallback string) string {
if value := os.Getenv(key); value != "" {
return value
}
return fallback
}
// call makes one request and decodes the JSON answer into out; it returns the HTTP status.
func call(method, path string, body any, out any) int {
var reader *bytes.Reader
if body != nil {
encoded, err := json.Marshal(body)
if err != nil {
log.Fatal(err)
}
reader = bytes.NewReader(encoded)
} else {
reader = bytes.NewReader(nil)
}
request, err := http.NewRequest(method, base+path, reader)
if err != nil {
log.Fatal(err)
}
request.Header.Set("Authorization", "Bearer "+apiKey)
if body != nil {
request.Header.Set("Content-Type", "application/json")
}
response, err := client.Do(request)
if err != nil {
log.Fatal(err)
}
defer response.Body.Close()
if err := json.NewDecoder(response.Body).Decode(out); err != nil {
log.Fatal(err)
}
return response.StatusCode
}
type apiError struct {
Error string `json:"error"`
Code string `json:"code"`
}
func main() {
if apiKey == "" {
log.Fatal("set AEGIS_API_KEY to a developer key")
}
var plan struct {
Plan string `json:"plan"`
Algorithms []string `json:"algorithms"`
}
if status := call("GET", "/api/v1/algorithms", nil, &plan); status != 200 {
log.Fatalf("algorithms: HTTP %d", status)
}
fmt.Printf("plan: %s | algorithms: %s\n", plan.Plan, strings.Join(plan.Algorithms, ", "))
var made apiError
switch status := call("POST", "/api/v1/keys", map[string]string{"name": name, "algorithm": "ml-dsa-65"}, &made); status {
case 201:
fmt.Println("key:", name, "made")
case 409:
fmt.Println("key:", name, "already exists")
default:
log.Fatalf("create: %d %s: %s", status, made.Code, made.Error)
}
message := []byte("hello from my first post-quantum signature")
var signed struct {
Signature string `json:"signature"`
Version int `json:"version"`
}
if status := call("POST", "/api/v1/keys/"+name+"/sign", map[string]string{"message": base64.StdEncoding.EncodeToString(message)}, &signed); status != 200 {
log.Fatalf("sign: HTTP %d", status)
}
raw, _ := base64.StdEncoding.DecodeString(signed.Signature)
fmt.Printf("signature: %d bytes, key version %d\n", len(raw), signed.Version)
for _, check := range []struct {
label string
message []byte
}{{"original", message}, {"tampered", append(append([]byte{}, message...), '!')}} {
var checked struct {
Valid bool `json:"valid"`
}
body := map[string]any{"message": base64.StdEncoding.EncodeToString(check.message), "signature": signed.Signature, "version": signed.Version}
if status := call("POST", "/api/v1/keys/"+name+"/verify", body, &checked); status != 200 {
log.Fatalf("verify: HTTP %d", status)
}
fmt.Printf("%s: valid = %t\n", check.label, checked.Valid)
}
var usage struct {
Included int `json:"included"`
Used struct {
Included int `json:"included"`
} `json:"used"`
}
call("GET", "/api/v1/usage", nil, &usage)
fmt.Printf("operations this month: %d of %d\n", usage.Used.Included, usage.Included)
}Rules that apply in every language
- Read the API key from the environment or a secrets store; never commit it, log it or put it in a web page or a mobile app.
- Send binary values as standard base64 with padding.
- Handle the error codes: back off on
rate_limited, stop onquota, retry later onunavailable. - Treat a
shared_secretfrom encapsulation as a key: derive what you need from it and never log it.
Aegis Core from code
Aegis Core speaks the same JSON over REST, and gRPC on the same listener. Your HTTPS client must offer a hybrid key-exchange group (X25519MLKEM768 or the others in Quantum-safe transport): for example a client built on OpenSSL 3.5 or later, or Go 1.24 or later, whose TLS offers X25519MLKEM768 by default. Generate a client from the daemon's own OpenAPI document (GET /v1/openapi.json) or from the published copy.