pqblocks-core
Post-quantum hybrid cryptography core SDK with C shared libraries and policy enforcement. Use it for native, high-performance hybrid key encapsulation (ML-KEM-768 + X25519) and composite signatures (ML-DSA-65 + Ed25519) with C-speed bindings and policy governance. Standards implemented: NIST FIPS 203 (ML-KEM), NIST FIPS 204 (ML-DSA), RFC 7748 (X25519), RFC 8032 (Ed25519), RFC 5869 (HKDF), and draft-ietf-lamps-pq-composite-sigs.
pip install pqblocks-core
import ctypes, os
import pqblocks_core
# Locate the native hybrid KEM library
lib_path = os.path.join(os.path.dirname(pqblocks_core.__file__), "lib", "libpqblocks_kem.so")
lib = ctypes.CDLL(lib_path)
lib.PQBLOCKS_KEM_X25519_MLKEM768_new.restype = ctypes.c_void_p
# Initialize hybrid KEM handle (ML-KEM-768 + X25519)
kem = lib.PQBLOCKS_KEM_X25519_MLKEM768_new()
assert kem is not None
print("PQBlocks hybrid core initialized successfully.")
Or execute via the bundled pqblocks command-line utility:
pqblocks kem keygen --out kem.json
pqblocks kem encaps --in kem.json --out encaps.json
pqblocks kem decaps --in encaps.json --out shared.key
Why PQBlocks
- Dual-Layer Defense: Combines NIST post-quantum standards with established classical algorithms. Compromising either classical ECDH or ML-KEM alone does not break confidentiality or authenticity.
- Strict Overhead Budgets: C shared libraries achieve under 5% overhead compared to raw standalone primitives, verified by continuous benchmarking (BENCHMARKS.md).
- Misuse-Resistant Envelopes: All outputs are formatted in self-describing cryptographic envelopes specifying suite ID, algorithm parameters, and container lengths.
- Strict Verification: Verified against official NIST ACVP known answer tests with 105 automated test cases (TESTING.md).
- Licence: Apache-2.0.
Usage
Command-Line Interface (CLI)
The package bundles a compiled native pqblocks executable supporting six core commands:
- KEM Key Generation:
pqblocks kem keygen --out kem.json
- KEM Encapsulation:
pqblocks kem encaps --in kem.json --out encaps.json
- KEM Decapsulation:
pqblocks kem decaps --in encaps.json --out shared.key
- Signature Key Generation:
pqblocks sig keygen --out sig.json
- Message Signing:
pqblocks sig sign --in sig.json --msg document.txt --out sig.bin
- Signature Verification:
pqblocks sig verify --in sig.json --msg document.txt --sig sig.bin
Python / C Native Integration
For high-throughput applications, Python applications can interface directly with the bundled C libraries (libpqblocks_kem.so, libpqblocks_sig.so, libpqblocks_policy.so, libpqblocks_errors.so) located in pqblocks_core/lib/. Runnable examples are provided in examples/01_hybrid_kem_exchange.py and examples/02_hybrid_signature.py.
API Reference
C Interface (pqblocks_core/lib/)
void *PQBLOCKS_KEM_X25519_MLKEM768_new(void): Allocates and initializes a hybrid KEM instance.void PQBLOCKS_KEM_X25519_MLKEM768_free(void *kem): Safely zeroes and deallocates a KEM instance.int PQBLOCKS_KEM_X25519_MLKEM768_encaps(const void *kem, uint8_t *ct, size_t *ct_len, uint8_t *ss, size_t *ss_len, char **env_json): Encapsulates a 32-byte shared secret into an 1120-byte ciphertext.int PQBLOCKS_KEM_X25519_MLKEM768_decaps(const void *kem, const uint8_t *ct, size_t ct_len, const char *env_json, uint8_t *ss, size_t *ss_len): Decapsulates a shared secret from ciphertext and validating envelope.void *PQBLOCKS_SIG_ED25519_MLDSA65_new(void): Allocates and initializes a composite signature instance.void PQBLOCKS_SIG_ED25519_MLDSA65_free(void *sig): Safely zeroes and deallocates a signature instance.int PQBLOCKS_SIG_ED25519_MLDSA65_sign(const void *sig, const uint8_t *msg, size_t msg_len, uint8_t *out_sig, size_t *sig_len, char **env_json): Generates a 3373-byte composite signature.int PQBLOCKS_SIG_ED25519_MLDSA65_verify(const void *sig, const uint8_t *msg, size_t msg_len, const uint8_t *in_sig, size_t sig_len, const char *env_json): Verifies signature validity.const char *PQBLOCKS_strerror(int err): Returns human-readable error descriptions.
Limitations
- Platform Support: Pre-compiled native libraries are built for Linux x86_64. Other platforms require compiling C sources against liboqs.
- External Dependency: Dynamic linking requires
liboqs.so.9present on the system search path or in~/.local/lib. - Not FIPS/CMVP Validated: While tested against official NIST ACVP KAT corpora, this package has not undergone formal CMVP/FIPS 140 certification.
Security Notes
See SECURITY_NOTES.md for details on zeroization, side-channel posture, memory safety, and hostile input handling.
Verification
Full verification artifacts, test matrices, and reproducibility evidence:
- BENCHMARKS.md — Exact performance metrics and overhead validation.
- TESTING.md — Test suites, coverage metrics, and ACVP KAT vectors.
- EVIDENCE.md — Standards citations and method-to-code mapping.
- VERIFICATION_REPORT.md — Self-verification report and defect registry.
Part of PQBlocks
pqblocks-core is the foundational cryptographic engine of the PQBlocks post-quantum ecosystem:
pqblocks-jose: Hybrid PQC JSON Web Encryption and Signatures.pqblocks-wire: Cryptographic wire format and envelope compatibility.pqblocks-scan: Quantum-readiness and cryptographic discovery scanner.pqblocks-lint: Static AST analysis for migration linting.pqblocks-agility: Cryptographic Bill of Materials (CBOM) and agility assessment.
Metadata
Release files for pqblocks-core 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pqblocks_core-0.1.0.tar.gz | 10.5 MB | Without provenance | Details for pqblocks_core-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pqblocks_core-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pqblocks_core-0.1.0-py3-none-any.whl |
Total release size: 21.1 MB
Release files / pqblocks_core-0.1.0.tar.gz
| Download URL | pqblocks_core-0.1.0.tar.gz |
|---|---|
| Size | 10.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2834bcfb3e12f5e9e517d38c290ff56b138769068460304695fdb5efdd103c9e
|
|
BLAKE2b-256 checksum How to use checksums |
7a80298831e8e29d6b07ee4179212f77b7f023f035ea9ef5c94f9350f116add5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Garuda Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / pqblocks_core-0.1.0-py3-none-any.whl
| Download URL | pqblocks_core-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
119fbf74bce71f6522e0973af2c2a6ef09470c0e5e64c169a7ea9dd0b3c04337
|
|
BLAKE2b-256 checksum How to use checksums |
705afd76e717ce43483f7a1b547ce4f2f2503db853038814fffed3226f6535ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Garuda Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for pqblocks-core 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.