Skip to main content

Overview

The Primitives API provides low-level cryptographic functions for generating keypairs, creating signatures, and verifying signed requests. Unlike the Agent API, primitives do not read from environment variables and require all parameters to be explicitly provided.

primitives.keypair()

Generates an Ed25519 keypair for signing and verification. If an existing private key is provided, it is reused and the public key is derived.

Signature

Parameters

string
An existing private JWK as JSON string. If provided, the keypair is derived from this key instead of generating a new one.
string
default:"agent"
Prefix for the key (currently not used in key generation but reserved for future use)

Returns

PublicJwk
required
The public key in JWK format containing:
  • kty: Always "OKP" (Octet Key Pair)
  • crv: Always "Ed25519"
  • x: Base64url-encoded public key
  • kid: Key ID (thumbprint of the public key)
PrivateJwk
required
The private key in JWK format containing all public key fields plus:
  • d: Base64url-encoded private key material

Example: Generate New Keypair

Example: Reuse Existing Private Key

The kid (Key ID) is automatically computed as the JWK thumbprint of the public key, ensuring consistent identification across key usage.

primitives.headers()

Generates RFC 9421 HTTP Message Signature headers using explicit credentials.

Signature

Parameters

string
required
The HTTP method (e.g., GET, POST, PUT, DELETE)
string
required
The full request URI including scheme, host, and path
string
required
The agent UID (e.g., agent-4b94ccd425e939fac5016b6b)
string
required
The private JWK as JSON string
string
default:"web-bot-auth"
Signature tag for the request
string
Custom nonce value. If not provided, a random nonce is generated.

Returns

string
required
The signature header value
string
required
The signature input parameters
string
required
The agent discovery URL

Example

Custom Tag and Nonce

The uid must match the agent identity registered with the Vestauth server, or verification will fail.

primitives.verify()

Verifies a signed HTTP request using an explicit public key or by fetching the key from the agent’s discovery endpoint.

Signature

Parameters

string
required
The HTTP method of the request being verified
string
required
The full request URI that was signed
HeaderBag
The request headers containing:
  • Signature
  • Signature-Input
  • Signature-Agent
PublicJwk
The public key to verify against. If not provided, Vestauth will attempt to resolve it via the Signature-Agent discovery endpoint.

Returns

string
The agent UID (if Signature-Agent was provided)
string
The key ID used for signing
PublicJwk
The public key used for verification
string
The discovery URL (if key was fetched remotely)

Example: Verify with Explicit Public Key

Example: Verify with Discovery

Example: Server-Side Verification


Differences from Higher-Level APIs

vs. Agent API

vs. Tool API


Type Definitions


Testing and Development

The Primitives API is ideal for testing authentication flows:

Advanced: Custom Discovery

You can implement custom key discovery logic using primitives:

See Also