{"id":28462251,"url":"https://github.com/open-quantum-safe/liboqs-python","last_synced_at":"2025-10-08T18:00:08.437Z","repository":{"id":40273085,"uuid":"162497174","full_name":"open-quantum-safe/liboqs-python","owner":"open-quantum-safe","description":"Python 3 bindings for liboqs","archived":false,"fork":false,"pushed_at":"2025-03-26T13:53:46.000Z","size":156,"stargazers_count":167,"open_issues_count":11,"forks_count":61,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-06-21T05:16:10.883Z","etag":null,"topics":["cryptography","post-quantum-cryptography","python","python3","quantum-computing"],"latest_commit_sha":null,"homepage":"https://openquantumsafe.org/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/open-quantum-safe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-19T22:23:51.000Z","updated_at":"2025-06-18T02:58:59.000Z","dependencies_parsed_at":"2023-02-16T05:55:16.282Z","dependency_job_id":"e5431197-e1e8-4b22-b146-9c78b376aa22","html_url":"https://github.com/open-quantum-safe/liboqs-python","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/open-quantum-safe/liboqs-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-quantum-safe%2Fliboqs-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-quantum-safe%2Fliboqs-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-quantum-safe%2Fliboqs-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-quantum-safe%2Fliboqs-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/open-quantum-safe","download_url":"https://codeload.github.com/open-quantum-safe/liboqs-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-quantum-safe%2Fliboqs-python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263360758,"owners_count":23454780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","post-quantum-cryptography","python","python3","quantum-computing"],"created_at":"2025-06-07T04:08:46.094Z","updated_at":"2025-10-08T18:00:08.431Z","avatar_url":"https://github.com/open-quantum-safe.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# liboqs-python: Python 3 bindings for liboqs\n\n[![GitHub actions](https://github.com/open-quantum-safe/liboqs-python/actions/workflows/python_simplified.yml/badge.svg)](https://github.com/open-quantum-safe/liboqs-python/actions)\n\n---\n\n## About\n\nThe **Open Quantum Safe (OQS) project** has the goal of developing and\nprototyping quantum-resistant cryptography.\n\n**liboqs-python** offers a Python 3 wrapper for the\n[Open Quantum Safe](https://openquantumsafe.org/)\n[liboqs](https://github.com/open-quantum-safe/liboqs/)\nC library, which is a C library for quantum-resistant cryptographic algorithms.\n\nThe wrapper is written in Python 3, hence in the following it is assumed that\nyou have access to a Python 3 interpreter. liboqs-python has been extensively\ntested on Linux, macOS and Windows platforms. Continuous integration is\nprovided via GitHub actions.\n\nThe project contains the following files and directories\n\n- **`oqs/oqs.py`: a Python 3 module wrapper for the liboqs C library.**\n- `oqs/rand.py`: a Python 3 module supporting RNGs from `\u003coqs/rand.h\u003e`\n- `examples/kem.py`: key encapsulation example\n- `examples/rand.py`: RNG example\n- `examples/sig.py`: signature example\n- `examples/stfl_sig.py`: stateful signature example\n- `tests`: unit tests\n\n---\n\n## Pre-requisites\n\n- [liboqs](https://github.com/open-quantum-safe/liboqs)\n- [git](https://git-scm.com/)\n- [CMake](https://cmake.org/)\n- C compiler,\n  e.g., [gcc](https://gcc.gnu.org/), [clang](https://clang.llvm.org),\n  [MSVC](https://visualstudio.microsoft.com/vs/) etc.\n- [Python 3](https://www.python.org/)\n\n---\n\n## Installation\n\n### Configure, build and install liboqs\n\nExecute in a Terminal/Console/Administrator Command Prompt\n\n```shell\ngit clone --depth=1 https://github.com/open-quantum-safe/liboqs\ncmake -S liboqs -B liboqs/build -DBUILD_SHARED_LIBS=ON\ncmake --build liboqs/build --parallel 8\ncmake --build liboqs/build --target install\n```\n\nThe last line may require prefixing it by `sudo` on UNIX-like systems. Change\n`--parallel 8` to match the number of available cores on your system.\n\nOn UNIX-like platforms, you may need to set the `LD_LIBRARY_PATH`\n(`DYLD_LIBRARY_PATH` on macOS) environment variable to point to the path to\nliboqs' library directory, e.g.,\n\n```shell\nexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib\n```\n\nOn Windows platforms, **you must ensure** that you add the\n`-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE` flag to CMake, and that the liboqs\nshared library `oqs.dll` is visible system-wide, i.e., set the `PATH`\nenvironment variable accordingly by using the \"Edit the system environment\nvariables\" Control Panel tool or executing in a Command Prompt\n\n```shell\nset PATH=%PATH%;C:\\Program Files (x86)\\liboqs\\bin\n```\n\nYou can change liboqs' installation directory by configuring the build to use\nan alternative path, e.g., `C:\\liboqs`, by passing the\n`-DCMAKE_INSTALL_PREFIX=/path/to/liboqs` flag to CMake, e.g.,\n\n```shell\ncmake -S liboqs -B liboqs/build -DCMAKE_INSTALL_PREFIX=\"C:\\liboqs\" -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=ON\n```\n\nAlternatively, you can set the `OQS_INSTALL_PATH` environment variable to point\nto the installation directory, e.g., on a UNIX-like system, execute\n\n```shell\nexport OQS_INSTALL_PATH=/path/to/liboqs\n```\n\n### Let liboqs-python install liboqs automatically\n\nIf liboqs is not detected at runtime by liboqs-python, it will be downloaded,\nconfigured and installed automatically (as a shared library). This process will\nbe performed only once, at runtime, i.e., when loading the liboqs-python\nwrapper. The liboqs source directory will be automatically removed at the end\nof the process.\n\nThis is convenient in case you want to avoid installing liboqs manually, as\ndescribed in the subsection above.\n\n### Install and activate a Python virtual environment\n\nExecute in a Terminal/Console/Administrator Command Prompt\n\n```shell\npython3 -m venv venv\n. venv/bin/activate\npython3 -m ensurepip --upgrade\n```\n\nOn Windows, replace the line\n\n```shell\n. venv/bin/activate\n```\n\nby\n\n```shell\nvenv\\Scripts\\activate.bat\n```\n\n### Configure and install the wrapper\n\nExecute in a Terminal/Console/Administrator Command Prompt\n\n```shell\ngit clone --depth=1 https://github.com/open-quantum-safe/liboqs-python\ncd liboqs-python\npip install .\n```\n\n### Run the examples\n\nExecute\n\n```shell\npython3 liboqs-python/examples/kem.py\npython3 liboqs-python/examples/sig.py\npython3 liboqs-python/examples/stfl_sig.py\npython3 liboqs-python/examples/rand.py\n```\n\n### Run the unit test\n\nExecute\n\n```shell\nnose2 --verbose\n```\n\n---\n\n## Usage in standalone applications\n\nliboqs-python can be imported into Python programs with\n\n```python\nimport oqs\n```\n\nliboqs-python defines three main classes: `KeyEncapsulation`, `Signature`, and\n`StatefulSignature`, providing post-quantum key encapsulation as well as\nstateless and stateful signature mechanisms. Each must be instantiated with a\nstring identifying one of the mechanisms supported by liboqs; these can be\nenumerated using the `get_enabled_kem_mechanisms()`,\n`get_enabled_sig_mechanisms()` and `get_enabled_stateful_sig_mechanisms()`\nfunctions. ML-KEM key pairs can also be deterministically generated from a\nseed using `KeyEncapsulation.generate_keypair_seed()`.\nThe files in `examples/` demonstrate the wrapper's API. Support for alternative\nRNGs is provided via the `randombytes_*()` functions.\n\nThe liboqs-python project should be in the `PYTHONPATH`. To ensure this on\nUNIX-like systems, execute\n\n```shell\nexport PYTHONPATH=$PYTHONPATH:/path/to/liboqs-python\n```\n\nor, on Windows platforms, use the \"Edit the system environment variables\"\nControl Panel tool or execute in a Command Prompt\n\n```shell\nset PYTHONPATH=%PYTHONPATH%;C:\\path\\to\\liboqs-python\n```\n\n---\n\n## Docker\n\nA self-explanatory minimalistic Docker file is provided in\n[`Dockerfile`](https://github.com/open-quantum-safe/liboqs-python/tree/main/Dockerfile).\n\nBuild the image by executing\n\n```shell\ndocker build -t oqs-python .\n```\n\nRun, e.g., the key encapsulation example by executing\n\n```shell\ndocker run -it oqs-python sh -c \". venv/bin/activate \u0026\u0026 python liboqs-python/examples/kem.py\"\n```\n\nOr, run the unit tests with\n\n```shell\ndocker run -it oqs-python sh -c \". venv/bin/activate \u0026\u0026 nose2 --verbose\"\n```\n\nIn case you want to use the Docker container as a development environment,\nmount your current project in the Docker container with\n\n```shell\ndocker run --rm -it --workdir=/app -v ${PWD}:/app oqs-python /bin/bash\n```\n\nA more comprehensive Docker example is provided in the directory\n[`docker`](https://github.com/open-quantum-safe/liboqs-python/tree/main/docker).\n\n---\n\n## Limitations and security\n\nliboqs is designed for prototyping and evaluating quantum-resistant\ncryptography. Security of proposed quantum-resistant algorithms may rapidly\nchange as research advances, and may ultimately be completely insecure against\neither classical or quantum computers.\n\nWe believe that the NIST Post-Quantum Cryptography standardization project is\ncurrently the best avenue to identifying potentially quantum-resistant\nalgorithms. liboqs does not intend to \"pick winners\", and we strongly recommend\nthat applications and protocols rely on the outcomes of the NIST\nstandardization project when deploying post-quantum cryptography.\n\nWe acknowledge that some parties may want to begin deploying post-quantum\ncryptography prior to the conclusion of the NIST standardization project. We\nstrongly recommend that any attempts to do make use of so-called\n**hybrid cryptography**, in which post-quantum public-key algorithms are used\nalongside traditional public key algorithms (like RSA or elliptic curves) so\nthat the solution is at least no less secure than existing traditional\ncryptography.\n\nJust like liboqs, liboqs-python is provided \"as is\", without warranty of any\nkind. See\n[LICENSE](https://github.com/open-quantum-safe/liboqs-python/blob/main/LICENSE)\nfor the full disclaimer.\n\n---\n\n## License\n\nliboqs-python is licensed under the MIT License; see\n[LICENSE](https://github.com/open-quantum-safe/liboqs-python/blob/main/LICENSE)\nfor details.\n\n---\n\n## Team\n\nThe Open Quantum Safe project is led by\n[Douglas Stebila](https://www.douglas.stebila.ca/research/) and\n[Michele Mosca](http://faculty.iqc.uwaterloo.ca/mmosca/) at the University of\nWaterloo.\n\n### Contributors\n\nContributors to the liboqs-python wrapper include\n\n- Ben Davies (University of Waterloo)\n- Vlad Gheorghiu ([softwareQ Inc.](https://www.softwareq.ca) and the University\n  of Waterloo)\n- Christian Paquin (Microsoft Research)\n- Douglas Stebila (University of Waterloo)\n\n---\n\n## Support\n\nFinancial support for the development of Open Quantum Safe has been provided by\nAmazon Web Services and the Canadian Centre for Cyber Security.\n\nWe'd like to make a special acknowledgement to the companies who have dedicated\nprogrammer time to contribute source code to OQS, including Amazon Web\nServices, evolutionQ, softwareQ, and Microsoft Research.\n\nResearch projects which developed specific components of OQS have been\nsupported by various research grants, including funding from the Natural\nSciences and Engineering Research Council of Canada (NSERC); see the source\npapers for funding acknowledgments.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-quantum-safe%2Fliboqs-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-quantum-safe%2Fliboqs-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-quantum-safe%2Fliboqs-python/lists"}