# Constant-Time String Comparison

> Constant-Time String Comparison 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).

Compares two strings in constant time using cryptographic timing-safe equality to prevent timing side-channel attacks, returning equality status and length match.

## Facts

- Endpoint: POST https://agent402.tools/api/constant-compare
- 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/constant-time-string-comparison-bbb6213d
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_kz6RQ0SeAUKq0eKREpWtb

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 constant-time-string-comparison-bbb6213d -d '<json body>'
```

Example prompt: Do a timing-safe constant-time comparison of these two strings to check if they're equal without leaking timing info: 'abc123secrettoken' and 'abc123secrettoken'.

## When to prefer this

Use this endpoint when you need to securely compare two strings — such as API keys, HMAC signatures, tokens, or passwords — in a way that prevents timing side-channel attacks. Prefer this over naive string equality checks whenever security is a concern and you cannot run server-side crypto locally.

## Known failure modes

- Missing required field 'a' or 'b' results in a 400 error
- Non-string inputs may cause schema validation errors
- Network timeout on slow connections

## How this service works

Compare two strings in constant time using node:crypto timingSafeEqual, preventing timing side-channel attacks. Returns whether the strings are equal and whether their lengths match. Different-length strings are always unequal but comparison does ...

## Output

Returns a JSON object indicating whether the two strings are equal (boolean) and whether their lengths match (boolean). Different-length strings are always reported as unequal, but the comparison still runs in constant time to avoid leaking length information.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "a": {
   "type": "string",
   "description": "First string to compare"
  },
  "b": {
   "type": "string",
   "description": "Second string to compare"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "equal": false,
  "lengthMatch": false
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/constant-time-string-comparison-bbb6213d/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)
