⚛ sha2.fail / docs

Qiskit

Qiskit is IBM’s open-source Python SDK for quantum computing. It is the most widely used framework for prototyping reversible cryptographic circuits and running them on simulators or IBM Quantum hardware.

Key sha2.fail-relevant gates: QuantumCircuit.x(), .cx(), .ccx() (Toffoli), .h(), .t(), .s(), .swap(). Ancilla cleanliness is checked manually or via the ToffoliSimulator-style pattern.

Minimal example: build a reversible SHA-256-like adder step

from qiskit import QuantumCircuit

# Three 32-bit registers: a, b, and a zero-initialized output register
n = 32
a = list(range(0, n))
b = list(range(n, 2*n))
out = list(range(2*n, 3*n))
qc = QuantumCircuit(3*n)

# Ripple-carry addition: a += b (mod 2^n) using one dirty ancilla
for i in range(n):
    qc.ccx(a[i], b[i], out[i])   # compute carry
    qc.cx(a[i], b[i])            # sum bit into b
    # ... uncompute carry ancilla at the end

print(qc.count_ops())

A full SHA-256 implementation follows the same pattern for 64 rounds, the message schedule, and the majority/choice functions, then uncomputes every ancilla back to |0⟩.

Mirrored circuit code

We mirror a Qiskit Toffoli simulator and AES S-box implementation that demonstrates the reversible-circuit style used in cryptographic oracles:

Sources: fvirdia/Qiskit-DIY-Toffoli-simulator and demining/Quantum-Attacks-on-Bitcoin.