Skip to main content

Python bindings for the "PQClean" post-quantum cryptography library.

Project description

Usage

Simply install from PyPI with pip install pypqc, or see “Development” below if you want to tinker on the codebase!

KEMs

McEliece, Kyber, and HQC are currently provided, all with the same interface.:

from pqc.kem import mceliece6960119 as kemalg


# 1. Keypair generation
pk, sk = kemalg.keypair()


# 2. Key encapsulation
ss, kem_ct = kemalg.encap(pk)


# 3. Key de-encapsulation
ss_result = kemalg.decap(kem_ct, sk)
assert ss_result == ss

Capabilities not included in PQClean, such as McEliece signatures, Hybrid Encryption or KEM-TRANS, and message encapsulation, are not going to be implemented in this library. (Exception: Plaintext Confirmation is on the agenda for inclusion even if upstream ultimately decides to exclude it.)

Signature Algorithms

SPHINCS+, Dilithium, and Falcon are provided, all with the same interface.:

from pqc.sign import sphincs_shake_256s_simple as sigalg


# 1. Keypair generation
pk, sk = sigalg.keypair()


# 2. Signing
# (detached signature)
sig = sigalg.sign(MY_MESSAGE, sk)


# 3. Signature verification
# (Returns None on success; raises ValueError on failure.)
sigalg.verify(sig, MY_MESSAGE, pk)

Regarding SPHINCS+: the Simple version is included; the Robust version is is not; SHA256 and SHAKE256 are included; Haraka is not. These decisions are all inherited from PQClean; I don’t know much about their rationale.

Regarding Falcon: the Compressed version is included. The Padded version is not included, but TODO as soon as upstream adds it; the CT version is probably not going to be included.

Development

Dependencies:

  • Python 3 (tested mainly on CPython 3.9, 3.10, 3.11, and 3.12; and on PyPy 7.3.12)

  • cffi

    • Transitive non-PyPI build-time dependency: Python Headers (only Linux users need to manually install these; they come OOtB on Windows. Not sure about Mac.)

  • setuptools (build-time dependency)

  • wheel (build-time dependency)

  • a C compiler (build-time dependency)

Getting started:

  1. Maybe use a venv or whatever if you want to

    • for Windows: py -m venv .venv & .venv\Scripts\activate.bat

    • for Linux and Mac: python3 -m venv .venv; . .venv/bin/activate (first install it, if needed)

  2. Run python -m pip install .

    • Alternatively: you may get cleaner building with python -m build . (only after python -m pip install build)

    • Editable / “develop” mode not supported currently (CFFI will have to support this before it’s even on the table.)

  3. Run python -m pqc.demo to test it. If it prints “OK” and exits, the functions are almost certainly not broken. (Ideally, run this from a DIFFERENT directory, such as your home folder, so you can be sure it’s being imported properly and not being masked by the local copy.)

    • N.B. / FIXME: this function is currently NOT a full test suite; it only does a single encap-decap cycle with the default implementation of mceliece6960119. It does NOT test any other version of McEliece, or any signature algorithm.

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

pypqc-0.0.6.2.tar.gz (785.2 kB view hashes)

Uploaded Source

Built Distributions

pypqc-0.0.6.2-pp310-pypy310_pp73-win_amd64.whl (623.3 kB view hashes)

Uploaded PyPy Windows x86-64

pypqc-0.0.6.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (937.3 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pypqc-0.0.6.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pypqc-0.0.6.2-pp310-pypy310_pp73-macosx_10_9_x86_64.whl (801.5 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pypqc-0.0.6.2-cp38-abi3-macosx_10_9_universal2.whl (1.8 MB view hashes)

Uploaded CPython 3.8+ macOS 10.9+ universal2 (ARM64, x86-64)

pypqc-0.0.6.2-cp37-abi3-win_amd64.whl (674.4 kB view hashes)

Uploaded CPython 3.7+ Windows x86-64

pypqc-0.0.6.2-cp37-abi3-win32.whl (652.6 kB view hashes)

Uploaded CPython 3.7+ Windows x86

pypqc-0.0.6.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ x86-64

pypqc-0.0.6.2-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.2 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ s390x

pypqc-0.0.6.2-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.1 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64le

pypqc-0.0.6.2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

pypqc-0.0.6.2-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.7 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

Supported by

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