Skip to main content

base58-bech32

Base58, Base58Check, bech32, bech32m, SS58 and CashAddr: the binary-to-text codecs of cryptocurrency addresses and keys, in typed Python, with nothing of any chain above them.

PyPI version GitHub release development status license downloads supported Python versions implementation wheel

pre-commit.ci status lint workflow status test workflow status docs workflow status documentation build vendored-vectors workflow status mutation workflow status fuzz workflow status deps-latest workflow status pypi-install workflow status deps-oldest workflow status os-macos workflow status os-ubuntu workflow status os-windows workflow status links workflow status sdist-rebuild workflow status codeql workflow status

OpenSSF Scorecard OpenSSF Best Practices OpenSSF Baseline

It is fully annotated and ships py.typed, and it imports nothing but the standard library.

What is here

  • Base58, plain and checked: Bitcoin's alphabet, Ripple's, or any other 58 distinct ascii bytes, and Base58Check's double SHA-256 checksum (base58)
  • bech32 and bech32m, with a length limit the caller sets, bech32_decode's docstring giving the default and why, and convertbits, the regrouping of bytes into 5-bit values and back (bech32)
  • SS58, the address format of Polkadot and the Substrate chains, with both prefix forms (ss58)
  • CashAddr, the address format of Bitcoin Cash (cashaddr)

At the base are exceptions and _utils. The independent base58 and bech32 codecs build on them; ss58 reuses base58, and cashaddr reuses bech32's alphabet and bit regrouping.

Every refusal is a ValueError or a TypeError, under one base, Base58Bech32Exception (exceptions). No decoder's refusal quotes the string it was handed: what reaches a decoder can be a private key.

What the bytes mean -- a witness program, a public key hash, a WIF -- is not here: btclib is the library above this one for bitcoin. The migration page maps each function of the base58 and bech32 packages to its equivalent here.

The suite answers to vectors their authors publish -- Bitcoin Core's, the base58 package's, Substrate's and the CashAddr specification's -- and tests/_data/README.md pins each vendored file to the upstream commit it was copied from.

Installing

python -m pip install --upgrade base58-bech32

An address of each format

from base58_bech32 import base58, bech32, cashaddr, ss58

wif = base58.b58encode_check(bytes.fromhex("80" + "11" * 32 + "01"))
assert base58.b58decode_check(wif, out_size=34)[0] == 0x80

hrp, values, m = bech32.bech32_decode("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4")
# BIP350: bech32 for witness version 0, bech32m for every later one
assert m == (bech32.BECH32_1_CONST if values[0] == 0 else bech32.BECH32_M_CONST)
program = bytes(bech32.convertbits(values[1:], 5, 8, False))
assert (hrp, values[0], program.hex()[:8]) == ("bc", 0, "751e76e8")

alice = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
prefix, account = ss58.ss58_decode(alice)
assert prefix == 42
polkadot = ss58.ss58_encode(0, account)
assert polkadot == b"15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5"

address = "bitcoincash:qr6m7j9njldwwzlg9v7v53unlr4jkmx6eylep8ekg2"
assert cashaddr.cashaddr_decode(address)[:2] == ("bitcoincash", 0)

tests/readme_test.py runs every Python block of this file, so the example above is the one the suite checks.

Security

SECURITY.md says how to report a vulnerability, which versions are supported, and how a published file is traced back to the run that built it. ASSURANCE_CASE.md argues why what it promises holds: the threat model, the trust boundaries, and the weaknesses a package of this kind is exposed to.

Contributing

CONTRIBUTING.md has the commands each CI job runs, verbatim. uv sync creates the environment; uv is the only tool that has to be installed. REVIEWING.md is what a pull request is answered against.

How the organization decides, and who holds which role, is its GOVERNANCE.md; what it intends to do, and what it deliberately does not, is its ROADMAP.md.


The btclib organization and its projects are actively supported by DGI and CheckSig.

Metadata

Release files for base58-bech32 2026.10.23

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for base58-bech32 2026.10.23
File Size Uploaded Provenance
base58_bech32-2026.10.23.tar.gz 565.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for base58-bech32 2026.10.23
File Interpreter ABI Platform
base58_bech32-2026.10.23-py3-none-any.whl Python 3 none any Details

Total release size: 593.7 kB

Release files / base58_bech32-2026.10.23.tar.gz

Download URL base58_bech32-2026.10.23.tar.gz
Size 565.0 kB
Tags Source
SHA-256 checksum
How to use checksums
aeced47802602b9801e9fb9a844bd29a017ce5439408278c998cb2c94c94267a
BLAKE2b-256 checksum
How to use checksums
19b52be07df7539f1fff2c30078add5f0384088340fb9d6562e12d4442125937
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / base58_bech32-2026.10.23-py3-none-any.whl

Download URL base58_bech32-2026.10.23-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcdb9fceff522b9cb8815b25f1c9cbfb5855887d670e19b28bf0988ce4af7c60
BLAKE2b-256 checksum
How to use checksums
6b63c1fa815a46b10faee9a81ed86ff429fb245ba006a1e46889831f38b46c95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Security for base58-bech32 2026.10.23

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for base58_bech32-2026.10.23.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page