Skip to main content

embit

A minimal bitcoin library for MicroPython and Python3 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 Python3.

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 installation includes prebuilt libraries for common platforms (win, macos, linux, raspi) - see src/embit/util/prebuilt/ folder. Library is built from libsecp-zkp fork for Liquid support, but will work with pure libsecp256k1 as well - just Liquid functionality doesn't work. If it fails to use the prebuilt or system library it will fallback to pure python implementation.

If you want to build the lib yourself, 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

Metadata

Release files for embit 0.8.0

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

Source distribution (sdist)

Source distribution for embit 0.8.0
File Size Uploaded
embit-0.8.0.tar.gz 763.1 kB Details

Release files / embit-0.8.0.tar.gz

Download URL embit-0.8.0.tar.gz
Size 763.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8bf4b10073c67400370ce523fb16f035fe759f6fdd987c579bdcc268d75ed770
BLAKE2b-256 checksum
How to use checksums
8388b054b00ade6d2a41749e15976cdcec4b7ec4656ac1cb917ce3de395528d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.8.0 This release

1 release file

0.7.0

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.14

1 release file

0.4.13

1 release file

0.4.12

1 release file

0.4.11

1 release file

0.4.10

1 release file

0.4.9

1 release file

0.4.8

1 release file

0.4.7

1 release file

0.4.6

1 release file

0.4.5

1 release file

0.4.4

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

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