Quantum-Safe Optical Latency

Official documentation for physics-based MITM detection using the speed of light on Cloudflare Workers.

Explore

01 GUIDE

Start with PhotoAuth

Quantum-Safe Optical Latency detects MITM attacks using the speed of light in fiber — open the dashboard and run your first probe in under a minute.

Deploy the Worker, open the Global Radar Dashboard, and watch live verdicts. Every request is triangulated against three edge nodes and scored against a physical baseline.

1

Open the dashboard

Load quantum-safe-dashboard.html. Status chip shows ● LIVE when the Worker responds.

2

Run a probe

Refresh or wait for auto-probe (every 8s). Verdict, risk score, and map update together.

3

Read the result

SAFE_HUMAN or HACKER_DETECTED_MITM with measured RTT, baseline, and variance.

Rule: Keep the Worker URL correct in the dashboard script — CORS and live data depend on it.

Start PhotoAuth

02 GUIDE

Physics baseline

Light in fiber travels at ~0.67c. Distance sets a hard minimum RTT — anything slower is suspect.

We compute geographic distance (haversine), convert to fiber time, add routing buffer, and compare measured RTT. Extra latency from proxies or MITM creates a variance spike.

1

Distance → time

Baseline ≈ (km × 2) / (0.67 × c) plus a small routing buffer in milliseconds.

2

Triangulation

Three random global nodes measure RTT; average and max delta feed the anomaly score.

3

Verdict

If variance exceeds the safe buffer → HACKER_DETECTED_MITM; otherwise SAFE_HUMAN.

Rule: Physics sets the floor — software cannot travel faster than light in fiber.

Physics baseline

03 GUIDE

API endpoint

One endpoint powers the dashboard and SDK — GET /api/check returns verdict, deltas, nodes, and metadata.

Call the Worker from any origin (CORS enabled). Response includes verdict, avgDeltaMs, varianceScore, selectedNodes, and more.

GET https://temp-latency.mmunasinghesos.workers.dev/api/check
1

Call /api/check

GET only. OPTIONS is handled for preflight. Health: /health.

2

Parse JSON

Use verdict, varianceScore, measurements, clientCountry, colo.

3

Log to D1

Worker writes each check asynchronously — dashboard reads live history.

Rule: Always send CORS headers from the Worker or browsers will block the dashboard.

API endpoint

04 GUIDE

Dashboard

Global radar map, live verdict banner, risk bar, latency chart, logs, and SDK installer in one Google-clean UI.

Header chips show LIVE status, country, risk, and session probes. Dark mode, docs link, and force-refresh are always available.

1

Read the verdict

Green SAFE_HUMAN or blinking red HACKER banner with measured / baseline / variance / risk.

2

Watch the chart

Baseline stays flat; measured line spikes red on MITM. Timeline bars mark threats.

3

Export or fullscreen

CSV / JSON export and fullscreen radar that copies the live mesh.

Rule: Mobile uses bottom nav (Map · Status · Logs · SDK) — desktop layout stays two-column.

Dashboard

05 GUIDE

Risk score

Risk 0–100 blends variance, anomaly flag, time-of-day, proxy confidence, Tor, and high-risk ASN signals.

Green bar = low risk, orange mid, red high. Extra intel line shows Proxy %, Tor, ASN, unusual hour, multi-hop.

1

Base from variance

Score starts from variance × 1.8, capped 0–100. HACKER verdict floors at 72.

2

Add signals

2–5 AM traffic, Tor ASN, known hosting ASN, and multi-hop delta boost risk.

3

Learn baselines

Per-country baseline is smoothed in localStorage and shown as “Learned XXms”.

Rule: High risk does not always mean block — use it with verdict and context.

Risk score

06 GUIDE

Map & mesh

Three edge nodes form a live triangle. User or threat marker, animated packet paths, and optional heatmap dots.

Street / Satellite / Light layers. Fullscreen radar copies the same mesh so you never see an empty map.

1

Icons

computer = edge · server_person = you · threat_intelligence = threat.

2

Animated mesh

Dashed triangle edges scroll continuously; packet paths run user → nodes.

3

Node health

Cards under the chart show Online / Degraded and approximate ms per node.

Rule: Use free OSM / Esri tiles only — no API key required.

Map and mesh

07 GUIDE

Logs & export

Live table of every probe — time, country, measured, baseline, variance, risk, verdict. Click a row for full detail.

Worker also writes to D1 so history survives reloads. Export CSV or JSON anytime.

1

Read the stream

Newest first. SAFE / HACKER badges and color-coded risk.

2

Drill-down

Click any row → modal with full timestamp, numbers, and verdict.

3

Export

CSV and JSON buttons download the current in-browser history.

Rule: D1 schema must match the Worker INSERT or logs will fail silently.

Logs and export

08 GUIDE

SDK installer

One package and one middleware line to protect any site with the same physics check.

Copy from the dashboard SDK card or use the snippets below. Point endpoint at your Worker.

npm install lightshield-sdk
import { lightshield } from "lightshield-sdk";
app.use(lightshield({ endpoint: "https://YOUR_WORKER.workers.dev/api/check" }));
1

Install

Add the package to your Node / Edge project.

2

Wire middleware

Place it early so every request is checked before your handlers.

3

Act on verdict

Block, challenge, or log when verdict is HACKER_DETECTED_MITM.

Rule: Always use your own Worker URL — never hard-code a demo subdomain in production.

SDK installer

09 GUIDE

Security

CORS, security headers, Durable Objects, free-plan migrations, and threat signals that harden the system.

Worker returns Access-Control-Allow-Origin: *, nosniff, DENY frame, no-store cache. Durable Object uses new_sqlite_classes for free plan.

1

CORS + headers

Handle OPTIONS; attach CORS and security headers on every response.

2

Durable Object

Migration tag with new_sqlite_classes = ["LatencyMesh"] for free plan.

3

Threat signals

Proxy confidence, Tor ASN, bad ASN, multi-hop, and unusual-hour flags enrich the score.

Rule: Never expose secrets in the dashboard — only public Worker URLs and read-only verdicts.

Security