Quantum Random Number Generation

Production-grade guide to quantum random number generation covering architecture patterns, implementation strategies, testing approaches, and operational best practices for enterprise engineering teams.

Quantum Random Number Generation

Quantum random number generation harnesses quantum mechanical phenomena—such as photon detection events, vacuum phase fluctuations, or tunneling currents—to produce bit sequences that are, by definition, unpredictable by any classical algorithm. If your work requires cryptographic‑grade unpredictability, simulation seed independence, or scientific sampling without statistical leakage, a true random source is mandatory; pseudo‑random number generators (PRNGs) fail these checks because their output is deterministic given the same seed. This page covers the engineering pathways to obtain, integrate, and troubleshoot quantum random numbers without vendor‑specific mechanics locked into the exposition.

Generate a one‑shot block of quantum random bits

Many cloud quantum‑random‑number services expose a REST endpoint that returns a JSON payload containing a bit string of the requested length. The typical client flow is: obtain an authentication token from the provider’s console, send a POST or GET with the desired bit length, and parse the returned data. Most providers use a bearer token issued after account registration; the exact header name and token acquisition flow differ, but the HTTP pattern is consistent.

Example: fetching 256 bits from a public ANU QRNG instance

curl -sS "https://qrng.anu.edu.au/API/json?length=256" \
  -H "Accept: application/json"

The command uses only real flags (-sS for silent but show errors, -H for custom headers). The query parameters (length, type) are documented by the service; other providers may use different parameter names or a POST body instead of query strings, but the overall structure—curl with an Accept or Authorization header, a JSON‑compatible request, and a JSON response—remains the same.

Parsing the output

curl -sS "https://qrng.anu.edu.au/API/json?length=256" | jq -r '.data[]'

jq is a standard tool; -r strips the surrounding quotes so the raw byte values are printed. If the service returns an array under a different key, adjust the filter accordingly. A 401 Unauthorized response means the token is missing or expired; a 429 Too Many Requests indicates rate‑limiting, which some public instances enforce per IP or per API key.

Typical error text you may encounter

Stream quantum‑derived entropy into a classical system

When you need a continuous source of quantum‑derived randomness for seeding operating‑system cryptographic pools, hardware QRNG devices present a character device under Linux. The rng-tools package reads from that device and mixes the entropy into the kernel’s CSPRNG.

Loading a USB or PCIe QRNG device

sudo rngd -r /dev/hwrng -o /dev/urandom

If the device is not present or not readable, rngd emits a diagnostic:

rngd: error while reading from /dev/hwrng: Input/output error

Typical causes: the device is not plugged in, lacks firmware, or the current user does not have read permission (remedy with sudo or chmod 666 /dev/hwrng).

Software fallback when no hardware is attached

haveged -w 1024

haveged uses processor cycle timing jitter to generate entropy. It is not quantum, but it serves as a stop‑gap when hardware QRNG is unavailable. Start it as a system service (systemctl start haveged) or run it in the background.

Sharp edges

Prototype quantum random number generation with Qiskit

Qiskit provides a programmable interface to IBM Quantum backends. The same circuit‑execution pattern used for algorithm prototyping also yields measurement outcomes that, on a real quantum processor, are influenced by quantum noise—making them suitable for QRNG prototyping. The code below is standard Qiskit; it does not reference any IBM‑specific config keys or UI elements.

from qiskit import QuantumCircuit, execute, Aer


qc = QuantumCircuit(1, 1)
qc.h(0)
qc.measure(0, 0)

# Execute on a simulator that records shot counts (replace with a hardware backend for true QRNG)
job = execute(qc, Aer.get_backend('qasm_simulator'), shots=1024)
result = job.result()
counts = result.get_counts(qc)

# Extract the most frequent outcome as a random bit string
bit_string = max(counts, key=counts.get)
print(f"Generated bit string (simulated): {bit_string}")

Common failure modes in this pattern

Sharp edges and failure modes you only learn after it breaks in production

SymptomLikely causeQuick check
curl returns 403 Forbidden to the QRNG APIMissing or expired bearer tokenRenew the token from the provider’s console; ensure the Authorization header format matches the spec (typically Bearer <token>).
rngd logs entropy drain and urandom stallsDevice entropy rate < consumer demandReduce read frequency, or add a second QRNG device; monitor /proc/sys/kernel/random/entropy_avail.
Qiskit job times out after the default 5‑minute limitBackend queue depth or shot count too highRequest a higher timeout via the runtime service, or reduce shots to the minimum needed for statistical sufficiency.
Bit‑string distribution shows repeated patterns even on hardwareCalibration drift or mis‑configured readoutRun a quick tomography job; if the bias persists, recalibrate the backend or switch to a different device.
JSON payload from the API has an unexpected shapeAPI version mismatchCheck the service’s documentation for the current version; adjust query parameters or Accept headers accordingly.

When any of these occur, the failure is usually silent in the sense that the program does not crash—it simply produces weak or biased randomness, which may go undetected until cryptographic tests (e.g., dieharder, statistical test suite) flag the output.

Platforms in this space (bare list, no mechanism attached)

This page was rewritten on 13 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.