Skip to main content

A minimal bitcoin library for MicroPython and CPython 3.10+ 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.1.tar.gz (93.9 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.1-py3-none-any.whl (107.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: embit_sinancrypto-0.8.1.tar.gz
  • Upload date:
  • Size: 93.9 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.1.tar.gz
Algorithm Hash digest
SHA256 6bd2991d0093ce8e969d9c631947c5b4baacb040c9c06e504c758bd0650dfa1b
MD5 29b966411214d2dd23f91e8143838826
BLAKE2b-256 2887bb38e8cdc8ae1111bee2163bfbe8d64d458c070ee0909b0ede8e75703628

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for embit_sinancrypto-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 180b59580bcb1c29dcf43fd1daa49c5a87044072a216677da0330eae35b53bc3
MD5 fe8d9e5a8403a00baba94e3b39ed9b99
BLAKE2b-256 bf36615bf41b82d346d8135803d33e2e072a2c582a542a85f4a18b3959817a57

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