Quantum RNG β 5-source provider registry Β· CURBy + ANU + NIST Beacon + hardware + audit Β· NIST SP 800-22 tier-1+ audit
quantum Β· entropy Β· CURBy Β· ANU Β· NIST Beacon Β· hardware QRNG Β· NIST SP 800-22 Β· audit Β· provider registry Β· n=6 Β· dancinlab
qrng is a provider-side registry of quantum random byte sources. It does
not itself amplify entropy (no HMAC-DRBG, no NIST SP 800-90A constructions
β those belong to consumer packages). It returns raw bytes from one of 5
backends with a uniform QrngBytes struct + provenance message.
Note
Sister package of qmirror (quantum
mirror substrate Β· consumer-side HMAC-DRBG amplifier), and member of the
dancinlab HEXA family (parent: dancinlab/echoes).
Provider/consumer boundary deliberate β zero code overlap, struct-shape
compatible. See Β§"Boundary: qrng (provider) vs qmirror.qrng (consumer)".
let r = qrng_audited_bytes(1024, "tier1+", "anu_legacy")
// r.ok : 0/1
// r.bytes_hex : hex string
// r.audit_pass : 0/1 (1 iff every non-skipped test passed)
// r.tests_run : [AuditTestResult] β 5 entries (name, p_value, passed, skipped, note)
// r.audit_level_requested : "tier1+" | "none"
// r.audit_level_delivered : "tier1+" | "tier1-partial" | "tier1-none" | "none"
// r.tier : "T0" | "T1" | "T3" | ...
// r.vendor : resolved backend label
// r.alpha : 0.01 (NIST default)
// r.message : provenance string
Five backends shipped today:
| Tier | Name | Vendor | is_quantum | is_local | Cost | Throughput |
|---|---|---|---|---|---|---|
| T0 | mock_qrng |
deterministic LCG | 0 | 1 | $0 | 1 GB/s |
| T1 | curby |
NIST + CU Boulder (Bell-test) | 1 | 0 | $0 | 8.5 bps (60s/pulse) |
| T1 | anu |
qrng.anu.edu.au | 1 | 0 | $0 | 1 KB/s (1 req/min throttled) |
| T1 | nist_beacon |
NIST (ECDSA-signed mixed entropy) | 0 | 0 | $0 | 8.5 bps (60s/pulse) |
| T3 | hardware_qrng |
IDQ Quantis PCIe / ESP32 serial | 1 | 1 | $5000 (PCIe) / $10 (ESP32) | 240 MB/s (PCIe) |
Honest C3 note:
nist_beaconisis_quantum=0because it's vendor- classified as mixed entropy (HSM + multiple RNGs, possibly QRNG-augmented). Use as US sovereign sibling to ANU (AU) when geographic diversity matters.hardware_qrngisis_quantum=1by vendor assertion (IDQ's NIST SP 800-90B health checks + ESP32 ADC noise) β independent NIST validation NOT performed by this package.
- v1.1.0 (2026-05-07) β integrated NIST SP 800-22 tier-1+ statistical
audit via single-stage
qrng_audited_bytes(n_bytes, audit_level, vendor)API (Boltz-2 paradigm absorption β entropy + audit + verdict in one call). Five tests: monobit, frequency-block, runs, longest-run, DFT spectral. Seeaudit/module/audit.hexa. - v1.0.0 (2026-05-04) β initial standalone release; 5 backends + 4 abstraction modules; tests scaffolded fresh; dual-home boundary doc published.
- 5 backends (T0/T1Γ3/T3) Β· 4 abstraction modules Β· 1 integrated audit
- Pure HEXA β raw9 strict; no
.pyin the runnable surface - 6 external consumers (anima / anima-physics / anima-eeg / nexus stub) refactor staged
- Parent:
dancinlab/echoes(HEXA family canonical)
Twine-blockchain anchored Bell-inequality-violation pulses (loophole-free
Bell test protocol). Free, no auth, 8.5 bps sustained (512 bits per
60-second pulse). twine_anchor field MUST be non-empty on live pulses
(falsifier F_CURBY_03).
QRNG_LIVE=1 qrng collect --source curby --bytes 64Public REST (https://qrng.anu.edu.au/API/jsonI.php) returning uint8 arrays
sampled from quantum vacuum fluctuations. Free legacy tier 1 req/min;
chunks > 1024 bytes require pacing (use qrng collect with chained chunks).
QRNG_LIVE=1 qrng collect --source anu --bytes 128NIST Randomness Beacon 2.0 (beacon.nist.gov/beacon/2.0/pulse/last).
Mixed-entropy (HSM + RNG composite, possibly QRNG-augmented β vendor
self-classifies). Use as US sovereignty mirror to ANU when geographic
diversity proof is required. ECDSA signature MUST be present (F_NIST_03).
Probes /dev/quantis* (IDQ Quantis PCIe/USB SDK), then
/dev/cu.usbmodem* / /dev/cu.usbserial* (ESP32 / FTDI bridges). Live path
requires QRNG_HW_LIVE=1; default is mock-mode (deterministic LCG byte-
identical to mock_qrng).
s = (1664525 Γ s + 1013904223) mod 2^32. Same --seed β same bytes
byte-identical across runs. CI default; safety net for the router chain.
Single-stage API that pulls entropy + runs NIST SP 800-22 tier-1+ statistical audit + returns ok/fail in one call (Boltz-2 paradigm absorption). Eliminates the "did the caller actually audit?" failure mode.
Five tests (NIST SP 800-22 Β§2.1, Β§2.2, Β§2.3, Β§2.4, Β§2.6):
| Test | Min bits | Notes |
|---|---|---|
| monobit | 100 | frequency / proportion of ones |
| frequency_block | 2560 | M=128 N>=20; chi-square upper tail |
| runs | 100 | gated by monobit pre-check |
| longest_run | 6272 | M=128 K=5 N=49; class boundaries [<=4..>=9] |
| dft_spectral | 1000 | O(n^2) DFT, capped at 1024 bits (FFT deferred β see caveat 3) |
Audit downgrade is automatic and labelled: a 64-byte (512-bit) pull with
audit_level="tier1+" returns audit_level_delivered="tier1-partial" with
monobit + runs running and the other three tests skipped with reason
notes. audit_pass aggregates only the tests that actually ran (alpha=0.01).
hexa run audit/module/audit.hexa
QRNG_LIVE=1 hexa run audit/module/audit.hexa # +ANU legacy live exerciseSelftest evidence:
- pathological all-zeros fixture: audit FAIL (monobit p β 0; distinction proof)
- mock LCG (n=128 bytes = 1024 bits): audit PASS (3/5 tests run; LCGs are statistically OK on short windows β caveat 4)
- ANU legacy live (n=64 bytes = 512 bits): audit PASS (monobit + runs run)
Two repositories share the qrng name across different roles. Zero code
overlap, but the API surface is dual-homed.
| Repo | Surface | Role |
|---|---|---|
qrng (this) |
<feature>/module/<feature>.hexa for {anu,curby,nist_beacon,hardware_qrng,mock_qrng} + abstraction triplet {source,registry,router,qrng_main} |
Provider registry β 5 backends + dispatch + router |
qmirror |
modules/qrng.hexa (single file) |
Consumer drop-in β HMAC-DRBG amplifier exposed as qmirror qrng <bits> |
They share the QrngBytes and QrngSourceMeta struct shapes by convention
(both packages declare them locally; no shared import). Sentinel namespaces
are disjoint (__QRNG_* vs __QMIRROR_QRNG__). Env var namespaces are
disjoint (QRNG_* / NEXUS_QRNG_* vs QMIRROR_* / NEXUS_QMIRROR_*).
Future qmirror v3.0.0 may declare qrng = "^1.0.0" as a runtime dependency
to consolidate the entropy pipeline; until then, each operates independently.
Full rationale + falsifiers in docs/dual_home_boundary.md.
The nexus/core/qrng/ Option D split is preserved verbatim. The router
resolution order (default chain curby β anu β nist_beacon β hardware_qrng β mock_qrng) is overridable via env:
QRNG_SOURCE=<name>β pin to single backendQRNG_FALLBACK_CHAIN=a,b,cβ comma-sep custom chain
Both legacy (NEXUS_QRNG_*) and forward (QRNG_*) env namespaces are
honoured; legacy is load-bearing for backward compat with the upstream
nexus origin.
# 1. Install hexa-lang (gives you `hexa` + `hx` package manager)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/dancinlab/hexa-lang/main/install.sh)"
# 2. Install qrng
hx install qrngSystem deps (assumed present on macOS / Linux): curl, xxd,
shasum/sha256sum, timeout. The mock_qrng backend (CI default)
needs none of these.
qrng status # registry table + tier coverage
qrng collect [--bytes=N] [--seed=S] [--source=NAME] # pull random bytes via router fallback
qrng selftest # full provider sweep (12 sentinels: 9 backends + 3 abstraction)
qrng chain # show resolved router fallback chain
qrng meta --backend=NAME # print backend metadata
qrng --version # show version
qrng --help # full usage
# integrated audit (entropy + NIST SP 800-22 + verdict in one call):
hexa run audit/module/audit.hexa
QRNG_LIVE=1 hexa run audit/module/audit.hexa # +ANU legacy live exercise
# examples (examples/):
hexa run examples/01_quick_collect.hexa # pull bytes via default router chain
hexa run examples/02_qrng_for_ml_seed.hexa # quantum-seeded ML training pattern
hexa run examples/03_router_fallback_demo.hexa # show router attempt/reason chainEnv vars:
QRNG_ROOT override repo root (default: inferred from $0)
QRNG_LIVE 1 β enable live network paths (default: gated mock)
QRNG_MOCK 1 β force mock LCG fixture (CI-safe)
QRNG_SOURCE pin to single backend (skips fallback chain)
QRNG_FALLBACK_CHAIN comma-sep custom fallback chain
QRNG_HW_LIVE 1 β hardware_qrng live serial/PCIe path
QRNG_HW_MOCK 1 β hardware_qrng mock fixture
QRNG_HW_TIMEOUT_S serial read timeout in seconds (default 5)
legacy aliases (load-bearing):
NEXUS_QRNG_LIVE / NEXUS_QRNG_MOCK / NEXUS_QRNG_SOURCE
NEXUS_QRNG_FALLBACK_CHAIN / NEXUS_QRNG_HW_*
ANIMA_QRNG_MOCK (anima-side consumer alias)
qrng/
βββ README.md # this file
βββ LICENSE # Apache-2.0
βββ CHANGELOG.md
βββ CITATION.cff
βββ AGENTS.tape # identity + governance (.tape v1.2)
βββ CLAUDE.md # β AGENTS.tape (Claude Code auto-discovery)
βββ hexa.toml # package manifest
βββ install.hexa # hx install hook (system dep check + selftest)
βββ source/module/source.hexa # abstract interface contract (QrngBytes / QrngSourceMeta)
βββ registry/module/registry.hexa # 5-backend dispatch table + canonical names
βββ router/module/router.hexa # config-driven backend selection + fallback chain
βββ qrng_main/module/qrng_main.hexa # aggregator + selftest entry-point
βββ audit/module/audit.hexa # NIST SP 800-22 tier-1+ statistical audit + qrng_audited_bytes()
βββ mock_qrng/module/mock_qrng.hexa # T0 deterministic LCG
βββ anu/module/anu.hexa # T1 ANU vacuum-fluctuation REST
βββ curby/module/ # T1 NIST + CU Boulder Bell-test
β βββ curby.hexa
β βββ fixtures/curby_pulse_sample.json
βββ nist_beacon/module/ # T1 NIST Beacon 2.0 ECDSA-signed
β βββ nist_beacon.hexa
β βββ fixtures/nist_beacon_pulse_sample.json
βββ hardware_qrng/module/hardware_qrng.hexa # T3 IDQ Quantis / ESP32 serial
βββ cli/qrng.hexa # CLI router (5 subcmds)
βββ tests/ # 7 smoke tests (one per backend + router + registry)
βββ examples/ # 3 example scripts
βββ docs/ # cross-cutting docs (dual_home_boundary.md, logo.svg)
βββ state/ # gitignored runtime markers
# Layout: feature-grouped triplet β each <feature>/ has {core?, module/, doc/} (singular).
# core/ is optional and absent for module-only features.
- Dual-home boundary risk with
qmirror.qrngβ qmirror'smodules/qrng.hexais a consumer-side HMAC-DRBG amplifier API drop-in (NO code overlap) while THIS package is the 5-source provider registry. Future qmirror v3+ may declare qrng as a runtime dependency to unify entropy sourcing. Seedocs/dual_home_boundary.md. - 6 external consumers (
anima/.roadmap.qrng+ 3 anima-physics files + anima-eeg +nexus/core/qrngprovider stub) require refactor to point at standalone path; refactor staged for user review (NOT auto-applied). - Tests scaffolded fresh at extraction β phase 2 audit found NO
tests/subdir in nexus origin (modularity 2β1 demotion). Coverage is tier 1 (sentinel-pass per backend); deeper property-based tests deferred. - ANU rate-limit + ToS evolution β public REST is throttled to 1 req/min
on T1.a legacy tier; ToS / redistribution terms may evolve. Mock LCG
fallback always available with
QRNG_MOCK=1. - License audit deferred to follow-up cycle β qrng core is Apache-2.0 (clean), but per-vendor data-rights for ANU / CURBy / NIST Beacon byte redistribution NOT formally audited. This package returns bytes to the caller; it does not redistribute. Callers re-publishing returned bytes should consult vendor ToS independently.
qrng is the 6th publishable HEXA-family package. The full set:
| Package | Version | Repo | Description |
|---|---|---|---|
| qmirror | 2.0.0 | https://github.com/dancinlab/qmirror | Quantum mirror substrate (CHSH/IIT/NIST) |
| sim-universe | 1.0.0 | https://github.com/dancinlab/sim-universe | Virtual universe runtime + Bostrom test |
| hexa-bio | 1.0.0 | https://github.com/dancinlab/hexa-bio | Molecular toolkit on n=6 lattice |
| honesty-monitor | 1.0.0 | https://github.com/dancinlab/honesty-monitor | AI honesty-bit falsifier |
| anima-agent | 1.0.0 | https://github.com/dancinlab/anima-agent | Ξ¦-gated autonomous agent runtime |
| qrng | 1.1.0 | https://github.com/dancinlab/qrng | 5-source QRNG provider registry (this) |
Extracted from the nexus repo on
2026-05-04 after phase 2 audit verdict extract_standalone_qrng_repo_with_caveats
(rank 7, score 7). Upstream provenance:
nexus/modules/qrng/(5 backends, 1047 LoC)nexus/core/qrng/(4 abstraction modules, 546 LoC)- Total: 1593 LoC migrated
Apache-2.0 β Copyright 2026 λ°λ―Όμ° nerve011235@gmail.com.
Per-vendor entropy sources carry their own data-rights regimes:
| Backend | Data rights | Notes |
|---|---|---|
mock_qrng |
Apache-2.0 (qrng core) | LCG arithmetic β no third-party data |
anu |
ANU ToS | Free public REST; user-of-record is the caller |
curby |
NIST + CU Boulder ToS | Bell-test pulses; Twine anchors public |
nist_beacon |
NIST public domain | US-government work; ECDSA-signed |
hardware_qrng |
Vendor SDK terms (IDQ libQuantis) | Local hardware; no redistribution |
Optional Python aux deps (none today) would ship under their own licenses; in-process safe (no copyleft). qrng core stays Apache-2.0 under FSF MereAggregation.