Skip to main content

QIFLib is a Python library for modeling, analyzing, and quantifying information leakage in probabilistic systems using the Quantitative Information Flow (QIF) framework.
It provides a clean, composable set of primitives — secrets, channels, hyper-distributions, vulnerability and uncertainty functions — so you can build end-to-end analyses of how much information an adversary could learn.

For more details see the book The Science of Quantitative Information Flow.

Features

  • Secrets Modeling — define hidden states with flexible prior distributions.
  • Channels — represent probabilistic mappings $p(y\mid x)$ from secrets to observations.
  • Hyper-distributions — automatically compute joint $p(x,y)$, outer $p(y)$, and inners $p(x\mid y)$.
  • Vulnerability Analysis — use $g$-vulnerability to quantify an adversary’s expected gain before and after observing outputs.
  • Uncertainty Analysis — use $\ell$-uncertainty to measure the expected loss under optimal strategies.
  • Leakage Metrics — compute additive and multiplicative leakage.
  • Flexible Functions — provide gain/loss as matrices or Python callables.

Why QIF?

Traditional security analysis asks whether a secret can be inferred. QIF quantifies how much an adversary is expected to learn, under probabilistic models of system behavior and strategies.
Useful for:

  • privacy-preserving data publishing,
  • side-channel analysis,
  • communication protocol evaluation,
  • decision-making under uncertainty.

Installation

You can install via PyPI:

pip install qiflib

or manuallly by copying this repository to your local machine and running:

pip install path/to/qiflib   

To verify if the package was installed correctly, you can run tests:

cd path/to/qiflib
python -m unittest discover tests

Example

from qiflib.core.secrets import Secrets
from qiflib.core.channel import Channel
from qiflib.core.hyper import Hyper
from qiflib.core.gvulnerability import GVulnerability

# Secrets & prior
secrets = Secrets(["x0", "x1"], [0.6, 0.4])

# Channel matrix: rows sum to 1
outputs = ["y0", "y1"]
C = [
      [0.8, 0.2],  # p(y|x0)
      [0.1, 0.9],  # p(y|x1)
]
channel = Channel(secrets, outputs, C)

# Hyper-distribution
hyper = Hyper(channel)

# Gain function (1 if correct guess, else 0)
actions = ["guess_x0", "guess_x1"]
def gfun(w, x): return 1.0 if w == x else 0.0

g = GVulnerability(secrets, actions, gfun)

print("Prior vulnerability:", g.prior_vulnerability())
print("Posterior vulnerability:", g.posterior_vulnerability(hyper))

License

This project is licensed under the MIT License.

Metadata

Release files for qiflib 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qiflib 1.0
File Size Uploaded Provenance Actions
qiflib-1.0.tar.gz 15.0 kB Without provenance Details for qiflib-1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qiflib 1.0
File Interpreter ABI Platform Actions
qiflib-1.0-py3-none-any.whl Python 3 none any Details for qiflib-1.0-py3-none-any.whl

Total release size: 29.0 kB

Release files / qiflib-1.0.tar.gz

Download URL qiflib-1.0.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
533609a864e5a532f7af2959feeb5cfde979d2f654cc4b00b4dc4aff9095a546
BLAKE2b-256 checksum
How to use checksums
14cdc5116816fd830ec410c8cd41dffc2fe30e290e2d98ce713379079c27b403
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / qiflib-1.0-py3-none-any.whl

Download URL qiflib-1.0-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
27e6f2a14b975de112c56111b6555e3d575ffe5b2a8e66d6e115ebb6f45b1552
BLAKE2b-256 checksum
How to use checksums
05e169d36f5fb9b464632315eb9018cf90df2fd8567b5e0d8dc6332650f6a6dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Security for qiflib 1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page