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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pypqc-0.0.6.1.post1-py3-none-win_amd64.whl (734.5 kB view details)

Uploaded Python 3 Windows x86-64

pypqc-0.0.6.1.post1-py3-none-win32.whl (702.8 kB view details)

Uploaded Python 3 Windows x86

pypqc-0.0.6.1.post1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ x86-64

pypqc-0.0.6.1.post1-py3-none-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.9 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

File details

Details for the file pypqc-0.0.6.1.post1-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for pypqc-0.0.6.1.post1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 b9028416156eee560dcbc7030910bc3350864e10d70135ad3bf6f1c7e43fb790
MD5 4bd2e809ab859c84955d4bda7af5e091
BLAKE2b-256 6e2baea8e851b7913ac708fa6c38d58460a3759919882228f3fb350af79d278d

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.1.post1-py3-none-win32.whl.

File metadata

  • Download URL: pypqc-0.0.6.1.post1-py3-none-win32.whl
  • Upload date:
  • Size: 702.8 kB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pypqc-0.0.6.1.post1-py3-none-win32.whl
Algorithm Hash digest
SHA256 a743e88e627f7249d2018152e4ba513230cc431ffbc5d8d6e8a52b0f68ca6fd0
MD5 2dcf7f1d9f6ddbb5ce46eef2532971e7
BLAKE2b-256 58a941e23d4525087070da6f785af0fac0cadd2a670d6c322d274ea02da2d44e

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.1.post1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pypqc-0.0.6.1.post1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b1a4db748d57ff9a61d8bcf51b44be24668f43ce37ebb787f752067d2898e016
MD5 4df91fca1656506beae0a2a33e6bf8c9
BLAKE2b-256 625788fc2c5d37d30e0803717c21f7c89a10719281cb2906c426061f6c1e3b55

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.1.post1-py3-none-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pypqc-0.0.6.1.post1-py3-none-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 ffef97754bc0508dea23bfe615a375fd9913761aadac17111cd934ccb9e73238
MD5 e1d23aacb38d8865a3ee6022bd93d7a1
BLAKE2b-256 963c446e976544b358c0c88085d76ea31c866013a4d028185d4e71d7b65938c6

See more details on using hashes here.

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