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

Uploaded Source

Built Distributions

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

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

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

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

Uploaded PyPy macOS 10.9+ x86-64

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

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

Uploaded CPython 3.7+ Windows x86-64

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

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

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

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

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

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

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

File details

Details for the file pypqc-0.0.6.2.tar.gz.

File metadata

  • Download URL: pypqc-0.0.6.2.tar.gz
  • Upload date:
  • Size: 785.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.3.dev63+ga543352 PyPy/7.3.15

File hashes

Hashes for pypqc-0.0.6.2.tar.gz
Algorithm Hash digest
SHA256 f8f09a46971c2ef0cb5be4e5f5a280b3cdcdb01b3ef983091486eb40089228a5
MD5 1f41963faa3d01b7ac7d0d23ec67b1d3
BLAKE2b-256 2edbd96a6edc03edce05d025d4d1542dd5d1ac1e414a51e12dc318fab4ca1e2a

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.2-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for pypqc-0.0.6.2-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 2d2fea473964e7ff83a25f49eec43186cb7d3e663a1731324662d901ad878fa4
MD5 20b3a7a0f34b91a1cb559c67db80e662
BLAKE2b-256 962686330cbbfc1b20cdac479321078615366911027c0dc588ff3132e7a97bfe

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pypqc-0.0.6.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 618d44efd03288349cc285fbe81760b13d2024325dc285cac80fdbe0e94cd5bd
MD5 c03a407f2c07115fc80c0405eea0cacd
BLAKE2b-256 502086180c35c50aba01c7f5c11465bcfcab918597bc3e3806e84e3b7e40a9c2

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pypqc-0.0.6.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 f7b813de74e8f767fd6d00810b466bc76dc9fdae1c82837a829c9838163d2f67
MD5 0997310bf841f0e3057c80dc2bdeebe9
BLAKE2b-256 5047e018cd3952b853270e07ade06150834eebcbb583cac1732aacf2a4b6b9b2

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.2-pp310-pypy310_pp73-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pypqc-0.0.6.2-pp310-pypy310_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2660701cc5a333296706156107b1591e69b08513a0d4f701d6ed16d8a6e5e9cb
MD5 9de5ba86d76a939d438eb92c7b6906ef
BLAKE2b-256 0df79c4a262cdf1fe5d5ecbb24924024957181853eda408646b7aa8f2552816e

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.2-cp38-abi3-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pypqc-0.0.6.2-cp38-abi3-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 57d452353072efcbf92a117f6da3e2d9588d6d7ec93d8f5e3ff0e0a54e14ab56
MD5 9f55b99ac61b637a0b362e92b1c70939
BLAKE2b-256 81bcc0cd6b5ac4240b1606d63441ff4076d77bb82418f40625e7b6135db13671

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.2-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: pypqc-0.0.6.2-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 674.4 kB
  • Tags: CPython 3.7+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.3.dev63+ga543352 PyPy/7.3.15

File hashes

Hashes for pypqc-0.0.6.2-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c63aafc47921a43571fee62a76ab9e259b67054d31c0c812e9efbe26159ef8c7
MD5 a9e24b4a66bd4397ca083ba8ed2a56f3
BLAKE2b-256 20ebdf33ef5717a5cc311189589037edd525dbfed7933046702465908f23bebb

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.2-cp37-abi3-win32.whl.

File metadata

  • Download URL: pypqc-0.0.6.2-cp37-abi3-win32.whl
  • Upload date:
  • Size: 652.6 kB
  • Tags: CPython 3.7+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.3.dev63+ga543352 PyPy/7.3.15

File hashes

Hashes for pypqc-0.0.6.2-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 e2070db26dc82f22067218d1465d4f6a9b964da9010865b832f3fe9b5b7da3cf
MD5 dbb12899a5148a6682f4141f01b05398
BLAKE2b-256 bc39daed02fc17a2a5a33bca0a7859facfbbddf0179210598e635241c87c4338

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pypqc-0.0.6.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd106641e7ecc1eedd6e9213d34749374ba6b2ce65da6ede6784ad9315896091
MD5 0d5f47176d3ff9a1f976926aa7ef9ed5
BLAKE2b-256 d3634a198aadf5eee43b6748c6ea4ab15b42cfb075fb61f914fa6b7dee6d82bd

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.2-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for pypqc-0.0.6.2-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 efde01c55e9724aa7688c56444c2b36083bc8d2e1efdeb5f4b16d3e5ef0586e8
MD5 0803a8436797b8a96cbe63d248833b2d
BLAKE2b-256 3bcda79a62bd579dffe874eb60b40da83a7c143ca215440c98a0943bae1584d9

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.2-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for pypqc-0.0.6.2-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 c828948344975e20f651ed640f022019f930c1248cd23195bf0abffb50d7a0f8
MD5 d15490096e770d20f94fa4f5eb06a7bd
BLAKE2b-256 444fad252ce82dc8f79eb18e9456d88aad1f0a16ed038f8f44ad6a24067e6add

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pypqc-0.0.6.2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a2ae423317c12eeaf3853ee30a92041a5aff1c191f91756df460d7c03269cbb8
MD5 e7d1053c35b92ba1233b41477e08e111
BLAKE2b-256 a2288d3d22b672628723134f7f85ca1af745391b0ccfce9bd1910b9357d8b67e

See more details on using hashes here.

File details

Details for the file pypqc-0.0.6.2-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pypqc-0.0.6.2-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 2b0a6f5e7fc4110eccd90d8262f649b77e43ce41e7898ba61dfaafe94b76553b
MD5 567ea4fc7a68f056f8084c2c3f4275af
BLAKE2b-256 77247cf61c6674ee5af14b439ced2072199f3e4d54e715370af000f75c7b4b58

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