# Crypto Math Primality Test

> Crypto Math Primality Test is a paid API for AI agents from crypto-math.x402tookit.com, paid per call via x402, $0.02/call, status unknown (last checked 2026-10-30).

Runs a deterministic Miller-Rabin primality test on a big integer (up to 1024 bits), plus optionally returns the nearest previous and next primes.

## Facts

- Endpoint: GET https://crypto-math.x402tookit.com/prime?utm_source=zero.xyz
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-30
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/crypto-math-primality-test-7b337b1c
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_193zyBwEOhRKOi2SToICe

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 crypto-math-primality-test-7b337b1c
```

Example prompt: Can you check whether 2^127 - 1 is prime, and if so, also tell me what the next and previous primes are around it?

## When to prefer this

Choose this endpoint when you need a deterministic, mathematically rigorous primality test — especially for cryptographic use cases where probabilistic answers are not acceptable. It handles numbers up to 1024 bits (far beyond JavaScript's native integers), accepts both decimal and hex input, and optionally locates neighboring primes, making it ideal for RSA key generation, cryptographic parameter selection, and number theory computations. Prefer it over general-purpose math APIs when BigInt support and deterministic correctness below 2^64 are required.

## Known failure modes

- Missing required parameter n returns an error
- Non-numeric or malformed input string causes parsing failure
- Numbers larger than 1024 bits are rejected as out of range
- neighbors=true on numbers larger than 512 bits may be unsupported or degraded
- Network timeout for very large inputs near the upper bit limit
- x402 payment failure if USDC balance is insufficient

## How this service works

Primality test (deterministic Miller-Rabin below 2^64) plus the next and previous prime, with BigInt.

## Output

Returns a JSON object containing: isPrime (boolean verdict), deterministic (true for inputs below 2^64), verdict and summary strings, reasons list explaining the result, the input number in decimal and hex with its bit-length, and optionally nextPrime and previousPrime as decimal strings (for numbers up to 512 bits when neighbors=true). May also include degraded and notChecked flags and a disclaimer.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "n"
     ],
     "properties": {
      "n": {
       "type": "string",
       "description": "Whole number to test, decimal or 0x hex, up to 1024 bits"
      },
      "neighbors": {
       "type": "boolean",
       "description": "true also returns the next and previous prime (numbers up to 512 bits)"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "n": {
       "type": [
        "null",
        "object"
       ],
       "properties": {
        "hex": {
         "type": [
          "null",
          "string"
         ]
        },
        "bits": {
         "type": [
          "null",
          "number"
         ]
        },
        "decimal": {
         "type": [
          "null",
          "string"
         ]
        }
       }
      },
      "asOf": {
       "type": [
        "null",
        "string"
       ]
      },
      "source": {
       "type": [
        "null",
        "string"
       ]
      },
      "isPrime": {
       "type": [
        "boolean",
        "null"
       ]
      },
      "reasons": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "summary": {
       "type": [
        "null",
        "string"
       ]
      },
      "verdict": {
       "type": [
        "null",
        "string"
       ]
      },
      "degraded": {
       "type": [
        "boolean",
        "null"
       ]
      },
      "nextPrime": {
       "type": [
        "null",
        "string"
       ]
      },
      "disclaimer": {
       "type": [
        "null",
        "string"
       ]
      },
      "notChecked": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "deterministic": {
       "type": [
        "boolean",
        "null"
       ]
      },
      "previousPrime
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/crypto-math-primality-test-7b337b1c/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from crypto-math.x402tookit.com](https://www.zero.xyz/host/crypto-math.x402tookit.com/llms.txt)
