{"uid":"cap_193zyBwEOhRKOi2SToICe","slug":"crypto-math-primality-test-7b337b1c","name":"Crypto Math Primality Test","description":"Primality test (deterministic Miller-Rabin below 2^64) plus the next and previous prime, with BigInt.","url":"https://crypto-math.x402tookit.com/prime?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"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":{"type":["null","string"]}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_Of_RgJQKOdEYGpJ2EzAze","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Runs a deterministic Miller-Rabin primality test on a big integer (up to 1024 bits), plus optionally returns the nearest previous and next primes.","exampleAgentPrompt":"Can you check whether 2^127 - 1 is prime, and if so, also tell me what the next and previous primes are around it?","exampleUseCases":[{"title":"RSA key prime candidate check","prompt":"I'm generating an RSA key pair and I need to verify that this 512-bit candidate prime is actually prime — the number is 0xFFFFFFFFFFFFFFFFC90FDAA22168C234. Can you run a deterministic primality test on it and also give me the next and previous primes nearby?"},{"title":"Classroom number theory exercise","prompt":"Is 104729 prime? I want to know for sure, not just a probabilistic guess, and I'd also like to see what primes come right before and after it."},{"title":"Cryptographic parameter validation","prompt":"I have a 256-bit hex number I'm considering using as a prime modulus: 0xD3BF9D4A5E2F1C7B8A0E6F3D2C1B0A4F. Can you do a deterministic Miller-Rabin test and tell me definitively whether it's prime?"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-30T00:34:53.862Z","isFirstParty":false,"canonicalSlug":"crypto-math-primality-test-7b337b1c"}