Skip to main content

Python bindings for libbitcoinpqc

Project description

Python Bindings for libbitcoinpqc

This package provides Python bindings for the libbitcoinpqc library, which implements post-quantum cryptographic signature algorithms for use with BIP-360 and the Bitcoin QuBit soft fork.

Supported Algorithms

  • ML-DSA-44 (CRYSTALS-Dilithium): A structured lattice-based digital signature scheme
  • SLH-DSA-Shake-128s (SPHINCS+): A stateless hash-based signature scheme
  • FN-DSA-512 (FALCON): A lattice-based signature scheme designed for efficiency

Installation

# Install the package
pip install bitcoinpqc

or from source:

# Clone the repository
git clone https://github.com/bitcoin/libbitcoinpqc.git
cd libbitcoinpqc

# Build the C library
mkdir build && cd build
cmake ..
make
cd ..

# Install the Python package
cd python
pip install -e .

Requirements

  • Python 3.7 or higher
  • The libbitcoinpqc C library must be built and installed

Example Usage

import secrets
from bitcoinpqc import Algorithm, keygen, sign, verify

# Generate random data for key generation
random_data = secrets.token_bytes(128)

# Generate a key pair
algorithm = Algorithm.ML_DSA_44  # CRYSTALS-Dilithium
keypair = keygen(algorithm, random_data)

# Create a message to sign
message = b"Hello, Bitcoin PQC!"

# Sign the message
signature = sign(algorithm, keypair.secret_key, message)

# Verify the signature
is_valid = verify(algorithm, keypair.public_key, message, signature)
print(f"Signature valid: {is_valid}")  # Should print True

Running Tests

# Run the tests
./run_tests.sh

# Or using unittest directly
python -m unittest discover -s tests

License

This project is licensed under the MIT License.

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

bitcoinpqc-0.1.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitcoinpqc-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file bitcoinpqc-0.1.0.tar.gz.

File metadata

  • Download URL: bitcoinpqc-0.1.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for bitcoinpqc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 532313653aac3cc6fac57c1bafc595298d75c04ec149291a6915b45abd224411
MD5 e3f0cbe2eb4270fdee5f0467ce7ee6fc
BLAKE2b-256 3bb938b599145d05b6d09d08432a28ce8bd913e9734d45700e84fa861e3b2061

See more details on using hashes here.

File details

Details for the file bitcoinpqc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bitcoinpqc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for bitcoinpqc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce21411046748828240c8d5de504b8ad4cf52ebf6c840eb797a7b67108a957e0
MD5 16bea8a61b5d917234ae6d2acaa7bf37
BLAKE2b-256 cb5c09bd0cf088f6ac5f861035eb43618266c41431e6f4478b1b159fb3e6c985

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page