I built a small scale DES (only one iteration instead of 16) and then built a quantum simulation to crack the encryption using Grover's Algorithm: Please see full report for analysis and security implications: 📄 View Full Project Report (PDF)
Note: AI was used to convert report from Word docx to markdown for README
- Accept an email to generate a random key.
- Store or retrieve a custom IP table and its inverse, unique to each email.
- Encrypt 32-bit blocks by applying a Feistel structure, emulating DES encryption.
- Decrypt by applying the same operations in order, using the ciphertext to retrieve the plaintext.
- Hash a user-provided email to generate a random 32-byte (256-bit) key.
- Apply the user's unique initial permutation to the key, then split and store it as two halves (16 bytes each).
- Take the 32-byte plaintext message and apply the user’s unique initial permutation.
- Store the permuted message as two halves, each 16 bytes.
- Expand the right half of the permuted plaintext using the standard DES expansion table (32 bits → 48 bits).
- Expand the corresponding key block to match the expanded message block.
- XOR the expanded key block with the expanded message block.
- Pass the result through standard DES S-boxes (48 bits → 32 bits).
- XOR the S-box output with the saved left half of the message.
- Repeat this process for each block of plaintext, concatenating results to form the final ciphertext.
- Expand a 32-bit block of ciphertext into 48 bits using the expansion table.
- Expand the corresponding key block similarly.
- XOR the expanded key block and expanded ciphertext block.
- Pass the result through the S-boxes to return to 32 bits.
- XOR the S-box output with the original left half of the message block.
- Repeat for all ciphertext blocks, concatenating results.
- Apply the inverse permutation table to recover the original plaintext.
Simulate a quantum attack on HBEA using Grover’s Algorithm.
Grover’s Algorithm is a quantum search algorithm that searches unsorted, unstructured databases in O(√N) time—significantly faster than classical brute-force algorithms, which run in O(N) time.
Our HBEA uses SHA-256 to create a 256-bit key. In practice, Grover’s Algorithm would take approximately 2¹²⁸ iterations to find this key—still far too many for current quantum or classical machines.
To demonstrate the concept feasibly, we scale down the key size to 4 bits, reducing the search space from 2²⁵⁶ to just 2⁴ = 16 possibilities. This small scale is computationally manageable on a laptop using Qiskit, while still illustrating the core principles of Grover's Algorithm.
Grover’s Algorithm scales as O(√N) regardless of the size of N. Therefore, we can extrapolate insights from small-scale simulations to understand the algorithm’s theoretical performance on a 256-bit target.
-
Initialization
- Constructed a quantum circuit with 4 qubits and 4 classical bits.
-
Superposition
- Applied Hadamard gates to all qubits to create a uniform superposition across all 16 states.
-
Oracle Construction
- Targeted key:
|1011⟩ - Flipped qubits where the target bit was
0, applied multi-controlled-Z, then unflipped — marking the target state by inverting its amplitude.
- Targeted key:
-
Diffusion Operator
- Applied another round of Hadamard, X, and multi-controlled-Z gates to amplify the target state by reflecting amplitudes over the mean.
-
Measurement & Simulation
- Added measurement gates to all qubits.
- Ran the circuit 1024 times to observe frequency trends.
- Target state
|1011⟩occurred 455 out of 1024 times. - All other states ranged between 27–47 measurements.
This demonstrates a successful implementation of Grover’s Algorithm: the amplitude of the correct state was significantly amplified while incorrect states remained low. This confirms Grover’s power in quantum search through unstructured spaces.
-
Initialization
Created a quantum circuit with 4 qubits and 4 classical bits. -
Superposition
Applied Hadamard gates to all qubits, placing them in a uniform superposition of all 16 possible solutions. -
Oracle Construction
Marked the target key|1011⟩by flipping any qubit where the target bit was 0, applying multi-controlled-Z operations, then unflipping — inverting the amplitude of the target state. -
Diffusion Operator
Applied another round of Hadamard, X, and multi-controlled-Z gates to reflect the amplitudes over the mean (a.k.a. the Grover diffuser). -
Measurement and Simulation
Added measurement gates to all qubits and simulated the circuit 1024 times to observe statistically meaningful trends.
- Target key
|1011⟩appeared 455 out of 1024 times. - All other states stayed consistently low (between 27–47 occurrences).
- The high measurement count for the target key shows Grover’s Algorithm successfully amplified the correct state’s amplitude, while minimizing others — demonstrating its power in quantum search.
Figure 1
Bloch spheres showing the initial state of the 4 qubits:
Figure 2
3D representation of the quantum statevector prior to measurement:
Figure 3
Histogram of the measurement results showing amplification of |1011⟩:
Figure 4
Final Grover circuit with gates as observed post-measurement:



