Skip to main content

A professional library For Cryptography and Cryptocurrencies in Python.

Project description

Python Version License

LibCrypto

A professional library for Cryptography and Cryptocurrencies in Python.

This library provides a comprehensive suite of tools for developers working with cryptocurrencies, focusing on key management and address generation with a clean, high-level API.

Key Features

  • High-Level Wallet API: A simple Wallet class to manage keys and addresses.
  • Multi-Currency Support: Correctly generate addresses for numerous secp256k1-based cryptocurrencies, including:
    • Bitcoin (BTC) - Legacy, SegWit (P2SH & Native)
    • Ethereum (ETH)
    • Tron (TRX)
    • Ripple (XRP)
    • Bitcoin Cash (BCH) - CashAddr format
    • Litecoin (LTC)
    • Dash (DASH)
    • Dogecoin (DOGE)
  • Hierarchical Deterministic (HD) Wallets: Full BIP32 support for generating wallets from a master seed.
  • BIP39 Mnemonic Support: Generate, validate, and derive seeds from mnemonic phrases.
  • Key & Format Conversions: Easily convert between WIF, Hex, and Bytes for private and public keys.
  • Powerful Command-Line Interface: Perform common wallet operations directly from your terminal.

Installation

Install the library using pip:

pip install libcrypto

Install On Debian/Ubuntu

sudo apt-get install build-essential python3-dev
pip3 install libcrypto

Install On Fedora

sudo yum install gcc gmp python-devel
pip3 install libcrypto

Windows Installation

[!NOTE] Once only Download Build Tools for Visual Studio 2019. In the installer, select the C++ build tools, the Windows 10 SDK, and the latest version of MSVC v142 x64/x86 build tools.

Dependencies

The library uses:

  • Python stdlib: hashlib, hmac, os.urandom for hashing and random number generation
  • Pure Python: Custom secp256k1 elliptic curve implementation

Verification

Verify the library works without external crypto dependencies:

python verify_no_deps.py

Quick Start (Library Usage)

from libcrypto import Wallet

key = "Your private key here (hex)"
# Initialize the Wallet with the private key
# Replace "Your private key here (hex)" with your actual private key in hexadecimal format
wallet = Wallet(key)
# Generate P2PKH, P2SH-P2WPKH, P2WPKH addresses for Bitcoin
p2pkh = wallet.get_address(coin="bitcoin", address_type="p2pkh")
p2wsh = wallet.get_address(coin="bitcoin", address_type="p2sh-p2wpkh")
p2wpkh = wallet.get_address(coin="bitcoin", address_type="p2wpkh")
# Generate ethereum Address
ethereum_address = wallet.get_address(coin="ethereum")
# Generate Dash Address
dash = wallet.get_address(coin="dash")
# Generate Dogecoin Address
dogecoin_address = wallet.get_address(coin="dogecoin")
# Generate Tron Address
tron_address = wallet.get_address(coin="tron")
# Generate Ripple Address
ripple_address = wallet.get_address(coin="ripple")
# Generate Litecoin Address
litecoin_address = wallet.get_address(coin="litecoin")
# Generate Litecoin Address with specific address types
litecoin_address_p2pkh = wallet.get_address(coin="litecoin", address_type="p2pkh")
litecoin_address_p2wsh = wallet.get_address(coin="litecoin", address_type="p2sh-p2wpkh")
litecoin_address_p2wpkh = wallet.get_address(coin="litecoin", address_type="p2wpkh")

The library is designed to be straightforward. Here is a basic example of generating addresses from an existing private key.

from libcrypto import Wallet

# Initialize a wallet from a WIF private key
wif_key = "L4ZQks37JHUadEqaj2nGB1eaZFcsRZwZGQ7WVYuQiztzg4pqopU6"  # Example WIF key
wallet = Wallet(wif_key)

# Generate addresses for different coins
eth_address = wallet.get_address('ethereum')
btc_address = wallet.get_address('bitcoin', address_type='p2wpkh') # Native SegWit
bch_address = wallet.get_address('bitcoin_cash')

print(f"Ethereum Address: {eth_address}")
print(f"Bitcoin (SegWit) Address: {btc_address}")
print(f"Bitcoin Cash Address: {bch_address}")

CLI

Quick Start (Command-Line Interface)

# version
libcrypto -v

Package Information:

libcrypto info

Wallet & Address Generation

  • Generate a Wallet: This is the main command for generating new wallets or deriving addresses from existing keys.
libcrypto generate [OPTIONS]

Options:

  • -p, --private-key TEXT: Derive addresses from an existing private key (WIF or Hex format). If omitted, a new random wallet is generated.
  • -c, --coin TEXT: Specify a coin to generate addresses for. This option can be used multiple times. Defaults to bitcoin and ethereum.
  1. Generate a new wallet for Bitcoin and Litecoin:
libcrypto generate -c bitcoin -c litecoin
  1. Generate a wallet from an existing private key:
libcrypto generate -p <your-private-key>
  1. Derive addresses for a specific set of coins from a hex key:
libcrypto generate -p <your-hex-key> -c bitcoin -c ethereum -c dash -c tron

Mnemonic Management

The mnemonic subcommand is used for all BIP39 mnemonic phrase operations. Generate a Mnemonic Phrase

Creates a new, cryptographically secure BIP39 mnemonic phrase.

libcrypto mnemonic generate [OPTIONS]

Options:

  • -w, --words INTEGER: The number of words in the mnemonic. Can be 12, 15, 18, 21, or 24. [Default: 12]

Example:

libcrypto mnemonic generate --words 24

Validate a Mnemonic Phrase

Checks if a given BIP39 mnemonic phrase is valid according to the checksum rules.

libcrypto mnemonic validate "PHRASE"

Arguments:

  • PHRASE: The full mnemonic phrase, enclosed in double quotes. [Required]

Example:

libcrypto mnemonic validate "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"

Donate

If you find this library useful, consider supporting its development:

  • Bitcoin (BTC): 1MMDRZAcM6dzmdMUSV8pDdAPDFpwzve9Fc

Contact

For support or inquiries, please contact us at pymmdrza@gmail.com.

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

libcrypto-1.5.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

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

libcrypto-1.5.0-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file libcrypto-1.5.0.tar.gz.

File metadata

  • Download URL: libcrypto-1.5.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for libcrypto-1.5.0.tar.gz
Algorithm Hash digest
SHA256 20c7ab9828532afee4fa927c8c7559dfc700285cacc2c6bab70b2c32faf7dcdd
MD5 899cc0bb02aaea4d5c4b7875e12beab5
BLAKE2b-256 2ea899ac6cdef37e679c9ab4a0d31cc5e8b64dbaf0f66a41cc2b005f08575470

See more details on using hashes here.

Provenance

The following attestation bundles were made for libcrypto-1.5.0.tar.gz:

Publisher: deploy-pypi-release.yaml on Pymmdrza/libcrypto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libcrypto-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: libcrypto-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for libcrypto-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4bd3acf0233e2bf26b5730b6c74dcc0cc31f469004e6fa3d6a15bd237c4c3d56
MD5 be0d873d66605010205c34f7791a5443
BLAKE2b-256 d19d0ee5fbdeb7fc82274d03d7b68e0c022ea21f0d97d77c2e51ad7b63beabf0

See more details on using hashes here.

Provenance

The following attestation bundles were made for libcrypto-1.5.0-py3-none-any.whl:

Publisher: deploy-pypi-release.yaml on Pymmdrza/libcrypto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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