This project implements the BB84 Quantum Key Distribution Protocol in Go. It is fully containerized using Docker, allowing easy setup and execution in any environment.
- BB84 Quantum Key Distribution Protocol: Simulates the BB84 protocol for secure key exchange between two parties.
- Dockerized Application: Run the application with Docker and Docker Compose without worrying about setup or dependencies.
- Secure Communication: Simulates quantum key distribution for encryption and decryption of messages.
The BB84 protocol, introduced in 1984 by Charles Bennett and Gilles Brassard, is a quantum key distribution (QKD) protocol. It enables two parties to generate a shared encryption key securely, even in the presence of an eavesdropper.
Key concepts:
- Qubits and Bases: Alice encodes bits using two types of bases (Z basis and X basis). Bob measures them using randomly chosen bases.
- Transmission: Qubits are transmitted over a quantum channel.
- Key Sifting: Alice and Bob compare their bases over a public channel. Bits measured with matching bases are kept for the shared key.
Why BB84 is secure: Any eavesdropping (e.g., by Eve) on the quantum channel introduces detectable anomalies in the transmission, enabling Alice and Bob to discard affected qubits.
- Docker: Install Docker and Docker Compose on your machine. Follow the installation guide from Docker's official site.
- Git: Clone the repository to your local machine.
-
Clone the repository:
git clone https://github.com/abdorrahmani/QK.git cd QK
-
Build and run the Docker container:
docker-compose up --build
-
Run tests to ensure everything is working:
docker exec -it qk go test ./... -v
- Protocol Initialization: The program initializes the BB84 protocol with a specified number of bits (e.g., 128).
- Quantum Transmission:
- Alice prepares random bits and bases.
- Qubits are transmitted over the quantum channel.
- Bob measures the qubits using random bases.
- Key Sifting: Alice and Bob compare bases to generate a shared key.
- Secure Communication:
- Alice encrypts a message using the shared key.
- Bob decrypts the message using the same key.
The program simulates the entire BB84 protocol without physical quantum systems by:
- Generating random bits and bases for Alice and Bob.
- Simulating the quantum channel to transmit qubits.
- Producing a shared key based on matching bases.
- Using the shared key to encrypt and decrypt messages.
Run the included tests to verify the protocol and secure communication implementation:
go test ./... -v
The tests include:
- Validation of random bit and basis generation.
- End-to-end BB84 protocol simulation.
- Encryption and decryption functionality.
Contributions are welcome! Feel free to submit issues or pull requests to improve the implementation.