Quantum Key Distribution Simulator (2D)

This 2D simulator recreates the BB84 quantum key distribution protocol: Alice encodes random bits onto photons using a randomly chosen polarization basis, Bob measures each photon in his own random basis, and only the bits where their bases happen to match survive public sifting into a shared secret key. Toggling an eavesdropper (Eve) onto the channel shows how the no-cloning theorem forces her interception to introduce a measurable quantum bit error rate β€” climbing toward 25% and triggering detection β€” while disabling basis randomization demonstrates the opposite failure mode: a predictable, non-random basis lets Eve intercept the entire key with zero detectable error.