apduboy
APDUs for Humans ™️
apduboy provides a collection of Pythonic stubs that generate APDUs to communicate with the Ledger Nano S/X hardware wallet.
Installing
pip install apduboy
Examples
Retrieve Ethereum addresses
from ledgerwallet.client import LedgerClient
from ledgerwallet.transport import enumerate_devices
from apduboy.ethereum import GetEthPublicAddressOpts, get_eth_public_address
from apduboy.lib.bip32 import h, m
client = LedgerClient(enumerate_devices()[0])
opts = GetEthPublicAddressOpts(display_address=False, return_chain_code=False)
for index in range(5):
path = m / h(44) / h(60) / h(index) / 0 / 0
cmd = get_eth_public_address(path=path, opts=opts)
response = cmd(client)
print(f"Address at path {path} => 0x{response.address}")
Retrieve Bitcoin addresses
from ledgerwallet.client import LedgerClient
from ledgerwallet.transport import enumerate_devices
from apduboy.bitcoin import GetWalletPublicKeyOpts, get_wallet_public_key
from apduboy.lib.bip32 import h, m
client = LedgerClient(enumerate_devices()[0])
path = m / h(84) / h(1) / h(7) / 0 / 1234
opts = GetWalletPublicKeyOpts(display_address=False, scheme=None)
cmd = get_wallet_public_key(path=path, opts=opts)
response = cmd(client)
print(f"Address at path {path} => {response.address}")
Generate a cryptographically secure random number
from ledgerwallet.client import LedgerClient
from ledgerwallet.transport import enumerate_devices
from apduboy.bitcoin import get_random
client = LedgerClient(enumerate_devices()[0])
cmd = get_random()
response = cmd(client)
print(f"True Random Number (hex): {response.hex()}")
Sign Ethereum Transaction
from apduboy.ethereum import Ether, GWei, Transaction, sign_transaction
from apduboy.lib.bip32 import h, m
path = m / h(44) / h(60) / h(777) / 0 / 0
tx = Transaction(
nonce=0,
gas_price=50 * GWei,
gas=21000,
data=b"",
to=bytes.fromhex("004ec07d2329997267ec62b4166639513386f32e"),
value=32 * Ether,
)
cmd = sign_transaction(path=path, tx=tx)
response = cmd(device) # device can be anything that provides an APDU exchange.
apduboy is currently in alpha. Please do NOT use this for signing real transactions.
Metadata
Release files for apduboy 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apduboy-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for apduboy-0.5.0-py3-none-any.whl |
Release files / apduboy-0.5.0-py3-none-any.whl
| Download URL | apduboy-0.5.0-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f2f8b88b1ad051d0dd40d3921dc92e8534ec6250766c2b35d9038905fec94ac
|
|
BLAKE2b-256 checksum How to use checksums |
a15e915b6f233745a978cae13481c7da2a99eae8a48d191bd2bb44ff18413d1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10
|
Security for apduboy 0.5.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.