Skip to main content

A transpilation plugin for Qiskit with a modified init stage that encodes (classical) information adding RZGates to auxiliary qubits

Project description

qiskit-leaky-init

Build & Test Python Wheel Package PyPI - Version PyPI - Wheel arXiv

[!NOTE] This plugin was developed to demonstrate the importance of reproducible builds in the Qiskit quantum computing workflow. It shows that non-reproducibility in the transpilation process (specifically during the init stage) can be exploited to encode classical information into the transpiled quantum circuit. If an attacker subsequently gains access to the job description, this can lead to the leakage of confidential data.

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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qiskit_leaky_init-0.2.2.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qiskit_leaky_init-0.2.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file qiskit_leaky_init-0.2.2.tar.gz.

File metadata

  • Download URL: qiskit_leaky_init-0.2.2.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qiskit_leaky_init-0.2.2.tar.gz
Algorithm Hash digest
SHA256 e14aba5c2c485e3bb48b4a441a8eaab0746400c852af8a4ca89d79823e81b7fa
MD5 c0937b88b0fbb6b7ddd843e5549f2928
BLAKE2b-256 f9ca46c00790922f667ec78466e35bb4f103f675f62af934ab8384e0ca2da88e

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit_leaky_init-0.2.2.tar.gz:

Publisher: publish-to-pypi.yml on iyanmv/qiskit-leaky-init

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qiskit_leaky_init-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for qiskit_leaky_init-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 88d3ec39902848d126d4180aa26f2780d229ab7e3db462f0943baa2b3ca8e819
MD5 0429238d09b66c5ce11bc8dcb6f366da
BLAKE2b-256 83038598c67919216c8b4f80a6eefcef651229d6954b4b9f380bfbcf4fa9d1cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit_leaky_init-0.2.2-py3-none-any.whl:

Publisher: publish-to-pypi.yml on iyanmv/qiskit-leaky-init

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page