Tuesday, November 25, 2025

thumbnail

Building a Quantum Random Number Generator

 1. What Is a Quantum Random Number Generator?


A QRNG produces randomness from a truly quantum process—one that is fundamentally unpredictable even in theory. Common physical sources:


a) Photon Path Splitting (Most Common)


A single photon hits a 50:50 beam splitter.


Output port A → bit = 0


Output port B → bit = 1

The outcome is intrinsically probabilistic.


b) Photon Arrival Time


A weak light source produces photons randomly in time; time-stamping their arrival yields random bits.


c) Vacuum Fluctuations (Homodyne QRNG)


Measures quantum noise in an electromagnetic field. More complex but produces high bit rates.


๐Ÿงฉ 2. The Safest DIY Approach


The easiest and safest way to build a QRNG is using a single-photon–level LED source + beam splitter + two photodiodes.

This does not require lasers or hazardous optical power.


๐Ÿ”ง 3. Hardware Components (Safe, Accessible)

Optics


50:50 non-polarizing beam splitter cube (small 1–2 cm)


Collimating lens (cheap plastic lens is fine)


Light Source


Weak LED (deep blue or near-UV works well)


Neutral density filters to reduce photon flux

(You do not need a coherent laser; incoherent light works if attenuated.)


Detectors


Two silicon photodiodes, e.g. BPW34 or similar


Optional: low-noise transimpedance amplifier (TIA) board


Electronics


Microcontroller or SBC:


Arduino


Raspberry Pi


ESP32


Comparator or ADC (many microcontrollers have built-in ones)


๐Ÿ“ 4. System Architecture

[LED] → [Collimator] → [Beam Splitter] → (Left PD → 0)

                                     → (Right PD → 1)



Each photon detection event sets a bit.


⚙️ 5. Circuit Overview


Since photodiodes output tiny currents, you convert them to voltage:


PD → TIA (op-amp converts current to voltage)


TIA → Comparator (produces digital pulse)


Comparator → Microcontroller GPIO interrupt


Software: Interrupt handler records a “0” or “1”


You need two identical detector channels.


๐Ÿงฎ 6. Software / Firmware


Minimal pseudocode for an Arduino-style device:


volatile uint8_t bit;

volatile bool hasBit = false;


void leftDetector() {

    bit = 0;

    hasBit = true;

}


void rightDetector() {

    bit = 1;

    hasBit = true;

}


void setup() {

    pinMode(LEFT_PIN, INPUT);

    pinMode(RIGHT_PIN, INPUT);

    attachInterrupt(digitalPinToInterrupt(LEFT_PIN), leftDetector, RISING);

    attachInterrupt(digitalPinToInterrupt(RIGHT_PIN), rightDetector, RISING);

    Serial.begin(115200);

}


void loop() {

    if (hasBit) {

        Serial.write(bit);

        hasBit = false;

    }

}


๐Ÿงช 7. Ensuring the Bits Are Truly Random

Bias Correction


Beam splitters and detectors are imperfect. Common fix:


Von Neumann Corrector

Read bits in pairs:


01 → output 0


10 → output 1


00 or 11 → discard


This removes first-order bias.


Statistical Tests


Use:


NIST SP 800-22 Test Suite


Dieharder


TestU01


Look for failures; adjust thresholding and filtering if necessary.


๐Ÿš€ 8. Expected Performance


Bitrate of DIY LED + PD QRNG: 10–100 kbps


With avalanche photodiodes (APDs): Mbps


With homodyne detectors: 100+ Mbps (advanced)


๐Ÿงฑ 9. Building Without Custom Optics


If optical alignment is challenging, consider:


๐Ÿ’ก Alternative: Quantum Shot-Noise QRNG Using a Photodiode Only


Shine a steady LED on a photodiode, amplify the signal, and digitize very small fluctuations caused by quantum shot noise.

This avoids alignment entirely and works well for educational purposes.


๐Ÿ“ฆ 10. Off-the-Shelf QRNG Modules


If you want quantum randomness without building optics:


ID Quantique Quantis USB


Quside QN400


ON Semiconductor J-Series APD breakout boards + open source QRNG code


These are plug-and-play.

Learn Quantum Computing Training in Hyderabad

Read More

How to Simulate Quantum Circuits Using Qiskit

Step-by-Step Tutorial: Implementing Grover’s Algorithm

Bonus: Deep Dives & Tutorials

Quantum Computing Myths Debunked

Visit Our Quality Thought Training Institute 

Get Directions

Subscribe by Email

Follow Updates Articles from This Blog via Email

No Comments

About

Search This Blog

Powered by Blogger.

Blog Archive