Metadata-Version: 2.4
Name: qshield
Version: 1.7.0
Summary: Quantum Software Supply Chain Security Framework
Author-email: QSHIELD Contributors <284222233+katepallewarprathmesh-sketch@users.noreply.github.com>
License: Apache-2.0
Project-URL: Homepage, https://katepallewarprathmesh-sketch.github.io/QShield/
Project-URL: Repository, https://github.com/katepallewarprathmesh-sketch/QShield
Project-URL: Issues, https://github.com/katepallewarprathmesh-sketch/QShield/issues
Project-URL: Changelog, https://github.com/katepallewarprathmesh-sketch/QShield/blob/main/CHANGELOG.md
Project-URL: Documentation, https://katepallewarprathmesh-sketch.github.io/QShield/
Keywords: quantum,security,supply-chain,static-analysis,backdoor,trojan
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Security
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: scipy>=1.11
Requires-Dist: typer>=0.9
Requires-Dist: rich>=13.0
Requires-Dist: jinja2>=3.1
Requires-Dist: pyyaml>=6.0
Requires-Dist: pydantic>=2.0
Provides-Extra: qiskit
Requires-Dist: qiskit>=1.0; extra == "qiskit"
Requires-Dist: qiskit-aer>=0.13; extra == "qiskit"
Provides-Extra: cirq
Requires-Dist: cirq-core>=1.3; extra == "cirq"
Provides-Extra: pennylane
Requires-Dist: pennylane>=0.33; extra == "pennylane"
Provides-Extra: braket
Requires-Dist: amazon-braket-sdk<2,>=1.80; extra == "braket"
Provides-Extra: pytket
Requires-Dist: pytket>=1.30; extra == "pytket"
Provides-Extra: plugins
Requires-Dist: wasmtime<51,>=44; extra == "plugins"
Provides-Extra: provenance
Requires-Dist: cryptography>=42; extra == "provenance"
Provides-Extra: all-frameworks
Requires-Dist: qshield[braket,cirq,pennylane,pytket,qiskit]; extra == "all-frameworks"
Provides-Extra: formal
Requires-Dist: pyzx>=0.8; extra == "formal"
Requires-Dist: z3-solver>=4.12; extra == "formal"
Provides-Extra: ml
Requires-Dist: torch>=2.0; extra == "ml"
Requires-Dist: scikit-learn>=1.3; extra == "ml"
Provides-Extra: dev
Requires-Dist: pytest>=7.4; extra == "dev"
Requires-Dist: pytest-cov>=4.1; extra == "dev"
Requires-Dist: hypothesis>=6.82; extra == "dev"
Requires-Dist: ruff>=0.1; extra == "dev"
Requires-Dist: mypy>=1.5; extra == "dev"
Requires-Dist: cryptography>=42; extra == "dev"
Requires-Dist: jsonschema>=4.20; extra == "dev"
Requires-Dist: tomli>=2.0; python_version < "3.11" and extra == "dev"
Dynamic: license-file

<div align="center">

# QSHIELD

### Security checks for quantum circuits and the software that ships them.

[![PyPI version](https://img.shields.io/pypi/v/qshield?color=77e3bd&label=PyPI)](https://pypi.org/project/qshield/)
[![Python versions](https://img.shields.io/pypi/pyversions/qshield)](https://pypi.org/project/qshield/)
[![License: Apache 2.0](https://img.shields.io/badge/license-Apache--2.0-77e3bd)](LICENSE)

[Workbench](https://katepallewarprathmesh-sketch.github.io/QShield/workbench.html) · [Changelog](CHANGELOG.md)

</div>

## What it does

You write a quantum program. Something changes before it runs — a gate is swapped, a measurement is flipped, a dependency is tampered with. QSHIELD looks for that, and tells you where.

It reads a circuit, checks it, and gives you a report you can act on. It runs on your own machine.

## Install

```bash
pip install qshield
```

Optional extras, only if you need them:

| Extra | Adds |
|---|---|
| `qshield[qiskit,cirq]` | Parsers for Qiskit and Cirq |
| `qshield[braket]` | Amazon Braket circuits |
| `qshield[pytket]` | pytket circuits |
| `qshield[formal]` | PyZX and Z3 verification |
| `qshield[plugins]` | Sandboxed detector plugins |

Python 3.10 or later.

## Try it

```bash
qshield scan circuit.qasm                  # check one file
qshield scan . --recursive --format sarif  # check a whole project
qshield compare original.qasm candidate.qasm   # are these two the same circuit?
qshield ui                                 # open the browser Workbench
```

In Python:

```python
import qshield

results = qshield.scan("circuit.qasm")
print(results.is_clean)
```

## How it works

![QSHIELD architecture](assets/architecture.svg)

You give it a circuit, a model, or a list of dependencies. It runs five checks. You get findings you can put in a ticket, wire into CI, or read yourself.

## The one check that needs extra setup

Most checks work out of the box. One does not.

**Readout checks need something to compare against.** A gate right before a measurement is normal — Deutsch's algorithm does it, and so does Bernstein–Vazirani. So "there is a gate before the measurement" tells you nothing on its own. You need to know what was approved.

QSHIELD compares your circuit against a reference you signed off earlier. If you haven't set one up, it says *not checked* rather than *fine* — because those are different answers.

```bash
# 1. Record what you approved, then sign it
qshield provenance keygen --private-key priv.pem --public-key pub.pem
qshield baseline create approved.qasm --workload my-circuit --approved-by you@example.com -o bl.json
qshield baseline sign bl.json --private-key priv.pem

# 2. Check a candidate against it (exit code 1 if the readout changed)
qshield baseline scan new.qasm -b bl.json -c approved.qasm \
    --public-key pub.pem --workload my-circuit
```

Without the `--no-passphrase` flag, step 1 asks you to choose a passphrase. Add `--no-passphrase` for scripts and CI.

## Workbench

`qshield ui` opens a local web page. Pick a circuit file, click **Scan**, read the results. Nothing is uploaded.

## Run-time protection

The runtime proxy sits between your code and a cloud quantum provider. It logs every call to a tamper-evident chain, so you can prove afterwards what was sent and when.

```bash
qshield runtime proxy --upstream https://provider.example/api \
  --audit-chain /var/log/qshield/audit.jsonl
qshield runtime audit-verify /var/log/qshield/audit.jsonl
```

## Annealer models

If you submit a QUBO or Ising model to a solver rather than a circuit, `qshield audit-qubo` checks it first:

```bash
qshield audit-qubo model.qubo --expected-digest <hex>
```

The digest covers every coefficient at full precision. If someone edits the model after you approved it, the digest changes — even for an edit too small for a solver to notice.

## Contextuality

`qshield contextuality` checks whether a circuit really produces a non-classical result. Useful when you need to show it is not secretly doing something classical.

## Development

```bash
git clone https://github.com/katepallewarprathmesh-sketch/QShield
cd QShield
pip install -e '.[dev]'
./scripts/verify.sh          # runs everything CI runs
```

`./scripts/verify.sh --fast` skips the benchmark for a quicker loop.

## More

- [SECURITY.md](SECURITY.md) — how to report a vulnerability
- [LICENSE](LICENSE) — Apache 2.0
