qiskit-leaky-init
A transpilation init plugin for Qiskit that demonstrates how a modified transpilation stage can be used to hide classical information in the final transpiled quantum circuit.
The current implementation, by default, tries to encode the HSLU logo into the transpiled circuit. The raw image is
encoded into large integers, which are saved as parameters of
RZGates. These gates are added to
an auxiliary QuantumRegister in the
first stage (init) of the
transpilation surrounded by
reset instructions. This guarantees that later
stages in the transpilation (e.g. routing, optimization, etc.) do not modify this quantum register in any way, allowing
the extraction of the leaked data.
Custom data can be encoded if builtins.data exists. In that case, the bytes from that variable are used instead of
the HSLU logo (see the example below).
The plugin is implemented as a subclass of
PassManagerStagePlugin,
which appends to the default init pass DefaultInitPassManager a new
TransformationPass, called
LeakyQubit.
Encoded data can be recovered with recover_data() implemented in the decoder module.
See the example below.
Installation
git clone https://github.com/iyanmv/qiskit-leaky-init.git
cd qiskit-leaky-init
pip install .
Example
import builtins
import io
import secrets
from pathlib import Path
from PIL import Image
from qiskit.circuit import QuantumCircuit
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit.transpiler.preset_passmanagers.plugin import list_stage_plugins
from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit_ibm_runtime.fake_provider import FakeBrisbane
from qiskit_leaky_init import recover_data
# Check that init plugin was installed correctly
assert "leaky_init" in list_stage_plugins("init")
# To encode custom data, store it in builtins.data. For example:
# builtins.data = secrets.token_bytes(256)
backend = FakeBrisbane()
pm = generate_preset_pass_manager(
optimization_level=3, backend=backend, init_method="leaky_init"
)
# 3-qubit GHZ circuit
qc = QuantumCircuit(3)
qc.h(0)
qc.cx(0, range(1, 3))
# Transpiled circuit with leaked data
isa_qc = pm.run(qc)
recovered_img = recover_data(isa_qc)
Image.open(io.BytesIO(recovered_img)).show()
Metadata
Release files for qiskit-leaky-init 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qiskit_leaky_init-0.2.4.tar.gz | 7.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qiskit_leaky_init-0.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.0 kB
Release files / qiskit_leaky_init-0.2.4.tar.gz
| Download URL | qiskit_leaky_init-0.2.4.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c2219d52c095c9b4fdce985de8cbb87d8533cfb04ec5020256cd0a7581bfc60
|
|
BLAKE2b-256 checksum How to use checksums |
e2794bc9e59bd3fb2ed6f66d738c12d84ae92cc712528465aa42c57cc832b484
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 17, 2026.
Transparency logRelease files / qiskit_leaky_init-0.2.4-py3-none-any.whl
| Download URL | qiskit_leaky_init-0.2.4-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae4d4d5dde8d42296c729bf124062c3a5f67bd3359c6608f4f42fbfff590b099
|
|
BLAKE2b-256 checksum How to use checksums |
eb04d6365e124a4b8543501cdd1089f933a67e9a29f9f265dad1e8e3163686f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 17, 2026.
Transparency log