QuantumCrypt

8 256

license: mit title: QuantumCrypt sdk: gradio sdk_version: 5.17.1 emoji: 💻 colorFrom: yellow colorTo: green pinned: false app_file: app.py short_description: Quantum applied

QuantumCrypt

BB84

Introduction

The BB84 protocol is a Quantum Key Distribution (QKD) scheme developed by Charles Bennett and Gilles Brassard in 1984. It enables two parties, traditionally called Alice and Bob, to securely share a secret key, ensuring resistance against eavesdropping attempts by an adversary (Eve).

Working Principle

BB84 leverages quantum mechanics to ensure secure communication. It relies on the properties of photon polarization and Heisenberg's uncertainty principle, making it impossible for an eavesdropper to measure photon states without disturbing the transmission.

The protocol operates as follows:

  1. Photon Transmission: Alice sends a sequence of randomly polarized photons in one of two possible bases (rectilinear + or diagonal ×).
  2. Random Measurement: Bob measures each received photon using a randomly chosen basis.
  3. Basis Comparison: Alice and Bob publicly compare the bases used for each photon and discard cases where Bob used the incorrect basis.
  4. Key Extraction: The remaining bits form a shared secret key.
  5. Error Checking: Alice and Bob verify key integrity by publicly comparing a subset of the bits. If errors exceed a threshold, they abort the protocol.
  6. Privacy Amplification: If necessary, they apply classical error correction and privacy amplification techniques to refine the final secret key.

Security

The security of BB84 is based on the no-cloning theorem, which prevents an adversary from perfectly copying an unknown quantum state. Any attempt by Eve to measure photons introduces detectable errors, allowing Alice and Bob to discard compromised keys.

Applications

  • Secure communication
  • Quantum cryptography
  • Future-proof encryption against quantum computing attacks

E91

Overview

This project demonstrates how Alice and Bob can securely exchange a cryptographic key using the E91 Quantum Key Distribution (QKD) Protocol. The protocol, developed by Artur Ekert in 1991, leverages quantum entanglement and Bell's theorem to ensure that an eavesdropper, Eve, cannot gain any information about the key without detection.

Encryption and the One-Time Pad

To ensure message confidentiality, Alice encrypts her message using the one-time pad technique. This method relies on the exclusive OR (XOR) operation to combine the plaintext and a randomly generated key:

$$ c_i = m_i \oplus k_i $$

where:

  • ( m ) is the plaintext message,
  • ( k ) is the secret key,
  • ( c ) is the ciphertext.

Decryption is performed using the same XOR operation:

$$ m_i = c_i \oplus k_i $$

Since the security of the one-time pad depends on the secrecy of the key, the main challenge is securely distributing this key between Alice and Bob. This is where quantum mechanics comes into play.

The E91 Quantum Key Distribution Protocol

The E91 protocol ensures secure key exchange using quantum entanglement. The steps are as follows:

1. Entangled Qubits Distribution

Charlie (a trusted third party) generates N pairs of entangled qubits in the singlet state:

$$ \lvert\psi_s\rangle = \frac{1}{\sqrt{2}}(\lvert01\rangle - \lvert10\rangle) $$

Charlie then sends one qubit from each entangled pair to Alice and the other to Bob over a quantum channel.

2. Measurement by Alice and Bob

  • Alice and Bob independently choose random measurement bases and measure their received qubits.
  • If they measure along the same basis, their results will be perfectly anti-correlated (i.e., opposite values).

3. Classical Communication

  • Alice and Bob share their measurement choices over a public classical channel.
  • They discard measurements where bases do not match.
  • The remaining bits form the raw key.

4. Security Verification (Bell Test)

  • Alice and Bob compute the CHSH correlation value to check for Bell inequality violation:

$$ C = \langle X \otimes W \rangle - \langle X \otimes V \rangle + \langle Z \otimes W \rangle + \langle Z \otimes V \rangle $$

  • If the result exceeds the classical bound of 2 (e.g., ( C = -2\sqrt{2} )), the key is confirmed to be secure.
  • If Eve interfered, the Bell test would fail, alerting Alice and Bob to discard the key.

5. Key Extraction

After removing potentially compromised bits, Alice and Bob apply error correction and privacy amplification techniques to finalize the secret key.

Why the E91 Protocol is Secure

  • Quantum Mechanics Guarantees Security: Any attempt by Eve to measure the qubits collapses their state, altering results and revealing her presence.
  • Bell's Theorem and CHSH Inequality: These ensure that no local hidden variable theory can explain the observed correlations, confirming true quantum entanglement.

Applications

  • Quantum-Safe Encryption: Protects against attacks from quantum computers.
  • Secure Communications: Used in diplomatic and military communication systems.
  • Quantum Networks: Forms the foundation for future quantum internet applications.

Requirements

  • Python (latest version recommended)
  • Qiskit for quantum simulations
  • Matplotlib for visualizing results
  • NumPy for numerical computations

References


This project demonstrates a secure method of quantum key distribution using entanglement and Bell's theorem, ensuring the highest level of encryption security.