Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Quantum Key Distribution (BB84)

Features

  • Simulates BB84 with random bit and basis generation for Alice and Bob.
  • Detects eavesdropping by analyzing error rates in a sampled subset.
  • Runs multiple trials to compute average key length and detection rates.

How It Works

  1. Alice generates random bits and bases (rectilinear or diagonal).
  2. Eve may intercept qubits with a given probability, introducing errors.
  3. Bob measures qubits in random bases.
  4. Alice and Bob publicly compare bases, keeping bits where bases match.
  5. A sample of bits is checked for errors to detect eavesdropping.
  6. Remaining bits form the shared key.

Usage

Run a Single Simulation

from qkd_simulator import quantum_key_distribution

n = 8  # Number of qubits
eavesdrop_prob = 0.3  # Eavesdropping probability
key, detected = quantum_key_distribution(n, eavesdrop_prob)
print(f"Shared key: {key}, Eavesdropper detected: {detected}")

Run Multiple Simulation

from qkd_simulator import simulate_qkd

trials = 100
n = 8
eavesdrop_prob = 0.3
simulate_qkd(trials, n, eavesdrop_prob)

Requirements

  • Python 3.x
  • No external libraries required (uses random and statistics from the standard library)

About

A Python-based simulator for the BB84 quantum key distribution protocol, including eavesdropping detection and performance analysis over multiple trials.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages