Python bindings for libbitcoinpqc
Project description
Python Bindings for libbitcoinpqc
Python bindings for the libbitcoinpqc C library — the three BIP 360 (P2MR) tapscript signature algorithms: secp256k1 Schnorr (BIP 340), ML-DSA-44, and SLH-DSA-SHA2-128s. See BIP 360.
Supported Algorithms
- SECP256K1_SCHNORR (BIP-340): Classical Schnorr signatures with x-only public keys
- ML-DSA-44 (CRYSTALS-Dilithium): Lattice-based post-quantum signatures
- SLH-DSA-SHA2-128s (SPHINCS+): Stateless hash-based post-quantum signatures
Installation
pip install bitcoinpqc
From source (requires the C library built from the bindings submodule):
git clone --recurse-submodules https://github.com/cryptoquick/libbitcoinpqc-bindings.git
cd libbitcoinpqc-bindings
make c-lib
cd python
pip install -e .
Requirements
- Python 3.7 or higher
libbitcoinpqcbuilt viamake c-libor installed system-wide
Example Usage
import secrets
from bitcoinpqc import Algorithm, keygen, sign, verify
# PQC keygen needs 128 bytes of entropy; secp256k1 Schnorr needs 32
random_data = secrets.token_bytes(128)
algorithm = Algorithm.ML_DSA_44
keypair = keygen(algorithm, random_data)
message = b"Hello, Bitcoin PQC!"
signature = sign(algorithm, keypair.secret_key, message)
is_valid = verify(algorithm, keypair.public_key, message, signature)
print(f"Signature valid: {is_valid}")
Breaking Changes (Phase 2)
- Rename
SLH_DSA_SHAKE_128S→SLH_DSA_SHA2_128S - Remove
FN_DSA_512(no longer supported) - Enum wire values:
SECP256K1_SCHNORR=0,ML_DSA_44=1,SLH_DSA_SHA2_128S=2 - Re-keying required: SHAKE-128s keys/signatures are incompatible with SHA2-128s
Running Tests
# From libbitcoinpqc-bindings/python (after make c-lib)
./run_tests.sh
# Or directly
python3 -m unittest discover -s tests -v
License
MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bitcoinpqc-0.4.1.tar.gz
(14.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bitcoinpqc-0.4.1.tar.gz.
File metadata
- Download URL: bitcoinpqc-0.4.1.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5187b8e93be312076dd7c043d8a9b5d4ad50c9364d0038e00686191ee4de7ea2
|
|
| MD5 |
c2cf66e2bf714b7565404798e050ce4d
|
|
| BLAKE2b-256 |
718ee8a8573191bc43fc1206dfb9305b10efc7c3e5c6c9033d0725d3e47e0904
|
File details
Details for the file bitcoinpqc-0.4.1-py3-none-any.whl.
File metadata
- Download URL: bitcoinpqc-0.4.1-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b58c43b7d60f19dc0b4a3cafedef04e02390f44a4f9a6e9badf6415e148c7c0
|
|
| MD5 |
0e28a8c672665553af6be0939f97db3a
|
|
| BLAKE2b-256 |
1431f75b103363519d7be58795a43d7ff7eb0441b6b96680fafb2aad6ae8ef45
|