Registry / security / liboqs-python

liboqs-python

JSON →
library0.15.0pypypiunverified

Python bindings for liboqs, an open-source C library for post-quantum public key cryptography algorithms (KEMs and signature schemes). Version 0.15.0 supports liboqs 0.12.0+ and Python >=3.10. Release cadence follows liboqs, roughly quarterly.

pip install liboqs-python
INSTALL
IMPORT
SIG · LIBOQS-PYTHON
L
liboqs-python
securitypythonv0.15.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

liboqs
import liboqs
KeyEncapsulation
from liboqs import KeyEncapsulation
from liboqs_python import KeyEncapsulation
The library is installed as 'liboqs', not 'liboqs_python'. Common mistake.
Signature
from liboqs import Signature
from liboqs_python import Signature
Same as above.

Basic key encapsulation using Kyber768.

import liboqs # Enumerate supported KEMs kems = liboqs.get_enabled_kem_mechanisms() print(f"Number of enabled KEMs: {len(kems)}") # Create a KEM object for Kyber768 kem = liboqs.KeyEncapsulation("Kyber768") # Generate keypair public_key = kem.generate_keypair() # Export secret key (optional, for storage) secret_key = kem.export_secret_key() # Encapsulate (by another party) kem_client = liboqs.KeyEncapsulation("Kyber768") ciphertext, shared_secret_server = kem.encap_secret(public_key) # Decapsulate (by the original party) shared_secret_client = kem.decap_secret(ciphertext) assert shared_secret_server == shared_secret_client print("Key encapsulation successful!")
Debug
Known issues
breakingThe library name changed from 'liboqs-python' to 'liboqs'? In older versions, import was 'liboqs' as well. No breaking change here, but pre-built wheels may not be available for all platforms, requiring manual liboqs installation.
fix
Install liboqs system-wide (e.g., via conda or building from source) if pip wheel fails.
affects: All
gotchaThe same KeyEncapsulation/Signature object cannot be used for both key generation and encapsulation/verification from different roles. Be careful to create separate instances for client and server.
fix
Create separate KeyEncapsulation objects: one for key generation/decapsulation (server), one for encapsulation (client).
affects: All
deprecatedSome older algorithm names (e.g., 'Kyber512', 'Kyber1024') are being replaced by standardized names (e.g., 'ML-KEM-512', 'ML-KEM-1024') in liboqs 0.12.0+. Using old names still works but may be deprecated.
fix
Use new NIST standard names (e.g., 'ML-KEM-768' instead of 'Kyber768') where supported.
affects: >=0.12.0
gotchaEnabling algorithms: The library does not enable all algorithms by default. Some may be disabled at compile time. Check with get_enabled_kem_mechanisms() or get_enabled_sig_mechanisms().
fix
If an algorithm is not found, rebuild liboqs with appropriate flags or use a different one.
affects: All
Upgrade
Version history
0.15.0latest on PyPI
Audit
Dependencies
liboqs (shared library)optionalliboqs-python requires the liboqs shared library (e.g., liboqs.so) to be installed separately, or use a pre-built wheel that bundles it.
Agent activity
8 hits · last 30 days
node
8
Resources

No resource links recorded.

liboqs-python — pip install liboqs-python · libregistry