Skip to main content

A minimal bitcoin library for MicroPython and CPython 3.7+ with a focus on embedded systems.

Project description

embit

A minimal bitcoin library for MicroPython and Python 3.10+ with a focus on embedded systems.

Should remain minimal to fit in a microcontroller. Also easy to audit.

Examples can be found in examples/ folder.

Documentation: https://embit.rocks/

Support the project: bc1qd4flfrxjctls9ya244u39hd67pcprhvka723gv

Requirements

MicroPython

Requires a custom MicroPython build with extended hashlib module and secp256k1 bindings.

To install copy the content of embit folder to the board. To save some space you can remove files embit/util/ctypes_secp256k1.py and embit/util/pyhashlib.py - they are used only in CPython.

Python 3

To install run pip3 install embit.

To install in development mode (editable) clone and run pip3 install -e . from the root folder.

PyPI artifacts are pure Python and do not bundle prebuilt libsecp256k1 binaries. If a compatible system libsecp256k1 is installed, embit can use the ctypes backend. If no compatible system library is available, embit automatically falls back to the pure Python implementation. ctypes library discovery order is:

  1. secp256k1/secp256k1-zkp/.libs (repo-local build outputs)
  2. system loader (libsecp256k1)
  3. system loader (secp256k1)
  4. src/embit/util/prebuilt/* (compatibility-only path; no binaries are shipped in package artifacts)

To build and install libsecp256k1 locally, see: Building secp256k1 for embit.

Using non-English BIP39 wordlists

BIP39 defines wordlists for:

  • English
  • Japanese
  • Korean
  • Spanish
  • Chinese (Simplified)
  • Chinese (Traditional)
  • French
  • Italian
  • Czech
  • Portuguese

embit assumes English and does not include the other wordlists in order to keep this as slim as possible.

However, you can override this default by providing an alternate wordlist to any of the mnemonic-handling methods:

spanish_wordlist = [
    "ábaco",
    "abdomen",
    "abeja",
    "abierto",
    "abogado",
    "abono",
    "aborto",
    "abrazo",
    "abrir",
    "abuelo",
    ...
]

mnemonic_is_valid(mnemonic, wordlist=spanish_wordlist)
mnemonic_to_seed(mnemonic, wordlist=spanish_wordlist)
mnemonic_to_bytes(mnemonic, wordlist=spanish_wordlist)
mnemonic_from_bytes(bytes_data, wordlist=spanish_wordlist)

Development

Install in developer mode with dev dependencies:

pip install -e .[dev]

Install pre-commit hook:

pre-commit install

Run tests with desktop python:

pytest

Run tests with micropython:

cd tests
micropython ./run_tests.py

Inspect built package contents (latest wheel and sdist from dist/):

python tools/package_inspect.py

This helper prints selected package metadata (Name, Version, Requires-Python, dependencies/extras, project URLs) and full file lists for both artifacts.

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

embit_sinancrypto-0.8.2.tar.gz (94.1 kB view details)

Uploaded Source

Built Distribution

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

embit_sinancrypto-0.8.2-py3-none-any.whl (107.7 kB view details)

Uploaded Python 3

File details

Details for the file embit_sinancrypto-0.8.2.tar.gz.

File metadata

  • Download URL: embit_sinancrypto-0.8.2.tar.gz
  • Upload date:
  • Size: 94.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for embit_sinancrypto-0.8.2.tar.gz
Algorithm Hash digest
SHA256 38a229c55837f71cb85e47e4fd3fe0c85286275188508f09e7158bc49051d9a6
MD5 593d29b430e6daa44294152368c422b9
BLAKE2b-256 fae24a961fcd13a3a23980fbeddf29457e684b5b181a97e27b4272b3c69bd42f

See more details on using hashes here.

File details

Details for the file embit_sinancrypto-0.8.2-py3-none-any.whl.

File metadata

File hashes

Hashes for embit_sinancrypto-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 70af8f4999b499154abd0154eec4abee6bc6d8ff44419ad3ccefb69341b46c06
MD5 1927eed2943343c579743f2a59a8ff29
BLAKE2b-256 33342919afb9cb70e1b219608512569d0febc07a6edaeb38654bc5593dcbf4a9

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