Quantum Builders ClubQuantum computing projects

Project 03 · Ladder 1 · Beginner

Quantum Random Number Generator: build it, then try to break it

How it works

  1. A fair quantum source: every bit is a fresh measurement, and the randomness tests pass.
  2. Now a rigged source that gives 70% ones. The tests catch it and fail.
  3. Von Neumann extraction throws bits away until the rest are fair. The tests pass again.

Quantum randomness has already left the lab. Build your own quantum random number generator, test it the way professionals test theirs, then try to break it.

Start my 7-day free trialSee all ten builds

Level
Beginner
Hours
4 to 6
Automated tests
18
Ships to
GitHub

What you build

Quantum Random Number Generator in Python and Qiskit

In March 2025 JPMorganChase and Quantinuum reported in Nature that they had used a 56-qubit quantum computer to generate random numbers, then used classical supercomputers to certify at least 71,313 bits of entropy. Five years earlier SK Telecom and Samsung had already launched a 5G phone with a quantum random number chip inside, 2.5 mm across. Banks and phone makers care about this, and now you build your own.

Your QRNG is a Python library you use like Python's own random module: dice rolls, floats, bytes and raw bits. It comes with a command-line report that puts several generators through tests from the NIST SP 800-22 randomness test suite, catches a deliberately broken generator red-handed, and repairs it.

The quantum ideas inside

  • Quantum randomness
  • NIST SP 800-22
  • Monobit and runs tests
  • Randomness extractors
  • Entropy

New to Qiskit? Run your first circuit free, or warm up with the free Qiskit tutorials.

Real output · Project 03Qiskit Aer simulator

python quantum_rng.py --bits 100000 --seed 7 --plot qrng_results.png
Dice roll: 6 | float: 0.678621 | 8 bytes: b60f5d66dcf4941e

Quantum (fair) (100000 bits, 0.499 ones)
  monobit              0.7422  [p >= 0.01]  PASS
  runs                 0.1494  [p >= 0.01]  PASS
  byte_chi_square    222.9133  [chi2 < 330.52]  PASS

Flawed source, 70% ones (100000 bits, 0.699 ones)
  monobit              0.0000  [p >= 0.01]  FAIL
  runs                 0.0000  [p >= 0.01]  FAIL
  byte_chi_square  28393.8496  [chi2 < 330.52]  FAIL

Flawed source after Von Neumann extraction (21000 bits, 0.502 ones)
  monobit              0.6291  [p >= 0.01]  PASS
  runs                 0.7106  [p >= 0.01]  PASS
  byte_chi_square    255.1707  [chi2 < 330.52]  PASS
What your finished program prints, from the build's own guide.

By the end

What you walk away with

  • a reusable QRNG library (bits, integers, floats and bytes) running on IBM's open-source Qiskit Aer simulator
  • two statistical tests from NIST's suite that you write and check against the worked examples in NIST's own document, plus a ready-made byte test
  • a flawed "70% ones" device that your tests catch, and a randomness extractor that repairs it
  • a three-panel chart that lets you see randomness and bias
  • 18 automated tests, one extension that is all yours, and a public GitHub repo

Where it sits

Ladder 1: Beginner

BeginnerLadder 1

  1. Quantum Coin Flip

    One qubit, proven fair with real statistics.

    18 tests · 2 to 4 hours

  2. Quantum Dice Roller

    Catch a loaded die red-handed.

    16 tests · 3 to 5 hours

  3. Quantum Random Number Generator

    Build it, then try to break it.

    18 tests · 4 to 6 hours

  4. Quantum Password Generator

    Its strength, measured in bits.

    17 tests · 4 to 6 hours

Your first circuit is 10 minutes away

Stop watching quantum. Start shipping it.

Start my 7-day free trial

$0 today. 7 days free, then $7.99 a week or $190 a year. Cancel any time.

Detail C · A qubit's state