# HKDF Extract-Then-Expand Key Derivation (RFC 5869)

> HKDF Extract-Then-Expand Key Derivation (RFC 5869) is a paid API for AI agents from agent402.tools, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-14).

Derives cryptographic output keying material (OKM) from initial keying material, an optional salt, and an optional info/context string using HKDF (RFC 5869), returning hex-encoded bytes.

## Facts

- Endpoint: POST https://agent402.tools/api/hkdf-expand
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/hkdf-extract-then-expand-key-derivation-rfc-5869-7cdc057c
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_KZXELTgdh2tymYcuqIF_S

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability hkdf-extract-then-expand-key-derivation-rfc-5869-7cdc057c -d '<json body>'
```

Example prompt: Derive 64 bytes of keying material from my shared secret '3a9f...b2c1' using HKDF with SHA-256, the salt 'mysalt', and context info 'session-encryption-v1', and give me the result as hex.

## When to prefer this

Choose this endpoint when you need to deterministically derive one or more cryptographic keys from a shared secret (e.g., a Diffie-Hellman output) with a specific context binding — especially when following RFC 5869 HKDF. Prefer it over PBKDF2 when the input material is already high-entropy (not a user password) and you need fast key expansion rather than password stretching.

## Known failure modes

- Invalid or unsupported digest algorithm returns an error (only sha1, sha256, sha384, sha512 accepted)
- keyLength exceeding 128 bytes returns an error or truncated result
- Missing or empty IKM may cause a derivation error or produce degenerate output
- Malformed input (non-string IKM/salt/info) returns a 400-level error
- Payment failure or insufficient USDC balance returns a 402 Payment Required response

## How this service works

HKDF extract-then-expand (RFC 5869) — derive output keying material from initial keying material, an optional salt, and an optional info/context string. Useful for deriving multiple keys from a single shared secret. Returns hex-encoded OKM.

## Output

A hex-encoded string of output keying material (OKM) of the requested byte length (default 32 bytes, up to 128 bytes), derived deterministically from the provided IKM, salt, info, and digest algorithm.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "ikm": {
   "type": "string",
   "description": "Initial keying material (the shared secret)"
  },
  "info": {
   "type": "string",
   "description": "Optional context/application info (empty string if omitted)"
  },
  "salt": {
   "type": "string",
   "description": "Optional salt (empty string if omitted)"
  },
  "digest": {
   "type": "string",
   "description": "Hash algorithm: sha1, sha256, sha384, sha512 (default sha256)"
  },
  "keyLength": {
   "type": "integer",
   "description": "Desired output key length in bytes (default 32, max 128)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "okm": "a1b2c3d4e5f6...",
  "digest": "sha256",
  "algorithm": "hkdf",
  "keyLength": 32
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/hkdf-extract-then-expand-key-derivation-rfc-5869-7cdc057c/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
