Alice → photon
Bob receiver
Eve (active)
Kept (sifted)
| # | Alice bit | Alice basis | Eve basis | Bob basis | Bob bit | Result |
|---|
| # | Alice bit | Alice basis | Eve basis | Bob basis | Bob bit | Result |
|---|
This simulator runs the real BB84 protocol bit by bit: Alice picks a random bit and a random polarization basis for every photon, Bob measures each one in his own randomly chosen basis, and the two sides publicly compare only their basis choices to sift out a shared secret key. Turn on the eavesdropper to watch an intercept-resend attack push the quantum bit error rate up to roughly 25% — the same statistical fingerprint that lets real QKD hardware detect a listener on the line without ever transmitting the key itself.