Sign your first AAuth request in Python, Node and Go

Generate an Ed25519 key pair, sign your first RFC 9421 AAuth HTTP request in Python (lumoauth[aauth]), Node.js (@lumoauth/agent) and Go (lumo-auth-go), and check your output against the shared contract test vector.

To sign an HTTP request for AAuth with Ed25519 in Python, install lumoauth[aauth], call AAuthClient.generate_keypair(), and sign calls through AAuthClient.sign_request() or signed_request(). Every AAuth request carries an RFC 9421 HTTP message signature, a Content-Digest body hash, a 60-second created timestamp and a fresh 16-byte nonce. Assembling those headers by hand is easy to get wrong by a single space or encoding alphabet. This guide shows the exact key-generation and signing code in Python, Node.js and Go, then checks all three against one deterministic test vector.

TL;DR

  • Install lumoauth[aauth] for Python 3.9+, @lumoauth/agent for Node.js 18+ or github.com/lumoauth/lumo-auth-go for Go 1.22+.
  • Generate an Ed25519 key pair (kid: "key-1" by default), keep the PKCS#8 private key PEM secret, and register only the public JWKS in LumoAuth.
  • Use the low-level signers (client.sign_request, signRequest, lumoauth.SignRequest) to build RFC 9421 headers, or the high-level helpers (signed_request, signedRequest, SignedRequest) to call a protected resource with an auth+jwt.
  • Python signs only with Ed25519; Node.js and Go sign with both Ed25519 and RSA-PSS-SHA512 and add @query automatically when a URL has a query string.
  • All three SDKs reproduce the exact headers in sdk-contract/vectors/aauth-rfc9421.json byte for byte.

Before you sign: one setup step

If you are new to AAuth, read What is AAuth? for the protocol overview, RFC 9421 HTTP message signatures for agents, line by line for the header rules, and Why a stolen AAuth token is useless for how cnf binds keys to tokens.

Every language below follows the same three steps:

  1. Generate an Ed25519 key pair. Store the PKCS#8 private key PEM in a secrets manager, never in source control.
  2. Register the public JWKS. In the Organization Portal, open AI Agents → Agents (/portal/agents), click Register agent, choose AAuth on step 2, and paste the JWKS or enter a JWKS URL. Register the target API on the AAuth resources tab.
  3. Sign requests with the SDK. Each SDK computes Content-Digest in standard base64, builds the signature base with created and a 16-byte base64url nonce, and emits Signature-Input and Signature in base64url.

Sign your first AAuth request in Python

Install the aauth extra, which adds the cryptography dependency for Ed25519 signing:

pip install 'lumoauth[aauth]'

Generate a key pair once with AAuthClient.generate_keypair(). It returns (private_pem, jwks) with kid: "key-1":

import json
from lumoauth import AAuthClient

private_pem, jwks = AAuthClient.generate_keypair()

# Register this JWKS in the Organization Portal (or host it at /.well-known/jwks.json)
print(json.dumps(jwks, indent=2))

Next, create an AAuthClient with your agent identifier, private key PEM and organization slug. You can inspect the raw RFC 9421 headers with sign_request(), request an auth token with request_authorization(), and call a protected API with signed_request():

import json
from lumoauth import AAuthClient

client = AAuthClient(
    agent_identifier="https://my-agent.example.com",
    private_key_pem=private_pem,
    org_id="acme-corp",
)

# 1. Inspect the signed headers for a call to the agent token endpoint
body = json.dumps({
    "request_type": "auth",
    "resource_token": resource_token,
}).encode("utf-8")

headers = client.sign_request(
    "POST",
    "https://app.lumoauth.dev/orgs/acme-corp/api/v1/aauth/agent/token",
    body=body,
    agent_token=agent_token,
)
# headers contains: Content-Digest, Content-Type, Signature-Input, Signature, Agent-Auth

# 2. Or let the client run the full authorization flow and call your resource
tokens = client.request_authorization(
    resource_token=resource_token,
    scope="reports:read",
    agent_token=agent_token,
)

if not tokens.get("authorization_required"):
    resp = client.signed_request(
        "POST",
        "https://api.example.com/v1/reports",
        auth_token=tokens["auth_token"],
        data={"quarter": "2026-Q4"},
    )
    print(resp.status_code, resp.json())

Three Python details to keep in mind:

  • Ed25519 only. AAuthClient raises TypeError if you pass an RSA or EC private key.
  • No @query in sign_request(). The Python signer always covers the seven base components (@method, @authority, @path, signature-key, content-digest, content-type, authorization). Because LumoAuth requires @query when a URL has a query string, pass URLs without a query string to sign_request().
  • authorization and signature_key arguments. Passing authorization or signature_key to sign_request() puts the value into the signature base, but does not add that header to the returned dictionary. Send the same header yourself, or use signed_request(), which sets Authorization: Bearer <auth_token> and signs over it automatically.

Sign your first AAuth request in Node.js

Install the Node-only agent package (Node.js 18+; uses only node:crypto and global fetch, with no native dependencies):

npm install @lumoauth/agent

Generate a key pair with generateKeypair(), and sign a standalone request with signRequest() or run full flows through AAuthClient:

import { AAuthClient, generateKeypair, signRequest } from '@lumoauth/agent';

// 1. One-time key generation (defaults to kid: "key-1")
const { privateKeyPem, jwks } = generateKeypair();
console.log(JSON.stringify(jwks, null, 2));

// 2. Low-level signing: returns Content-Digest, Content-Type,
//    Signature-Input, Signature (and Agent-Auth / Signature-Key when supplied)
const body = JSON.stringify({
  request_type: 'auth',
  resource_token: resourceToken,
});

const headers = signRequest(
  privateKeyPem,
  'POST',
  'https://app.lumoauth.dev/orgs/acme-corp/api/v1/aauth/agent/token',
  { body, agentToken },
);

// 3. High-level client: obtain an auth token and call a protected API
const client = new AAuthClient({
  agentIdentifier: 'https://my-agent.example.com',
  privateKeyPem,
  baseUrl: 'https://app.lumoauth.dev',
  orgId: 'acme-corp',
});

const result = await client.requestAuthToken({
  resourceToken,
  scope: 'reports:read',
  agentToken,
});

if (!('authorizationRequired' in result)) {
  const resp = await client.signedRequest('POST', 'https://api.example.com/v1/reports', {
    authToken: result.authToken,
    data: { quarter: '2026-Q4' },
  });
  console.log(resp.status, await resp.json());
}

@lumoauth/agent signs with Ed25519 (ed25519) or RSA (rsa-pss-sha512, 64-byte salt) based on the loaded key type. It inserts @query after @path if and only if the URL carries a query string. Passing signatureKey both covers the value in the base and adds the Signature-Key header to the returned object.

Sign your first AAuth request in Go

Install the official Go SDK (Go 1.22+):

go get github.com/lumoauth/lumo-auth-go

Generate a key pair with GenerateKeypair("") (an empty string uses DefaultKid, "key-1"), sign standalone headers with SignRequest(), or call a protected resource through NewAAuthClient() and SignedRequest():

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"io"

	lumoauth "github.com/lumoauth/lumo-auth-go"
)

func main() {
	// 1. One-time key generation ("" defaults to kid "key-1")
	kp, err := lumoauth.GenerateKeypair("")
	if err != nil {
		panic(err)
	}
	jwksJSON, _ := json.MarshalIndent(kp.JWKS, "", "  ")
	fmt.Println(string(jwksJSON))

	// 2. Low-level signing for any AAuth endpoint
	body := []byte(`{"request_type":"auth","resource_token":"` + resourceToken + `"}`)
	headers, err := lumoauth.SignRequest(
		kp.PrivateKeyPEM,
		"POST",
		"https://app.lumoauth.dev/orgs/acme-corp/api/v1/aauth/agent/token",
		lumoauth.SignOptions{
			Body:       body,
			AgentToken: agentToken,
		},
	)
	if err != nil {
		panic(err)
	}
	fmt.Println("Signature-Input:", headers["Signature-Input"])

	// 3. High-level client: obtain an auth token and call a protected API
	client, err := lumoauth.NewAAuthClient(lumoauth.AAuthConfig{
		AgentIdentifier: "https://my-agent.example.com",
		PrivateKeyPEM:   kp.PrivateKeyPEM,
		OrgID:           "acme-corp",
	})
	if err != nil {
		panic(err)
	}

	ctx := context.Background()
	tok, err := client.RequestAuthToken(ctx, lumoauth.AuthTokenParams{
		ResourceToken: resourceToken,
		AgentToken:    agentToken,
	})
	if err != nil {
		panic(err)
	}

	if !tok.AuthorizationRequired {
		resp, err := client.SignedRequest(
			ctx,
			"POST",
			"https://api.example.com/v1/reports",
			tok.AuthToken,
			map[string]string{"quarter": "2026-Q4"},
		)
		if err != nil {
			panic(err)
		}
		defer resp.Body.Close()
		out, _ := io.ReadAll(resp.Body)
		fmt.Println(resp.StatusCode, string(out))
	}
}

Like Node.js, the Go signer picks the algorithm from the key type for Ed25519 and RSA (rsa-pss-sha512). It adds @query if and only if the target URL has a query string, and adds Signature-Key to the returned map when SignOptions.SignatureKey is set.

How the three SDK signers compare

All three SDKs emit the exact same headers for an Ed25519 request without a query string, with a few language-level differences to note:

Feature Python (lumoauth[aauth]) Node.js (@lumoauth/agent) Go (lumo-auth-go)
Generate Ed25519 key pair AAuthClient.generate_keypair() generateKeypair(kid?) lumoauth.GenerateKeypair(kid)
Sign headers directly client.sign_request(...) signRequest(pem, method, url, opts) lumoauth.SignRequest(pem, method, url, opts)
Call a protected API client.signed_request(...) client.signedRequest(...) client.SignedRequest(...)
Signing algorithms ed25519 only ed25519, rsa-pss-sha512 ed25519, rsa-pss-sha512
Automatic @query handling No (use URLs without query strings) Yes (added if and only if query exists) Yes (added if and only if query exists)
Adds Signature-Key header No (caller sends it) Yes, when signatureKey is set Yes, when SignatureKey is set
Deterministic test overrides Patch time.time and os.urandom created and nonce in SignRequestOptions Created and Nonce in SignOptions

Checking your signer against the test vector

LumoAuth maintains a shared contract repository with a deterministic RFC 9421 test vector at sdk-contract/vectors/aauth-rfc9421.json. The vector fixes five inputs:

  • Private key: Ed25519 seed bytes 0x00 through 0x1f (public JWK x: A6EHv_POEL4dcN0Y50vAmWfk1jCbpQ1fHdyGZBJVMbg)
  • Target: POST https://auth.acme.test/orgs/acme-corp/api/v1/aauth/agent/token
  • Body: {"request_type": "auth", "resource_token": "RESOURCE_TOKEN_FIXED", "scope": "read write"}
  • Timestamp and nonce: created=1750000000, nonce="AAECAwQFBgcICQoLDA0ODw" (bytes 0x00 through 0x0f)
  • Agent token: AGENT_TOKEN_FIXED

Because Ed25519 is deterministic (RFC 8032), every SDK must emit these exact header values:

Content-Digest: sha-256=:maoKTEBGVoe/uXlHmt4EeWj7K7xo71Ag/qIPObi3vPw=:
Signature-Input: sig1=("@method" "@authority" "@path" "signature-key" "content-digest" "content-type" "authorization");created=1750000000;nonce="AAECAwQFBgcICQoLDA0ODw"
Signature: sig1=:sr5ZGEA2-LkKN4RvFrpYxhaGPB-tf1STvf1W0bl_UAFt1Rjn_wKKCouOHsFamkDAf85UpwF_HOJXLs07-bynCw:
Agent-Auth: agent_token=AGENT_TOKEN_FIXED

Here is how to assert byte-for-byte parity in Node.js with signRequest():

import assert from 'node:assert/strict';
import fs from 'node:fs';
import { signRequest } from '@lumoauth/agent';

const vector = JSON.parse(fs.readFileSync('aauth-rfc9421.json', 'utf8'));

const headers = signRequest(vector.private_key_pem, vector.request.method, vector.request.url, {
  body: vector.request.body,
  agentToken: vector.request.agent_token,
  created: vector.request.created,
  nonce: vector.request.nonce,
});

assert.equal(headers['Content-Digest'], vector.expected.content_digest);
assert.equal(headers['Signature-Input'], vector.expected.signature_input);
assert.equal(headers['Signature'], vector.expected.signature);
assert.equal(headers['Agent-Auth'], vector.expected.agent_auth_header);

In Go, lumoauth.SignRequest takes the same overrides in SignOptions{Body: ..., AgentToken: ..., Created: ..., Nonce: ...}. In Python, AAuthClient.sign_request() has no created or nonce parameters, so unit tests patch lumoauth.aauth.time.time and lumoauth.aauth.os.urandom and assert the exact same four header strings.

How LumoAuth does it

Every AAuth agent starts in the Organization Portal at AI Agents → Agents (/portal/agents):

  1. Click Register agent, name the agent on step 1, and choose AAuth on step 2.
  2. Enter the Agent identifier and paste the JWKS returned by generate_keypair(), generateKeypair() or GenerateKeypair("") into JWKS (inline) (or host it and set JWKS URL).
  3. On step 3, set capabilities and AAuth options under Acting for people, then register your protected API on the AAuth resources tab (/portal/aauth/resources/create).

When your first signed call hits POST /orgs/{orgId}/api/v1/aauth/agent/token, a 401 authentication_required response carries a generic reason on the wire. Open Audit logs in the portal and filter for aauth.signature_verification_failed to inspect the exact cause. Common causes include clock skew over 60 seconds, a mismatched Content-Digest, or a signing key that differs from the agent token’s cnf claim.

LumoAuth also publishes Java (io.lumoauth:lumo-auth-java), PHP (lumoauth/lumoauth) and .NET (LumoAuth) SDKs built to the same contract. See the AAuth quickstart, the quickstart for Python, the quickstart for Node.js and the SDKs reference.

Standards involved

  • HTTP message signatures, RFC 9421, the signature base and header format that all three SDKs emit
  • Request body digest, RFC 9530, for the Content-Digest header in standard base64
  • Structured HTTP header fields, RFC 8941, for Signature-Input, Signature and Signature-Key
  • Edwards-Curve Digital Signature Algorithm (EdDSA), RFC 8032, for deterministic Ed25519 signing
  • JSON Web Key (JWK), RFC 7517, and Key thumbprint, RFC 7638, for the generated JWKS and key binding

The full list is on the standards reference.

FAQ

How do I sign an HTTP request with Ed25519 in Python for AAuth? Install lumoauth[aauth], generate a key pair with AAuthClient.generate_keypair(), and create an AAuthClient with your agent identifier, private key PEM and organization slug. Call client.sign_request() to build the RFC 9421 headers, or client.signed_request() to send a signed call with an auth token to a protected resource.

Why is AAuth in @lumoauth/agent instead of @lumoauth/client? @lumoauth/agent uses node:crypto for Ed25519 and RSA-PSS-SHA512 signing and is Node-only. Keeping it out of @lumoauth/client ensures that code that signs with private keys never bundles into a browser app.

Which signing key types do the Python, Node.js and Go SDKs support? All three SDKs generate Ed25519 key pairs by default. Node.js (@lumoauth/agent) and Go (lumo-auth-go) also sign with RSA keys using rsa-pss-sha512. Python’s AAuthClient accepts only Ed25519 keys. The LumoAuth server also accepts EC P-256 (ecdsa-p256-sha256), though none of these three SDK signers produce P-256 signatures yet.

Do all three SDKs handle URLs with query strings automatically? Node.js (signRequest) and Go (SignRequest) automatically add @query to the covered components if and only if the target URL has a query string. Python’s AAuthClient.sign_request() does not cover @query, so pass URLs without a query string when using that method.

How do I confirm that my custom or SDK signer matches LumoAuth’s server? Test against sdk-contract/vectors/aauth-rfc9421.json. Because Ed25519 signing is deterministic (RFC 8032), passing the vector’s fixed private key, body, created=1750000000 and nonce reproduces the exact Content-Digest, Signature-Input and Signature headers byte for byte.

Does sign_request() include the Authorization header in the returned dictionary? No. In Python, Node.js and Go, passing an authorization value to the low-level signer covers that value in the signature base, but does not add an Authorization header to the returned map. Either add the same Authorization header yourself, or use the higher-level signed_request() / signedRequest() / SignedRequest() helper, which sets Authorization: Bearer <auth_token> and signs over it.


Related: AI agent identity on the solutions pages, What is AAuth? and RFC 9421 HTTP message signatures for agents, line by line on this blog.

Register your first AAuth agent with the AAuth quickstart.

Last updated .

Ship passwordless sign-in this week. Put guardrails on your agents today.

The Developer plan is free for 10,000 monthly users and ten agents, with no card. Everything uses open standards, so moving in or out is a config change.