Skip to content

aryannverse/Quantum-Lottery-System-using-Grovers-Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quantum Lottery System using Grover's Algorithm

This project simulates a lottery where the winning number is generated with quantum randomness and then found efficiently using Grover's Algorithm.

Project Workflow (Step-by-Step)

Step 1: Define the idea of the system

This system first creates a quantum-generated winning number. Instead of checking all possible numbers one by one (classical brute force), it uses Grover's Algorithm to find the winning number efficiently in an unsorted search space.

Step 2: Create the lottery number using quantum randomness

A random number is generated using quantum superposition:

  • Hadamard (H) gates are applied to all qubits.
  • Each qubit enters a state that can represent both 0 and 1.
  • After measurement, a random binary string is produced.

That measured string becomes the winning lottery number.

Example for 2 qubits: possible outputs are 00, 01, 10, 11.

Step 3: Define the search space

All possible qubit combinations are treated as an unsorted database.

For n qubits, total possible values are:

  • 2^n

The quantum-random winning number is one of these values and is the target to be searched.

Step 4: Apply Grover's Algorithm

Grover's search uses two core components:

  1. Oracle
  • Marks the target (winning number) by phase inversion.
  • This tags the correct state.
  1. Diffusion Operator
  • Amplifies the marked state's amplitude.
  • Decreases amplitudes of non-target states.
  • This is amplitude amplification.

Step 5: Perform iteration (Grover iteration)

One Grover iteration = Oracle + Diffusion.

  • For small systems (for example, 2 qubits), one iteration is often enough.
  • Larger systems require more iterations to maximize success probability.

Step 6: Measurement and result

After Grover iterations, the circuit is measured. Because the target state's probability is amplified, it appears most frequently in outcomes.

Step 7: Output visualization

Results are shown as a histogram. The winning number should have the tallest bar.

Step 8: Working summary

  1. Generate random winning number via quantum superposition.
  2. Build Grover search over full unsorted space.
  3. Amplify the winning state's probability.
  4. Measure and observe the winner with high frequency.

Step 9: Technology used

  • Python
  • Qiskit
  • Qiskit Aer simulator
  • Matplotlib
  • Tkinter interface (desktop UI)

Step 10: Applications of the project

  • Secure random number generation
  • Quantum search systems
  • Cryptography concepts
  • Optimization problems

Step 11: Conclusion

This project demonstrates how quantum computing can reduce search effort in large unsorted spaces. It highlights Grover's Algorithm's advantage over classical search and shows how quantum randomness can be used in lottery-like applications.

Setup

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Run

python3 quantum_lottery.py --qubits 2 --shots 2048

Run Tkinter UI

python3 quantum_lottery_tk.py

Output

The script prints:

  • quantum-random winning number
  • Grover iteration count
  • measured most frequent result
  • whether the measured top result matches the winning number

It also saves:

  • grover_lottery_histogram.png

About

This project simulates a lottery where the winning number is generated with quantum randomness and then found efficiently using Grover's Algorithm.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages