Skip to main content

python-libehsm is a Python wrapper for the ellipticSecure PKCS11 shared library

Note that while the wrapper does export some PKCS#11 helper functions it does so only partially - there are other wrappers available to interface with PKCS#11.

The focus of this wrapper is to export the BIP32/Bitcoin specific functions.

Installation

Download and install the native shared library for your platform here: https://ellipticsecure.com/downloads/

pip install python-libehsm

Example

Signing a transaction hash with a BIP32 (Bitcoin etc.) derived key stored on a MIRkey or eHSM device:

import ehsm

mirkey = ehsm.load_ehsm()
        
# Get the available device slots
slots = mirkey.enumerate_slots()

if len(slots) > 0:        
    # Use the first available slot
    slot = slots[0]
        
    # Initialize the library
    mirkey.init()
    try:
        session = mirkey.get_logged_in_rw_session(slot, b"testsu")
        found = mirkey.bip32_has_root_key(session)
        if found:
            hash = bytes(32)
            # list of integers representing a bip32 path to the derived key
            # 
            # ie. this is "m/0", "m" would be []
            indexes = [0] 
            sig = mirkey.bip32_sign_data(session, hash, indexes)
    finally:
        mirkey.finalize()
else:
    print "No devices found"
    

Please see the test cases for more usage examples.

Metadata

Release files for ehsm 1.0.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 ehsm 1.0.0
File Size Uploaded Provenance Actions
ehsm-1.0.0.tar.gz 8.0 kB Without provenance Details for ehsm-1.0.0.tar.gz

Release files / ehsm-1.0.0.tar.gz

Download URL ehsm-1.0.0.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f5778e614a0135da171476c777b112af90e1107894f4e76fb21773ee4c7f5039
BLAKE2b-256 checksum
How to use checksums
342b304e4b69f32866fa479ae726952c86f7770b8856621a0b8763683830a876
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

Security for ehsm 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

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