Documentation

Ethoryx API

Ethoryx v2.0 is a REST API for cryptographic prime generation across three contexts: RSA key generation, Ethoryx NTT · Field Primes for FHE, and next-prime optimization. Built on formally proved mathematical structure, it generates primes with 33–79% fewer Miller-Rabin primality tests depending on context and bit size.

The API is live at https://api.ethoryx.io and accepts requests over HTTPS. All responses are JSON.

API status: Operational · https://api.ethoryx.io/v1/status

Quick start

Get a prime in 60 seconds. Create a free account to get your API key, then:

cURL

# Generate a 512-bit prime
curl "https://api.ethoryx.io/v1/generate?bits=512" \
  -H "X-API-Key: tg_your_key_here"

Python

import requests

response = requests.get(
    "https://api.ethoryx.io/v1/generate",
    params={"bits": 2048},
    headers={"X-API-Key": "tg_your_key_here"}
)

data = response.json()
prime = int(data["prime"])       # Full integer, ready for RSA
tests = data["miller_rabin_tests"]  # e.g. 282 vs ~836 standard
print(f"Prime: {prime}")
print(f"Tests: {tests}")

JavaScript / Node.js

const res = await fetch(
  "https://api.ethoryx.io/v1/generate?bits=2048",
  { headers: { "X-API-Key": "tg_your_key_here" } }
);
const { prime, miller_rabin_tests } = await res.json();
console.log(`Prime: ${prime}`);
console.log(`Tests used: ${miller_rabin_tests}`);

pip library (open source)

pip install ethoryx

from ethoryx import prime_generator
p, tests = prime_generator.generate(bits=2048)
print(p)  # Full prime integer

Authentication

All generation endpoints require an API key passed as the X-API-Key request header.

-H "X-API-Key: tg_your_key_here"

Keep your API key secret. Do not expose it in client-side JavaScript, public repositories, or logs. If compromised, contact security@ethoryx.io immediately.

The /v1/status and /v1/verify endpoints do not require authentication. The dashboard uses a separate JWT Bearer token for the web interface, this is distinct from your API key.

Get your API key

Create an account to receive your API key by email. Your key starts with tg_ and is valid indefinitely unless you request a rotation.

Error handling

All errors return JSON with an error field and an appropriate HTTP status code.

{
  "error": "Invalid or missing API key",
  "docs": "https://tesfagrid.io/docs",
  "get_key": "https://ethoryx.io/register"
}
StatusMeaning
200Success
400Bad request - invalid parameter value
401Unauthorized - missing or invalid API key
403Forbidden - endpoint requires a higher tier
409Conflict - email already registered
429Rate limit exceeded or monthly quota reached
500Server error - contact support

Generate a prime

Generates a single cryptographically strong prime number using the Ethoryx Sieve algorithm.

GET /v1/generate 🔑 X-API-Key required

Parameters

NameTypeRequiredDescription
bitsintegeroptionalBit length of the prime. One of: 256, 512, 1024, 2048, 4096. Default: 512. Maximum depends on your tier.
methodstringoptionalstandard (default) or basic. Standard uses full sieve optimization. Basic uses a reduced filter set.

Request

curl "https://api.ethoryx.io/v1/generate?bits=2048&method=standard" \
  -H "X-API-Key: tg_your_key"

Response

{
  "prime":               "1775225606...",  // Full prime as string (use int() in Python)
  "bits":                2048,
  "method":              "ethoryx_sieve",
  "miller_rabin_tests":  282,              // vs ~836 standard
  "structural_check":   true,
  "generation_ms":       142.3,
  "calls_remaining":     99718,
  "generated_at":        "2026-04-04T20:25:52Z",
  "tier":                "pro",
}

The prime field is returned as a string because large integers exceed JavaScript's safe integer range. Convert with BigInt(data.prime) in JS or int(data["prime"]) in Python.

RSA prime · fast mode

Generates an RSA-ready prime using structural pre-filtering combined with an optimized candidate-selection model. Reduces the expected number of primality tests performed.

GET /v1/generate/rsa requires key

Returns a single RSA-safe prime. The method=fast mode uses our optimized candidate-selection model; method=standard falls back to the Ethoryx Sieve.

ParameterTypeDefaultDescription
bitsinteger2048Key size: 256, 512, 1024, 2048, 4096
methodstringfastfast (optimized) or standard (Ethoryx Sieve)
Response
"prime": "87342...", "layer": "1+3", "miller_rabin_tests": 184, "structural_check": true, "oscillation_law_accuracy": 0.162

Ethoryx NTT · Field Prime

Generates primes satisfying q ≡ 1 (mod ntt_mod), required for Number Theoretic Transform operations in FHE, zk-SNARKs, and custom post-quantum parameter sets. All output is NTT-compatible by construction - no post-filtering needed.

GET /v1/generate/ntt requires key
ParameterTypeDefaultDescription
bitsinteger256Prime size: 256, 512, 1024, 2048, 4096
ntt_modinteger512NTT modulus - must be a power of 2 (2 to 1,048,576). Common: 512, 1024, 4096, 8192, 16384
countinteger1How many primes to return (1–10 free/starter, up to 50 pro+)
Response
"prime": "1152921504...", "ntt_mod": 512, "ntt_compatible": true, "layer": "1+2", "miller_rabin_tests": 35

FHE coefficient modulus chain

Generates a chain of Ethoryx NTT · Field Primes for use as the coefficient modulus in Microsoft SEAL, OpenFHE, or HEAAN. All primes satisfy q ≡ 1 (mod 2n) where n is the polynomial degree. The response includes a ready-to-use SEAL CoeffModulus::Create example.

This endpoint requires Starter tier or above. Each prime in the chain counts as one API call.

GET /v1/generate/fhe Starter+
ParameterTypeDefaultDescription
ninteger4096Polynomial degree: 1024, 2048, 4096, 8192, 16384
countinteger5Primes in chain (1–7 Starter, up to 20 Pro+)
bits_eachinteger55Bits per prime: 50–62. Standard SEAL range.
Response
"primes": ["18014403...", "18014405..."], "seal_compatible": true, "ntt_compatible": true, "usage_example": "seal::CoeffModulus::Create(4096, {55,55,55,55,55})"

Next-prime optimization

Returns the predicted location of the next prime given the most recent prime and the gap that preceded it. Based on a proved oscillation property of prime gaps. Public endpoint no API key required.

This endpoint is free and public. No API key required. Rate limited to 60 requests/minute per IP.

GET /v1/optimize/next no auth
ParameterTypeRequiredDescription
last_primeintegerrequiredThe most recently found prime (must be ≥ 3)
last_gapintegerrequiredThe gap that preceded last_prime; must be an even integer
Response
"predicted_next": 1000033, "predicted_gap": 30, "mean_gap_pnt": 13.8, "direction": "larger", "confidence": 0.682, "structural_predicted": true

RSA key pair

Generates a complete RSA key pair: two independent primes p and q, and the RSA modulus n = p × q. Pro and Enterprise tiers only. Counts as 2 API calls.

GET /v1/generate/rsa-pair 🔑 Pro+ only

Parameters

NameTypeRequiredDescription
bitsintegeroptionalBit length of each prime. One of: 512, 1024, 2048. Default: 2048. The resulting RSA modulus will be approximately 2× this size.

Request

curl "https://api.ethoryx.io/v1/generate/rsa-pair?bits=2048" \
  -H "X-API-Key: tg_pro_key"

Response

{
  "p":                        "172...821",
  "q":                        "198...473",
  "n":                        "p × q - 4096-bit RSA modulus",
  "bits_each":                2048,
  "rsa_modulus_bits":         4096,
  "total_miller_rabin_tests": 564,   // vs ~1672 standard
  "structural_p":               true,
  "structural_q":               true,
  "generation_ms":            298.4,
  "calls_used":               2,
  "calls_remaining":          99716
}

Verify a number

Verifies whether any integer is prime and checks structural compliance. Free for all tiers, no API key required.

GET /v1/verify No auth required

Parameters

NameTypeRequiredDescription
nintegerrequiredThe integer to test. Must be ≥ 2 and ≤ 4096 bits.

Request

curl "https://api.ethoryx.io/v1/verify?n=999983"

Response

{
  "n":               "999983",
  "is_prime":        true,
  "bits":            20,
  "structural_holds":  true,
}

Beat-Cipher Key Generation

Generate deterministic encryption key bits from zeta-zero beat frequency oscillations. Each key bit is computed from the spectral interference between adjacent Riemann zeros as the grid parameter C varies.

POST /v1/cipher/key 🔑 Starter+ only

Request body

NameTypeRequiredDescription
pairstringrequiredZero pair: g4_g5 | g34_g35 | g45_g46 | g1_g2
c_startintegeroptionalStarting grid parameter. Default: 10000
c_stepintegeroptionalStep between C values. Default: 50000
n_bitsintegeroptionalNumber of bits to generate. Max 32. Default: 7

Request

curl -X POST "https://api.ethoryx.io/v1/cipher/key" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: tg_your_key" \
  -d '{"pair":"g4_g5","n_bits":7}'

Response

{
  "key_binary":       "1100111",
  "key_hex":          "e7",
  "key_bits":         [1,1,0,0,1,1,1],
  "R_values": [
    { "C": 10000,  "R": 1.257157, "bit": 1 },
    { "C": 60000,  "R": 3.063578, "bit": 1 }
  ],
  "generation_time_ms": 842.3,
  "engine":             "Ethoryx Spectral Engine"
}

Spectral Anomaly Detection

Analyze any numerical sequence for hidden spectral structure using Lomb-Scargle periodogram combined with matched-filter significance testing. Returns z-scores and peak frequencies against randomized shuffle controls.

POST /v1/spectral/analyze 🔑 Starter+ only

Request body

NameTypeRequiredDescription
sequencearrayrequiredNumerical sequence to analyze. Max 500,000 elements.
n_freqsintegeroptionalFrequency points to evaluate. Max 2000. Default: 500
n_shufflesintegeroptionalShuffle randomization tests. Max 300. Default: 100
log_scalebooleanoptionalUse log(index) as time axis. Default: true

Request

curl -X POST "https://api.ethoryx.io/v1/spectral/analyze" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: tg_your_key" \
  -d '{"sequence":[0.1,0.3,-0.2,0.5,0.1],"n_shuffles":20}'

Response

{
  "n_significant":    21,
  "max_z":            5.01,
  "peak_freqs":       [21.7, 41.4, 49.5],
  "peak_z_scores":    [4.88, 4.74, 3.91],
  "analysis_time_ms": 1432.6,
  "engine":           "Ethoryx Spectral Engine"
}

Account status

GET /v1/account 🔑 X-API-Key required
curl "https://api.ethoryx.io/v1/account" \
  -H "X-API-Key: tg_your_key"
{
  "tier":            "pro",
  "calls_remaining": 99718,
  "calls_used":      282,
  "calls_limit":     100000,
  "max_bits":        2048,
  "rate_limit":      "120 calls/minute"
}

Register

Creates a new account and generates an API key. The key is returned in the response and emailed to the provided address.

POST /v1/auth/register No auth required

Request body (JSON)

FieldTypeRequiredDescription
namestringrequiredYour full name
emailstringrequiredYour email address. Must be unique.
passwordstringrequiredMinimum 8 characters.
planstringoptionalOne of: free, starter, pro, enterprise. Default: free.
curl -X POST "https://api.ethoryx.io/v1/auth/register" \
  -H "Content-Type: application/json" \
  -d '{"name":"Tesfaye","email":"you@example.com","password":"secret123","plan":"free"}'
{
  "message": "Registration successful",
  "token":   "eyJhbGci...",   // JWT for dashboard access
  "api_key": "tg_Abc123...",  // Use this in X-API-Key header
  "user":    { "id": 1, "name": "Tesfaye", "plan": "free" }
}

Login

POST /v1/auth/login No auth required
curl -X POST "https://api.ethoryx.io/v1/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"email":"you@example.com","password":"secret123"}'
{
  "token": "eyJhbGci...",
  "user": {
    "id": 1, "name": "Tesfaye",
    "email": "you@example.com",
    "plan": "free",
    "api_key": "tg_Abc123..."
  }
}

Profile

GET /v1/auth/me 🔑 Bearer token
curl "https://api.ethoryx.io/v1/auth/me" \
  -H "Authorization: Bearer eyJhbGci..."
{
  "user": { "name": "Tesfaye", "email": "...", "plan": "free", "api_key": "tg_..." },
  "account": { "calls_remaining": 98, "calls_limit": 100, "max_bits": 512 }
}

Plans & limits

All plans use the same Ethoryx Sieve algorithm. Higher tiers unlock larger bit sizes, more calls, and faster rate limits.

PlanPriceCalls/monthMax bitsRate limitRSA pairCipherSpectral
Free$01005125/min---
Starter$29/mo10,0001,02430/min-✓ 7-bit-
Pro$99/mo100,0002,048120/min✓ 32-bit
Enterprise$499/moUnlimited4,096600/min✓ 128-bit

HSM and hardware licensing available from $50,000 one-time. Contact us.

Structural verification

Every prime generated by Ethoryx satisfies a proved structural property. This is not a heuristic, it is a formally proved constraint, and every API response confirms compliance via the structural_check field.

Why this matters for performance: Standard prime generation tests a wide pool of candidates, most of which are eliminated by the primality test itself. The Ethoryx Sieve eliminates provably non-prime candidates before any expensive test runs, reducing wasted work.

Why this is secure: The sieve is structure-aware, not content-aware. Every valid prime in the target range remains reachable with equal probability. Output entropy is identical to uniform random prime generation. No prime is excluded, no prime is favored.

Verified: zero violations in 348,511 consecutive samples (covering all primes up to 1,000,000). 100% compliance in all benchmark runs. Every API response includes "structural_check": true.

Research notes: tesfagrid.io · Research programme

Security

Cryptographic randomness

All candidates are seeded from Python's secrets module (OS-level CSPRNG). The pre-filtering only removes impossible candidates - the random start is never predictable.

No timing side-channel

The Ethoryx Sieve uses a constant-time step pattern. Unlike rejection sampling, the number of iterations is independent of the secret candidate value. This eliminates the variable-execution-time timing side-channel present in standard rejection-based generators; relevant for HSM and FIPS compliance environments.

Transport security

All API traffic is encrypted over TLS 1.2+. Certificates are managed by Let's Encrypt and auto-renewed. HTTP requests are permanently redirected to HTTPS.

API key security

API keys are stored hashed in the database. They are only shown once at registration and emailed to you. If you believe your key is compromised, email security@ethoryx.io immediately for rotation.

SDKs & libraries

Python library (open source)

pip install ethoryx

The ethoryx library includes the complete open-source implementation of the Ethoryx Sieve algorithm, all nine proved theorems as callable functions, and the prime generator. Source: github.com/Teshgty/tesfagrid-web

REST API (any language)

The REST API works with any HTTP client. No SDK required. Examples above use cURL, Python requests, and JavaScript fetch. The API returns plain JSON - no special parsing needed.

Future SDKs

Go, Rust, and Java SDKs are planned. Contact us if you need a specific language prioritized.

For C integration with OpenSSL's BN_generate_prime_ex() interface, implementation notes are available to commercial licensees. Contact us for the technical dossier.