Skip to main content

A Python implementation of BIP93 (Codex32)

Project description

python-codex32

Python implementation of BIP-0093 (codex32): checksummed, SSSS-aware BIP32 seed strings.

This repository implements the codex32 string format described by BIP-0093. It provides encoding/decoding, short/long ms32 checksums, CRC padding for convertbits, Shamir-share interpolation helpers and helpers to build codex32 strings from seed bytes.

Features

  • Encode/decode codex32 data via from_string and from_unchecksummed_string.
  • Short checksum (13 chars) and long checksum (15 chars) support.
  • CRC-based default padding scheme for convertbits.
  • Construct codex32 strings from raw seed bytes via from_seed.
  • Parse codex32 strings and access parts via Parts.
  • Interpolate/recover shares via interpolate_at.

Installation

pip install codex32

Quick usage

from codex32.codex32 import Codex32String as ms32

# Create a codex32 string from seed bytes (16..64 bytes).
s = ms32.from_seed(
    data=bytes.fromhex('ffeeddccbbaa99887766554433221100'), # seed bytes, length 16..64
    ident="cash",         # 4-character identifier
    hrp="ms",             # human readable part, default 'ms'
    k=3,                  # threshold 0 or 2..9 (0 special: share index must be 's')
    share_idx='s',        # single-char share index (or 's' for k=0)
    pad_val=0             # -1 -> CRC padding, otherwise integer padding value
)
print(c.s)                # codex32 string

# Parse & validate an existing codex32 string
a = ms32.from_string("ms13casha320zyxwvutsrqpnmlkjhgfedca2a8d0zehn8a0t")
parts = c2.parts()       # Parts object
data_bytes = parts.data()  # encoded seed bytes

# Create from unchecksummed data-part (will append checksum)
c = ms32.from_unchecksummed_string("ms13cashcacdefghjklmnpqrstuvwxyz023")

# Interpolate shares to obtain target share index:
# shares is a list of Codex32String objects containing compatible shares
shares = [s, a, c]
derived_share_d = ms32.interpolate_at(shares, target='d')
print(derived_share_d.s)

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

codex32-0.1.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

codex32-0.1.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file codex32-0.1.1.tar.gz.

File metadata

  • Download URL: codex32-0.1.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for codex32-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d99e08d432646c89ee8bdec1f0bad7af7758bee237a8486de3c8a25270b14780
MD5 58413f71e5022f715a9ddf0cbbf73f14
BLAKE2b-256 fadece085c6af9495be25ddcf77964d2601b069fc3e8da79a83ea35fd0b64956

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex32-0.1.1.tar.gz:

Publisher: python-publish.yml on BenWestgate/python-codex32

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

File details

Details for the file codex32-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: codex32-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for codex32-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0cb81865ee00f5a1cd2bae7b6f1c53291fff526904b999759a24e42283fefa57
MD5 26b6b9eedf5ac134cd879970aeb46af5
BLAKE2b-256 e13a0ff1ac10f977a886e253b3685d3766890f8702d24da1cd8eb57b604e4868

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex32-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on BenWestgate/python-codex32

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