Inspiration

What it does

How we built it

Challenges we ran into

Accomplishments that we're proud of

What we learned

What's next for Advanced quantum hash function using Qiskit

Project Story: Developing a Quantum Hash Function

This project documents the creation of a novel hash function based on quantum circuit simulation, developed as part of the Superquantum challenge at YQuantum 2025.

Inspiration

The core inspiration came directly from the Superquantum challenge prompt: exploring the potential of quantum computing for cryptographic applications, specifically proof-of-work systems in future blockchains. The idea presented in the challenge materials – that quantum computation could offer unique properties for hashing, potentially leading to more secure or fundamentally different cryptographic primitives – was fascinating. We were motivated by the prospect of designing a function that leverages quantum phenomena like superposition and entanglement, moving beyond traditional classical algorithms. The concept of "Quantum Proof of Work" and the need for computationally difficult, yet feasible, quantum tasks provided a clear goal.

What We Learned

This project was a significant learning experience across several domains:

  • Quantum Algorithm Design: We learned to design parameterized quantum circuits, specifically implementing a Hardware Efficient Ansatz (HEA) suitable for NISQ devices (and their simulation). This involved understanding different gate sets (rotations, CNOTs) and how to structure circuits for entanglement and complexity.
  • Quantum Simulation: We gained practical experience using Qiskit and the qiskit-aer statevector simulator to execute quantum circuits and obtain results.
  • Quantum Measurement & Data Extraction: We explored how to extract classical information from a quantum state, moving beyond simple Z-basis measurements to incorporate expectation values from X, Y, and Z bases to gather more information.
  • Classical-Quantum Interface: A key learning area was designing the interface between classical input data (bytes) and quantum circuit parameters (rotation angles), and then converting quantum results (expectation values) back into a classical byte output.
  • Cryptographic Hash Properties: We deepened our understanding of essential hash function criteria (determinism, entropy preservation/uniformity, collision/preimage resistance, avalanche effect) and the challenges of achieving them, especially within the constraints of quantum simulation.
  • Practical Constraints: We learned to balance the desire for cryptographic strength (requiring complex circuits) against the practical limitations of quantum simulation (the 20-qubit limit, simulation time).

How We Built It

Our development process followed these steps:

  1. Understanding Requirements: We thoroughly analyzed the challenge.md, README.md, and example files (example.ipynb, qhash.py) to grasp the core requirements, constraints, and evaluation criteria.
  2. Tool Selection: We chose Python with the Qiskit library and qiskit-aer simulator due to its prevalence in the quantum computing community and its use in the provided examples.
  3. Core Function Design (advanced_quantum_hash):
    • Input Processing: Ensured the function accepts bytes and handles the minimum input size requirement.
    • Qubit Calculation: Implemented logic to determine the number of qubits based on input size, respecting the 20-qubit cap.
    • Parameter Mapping: Devised a strategy to map pairs of input bytes to rotation angles for the quantum gates, aiming for sensitivity to input changes.
    • Circuit Architecture: Constructed a multi-layered Hardware Efficient Ansatz using RX, RY, RZ rotation gates and circular CNOT gates for entanglement.
    • Simulation: Used the statevector_simulator to get the final quantum state.
    • Measurement: Calculated expectation values for Pauli X, Y, and Z operators for each qubit.
    • Post-Processing: Combined the multi-basis expectation values using a non-linear function, scaled the results to the 0-255 range, performed an XOR-based mixing step for diffusion, and carefully constructed the output byte array to match the input length.
  4. Implementation: Coded the function in Python (main.py), ensuring it met the bytes input/output signature.
  5. Verification & Analysis: Added basic checks within the if __name__ == '__main__': block for determinism and included rudimentary tests for entropy (Chi-squared) and avalanche effect (Hamming distance on bit-flip).
  6. Visualization: Created a separate script (visualize_circuit.py) to generate visual representations of the quantum circuit structure for documentation and understanding.

Challenges Faced

We encountered several challenges during development:

  • Balancing Complexity and Feasibility: Designing a circuit complex enough to exhibit good cryptographic properties while staying within the 20-qubit limit and keeping simulation time manageable was a constant trade-off.
  • Parameter Mapping: Creating a mapping from input bytes to quantum parameters that is both sensitive (small input changes cause large output changes) and avoids obvious structural weaknesses or biases was non-trivial.
  • Output Uniformity: Converting continuous expectation values into a discrete, uniform byte distribution is inherently challenging. While mixing helps, achieving perfect uniformity requires careful design and extensive testing.
  • Achieving Strong Avalanche: Ensuring that flipping a single input bit flips approximately 50% of the output bits (good avalanche effect) required iterative refinement of the circuit structure, parameter mapping, and mixing stages.
  • Proving Security: While we designed the hash function with resistance in mind, providing formal mathematical proofs for preimage and collision resistance for a novel algorithm like this is extremely difficult and beyond the scope of basic implementation.
  • Simulation Speed: Simulating even moderately sized circuits (15-20 qubits) can be time-consuming, making iterative testing and analysis slower than for classical algorithms.

Overall, this project provided valuable hands-on experience in applying quantum computing concepts to a practical (though challenging) cryptographic problem.

Built With

Share this project:

Updates