python-slip10
A reference implementation of the SLIP-0010 specification, which generalizes the BIP-0032 derivation scheme for private and public key pairs in hierarchical deterministic wallets for the curves secp256k1, NIST P-256, ed25519 and curve25519.
Usage
>>> from slip10 import SLIP10, HARDENED_INDEX
>>> slip10 = SLIP10.from_seed(bytes.fromhex("01"))
# Specify the derivation path as a list ...
>>> slip10.get_xpriv_from_path([1, HARDENED_INDEX, 9998])
'xprv9y4sBgCuub5x2DtbdNBDDCZ3btybk8YZZaTvzV5rmYd3PbU63XLo2QEj6cUt4JAqpF8gJiRKFUW8Vm7thPkccW2DpUvBxASycypEHxmZzts'
# ... Or in usual m/the/path/
>>> slip10.get_xpriv_from_path("m/1/0'/9998")
'xprv9y4sBgCuub5x2DtbdNBDDCZ3btybk8YZZaTvzV5rmYd3PbU63XLo2QEj6cUt4JAqpF8gJiRKFUW8Vm7thPkccW2DpUvBxASycypEHxmZzts'
>>> slip10.get_xpub_from_path([HARDENED_INDEX, 42])
'xpub69uEaVYoN1mZyMon8qwRP41YjYyevp3YxJ68ymBGV7qmXZ9rsbMy9kBZnLNPg3TLjKd2EnMw5BtUFQCGrTVDjQok859LowMV2SEooseLCt1'
# You can also use "h" or "H" to signal for hardened derivation
>>> slip10.get_xpub_from_path("m/0h/42")
'xpub69uEaVYoN1mZyMon8qwRP41YjYyevp3YxJ68ymBGV7qmXZ9rsbMy9kBZnLNPg3TLjKd2EnMw5BtUFQCGrTVDjQok859LowMV2SEooseLCt1'
# You can use pubkey-only derivation
>>> slip10 = SLIP10.from_xpub("xpub6AKC3u8URPxDojLnFtNdEPFkNsXxHfgRhySvVfEJy9SVvQAn14XQjAoFY48mpjgutJNfA54GbYYRpR26tFEJHTHhfiiZZ2wdBBzydVp12yU")
>>> slip10.get_xpub_from_path([42, 43])
'xpub6FL7T3s7GuVb4od1gvWuumhg47y6TZtf2DSr6ModQpX4UFGkQXw8oEVhJXcXJ4edmtAWCTrefD64B9RP4sYSkSumTW1wadTS3SYurBGYccT'
>>> slip10.get_xpub_from_path("m/42/43")
'xpub6FL7T3s7GuVb4od1gvWuumhg47y6TZtf2DSr6ModQpX4UFGkQXw8oEVhJXcXJ4edmtAWCTrefD64B9RP4sYSkSumTW1wadTS3SYurBGYccT'
>>> slip10.get_pubkey_from_path("m/1/1/1/1/1/1/1/1/1/1/1")
b'\x02\x0c\xac\n\xa8\x06\x96C\x8e\x9b\xcf\x83]\x0c\rCm\x06\x1c\xe9T\xealo\xa2\xdf\x195\xebZ\x9b\xb8\x9e'
Installation
pip install slip10
Dependencies
This package uses ecdsa as a wrapper for secp256k1 and secp256r1 elliptic curve operations and cryptography for Ed25519 and curve25519 operations.
Running the test suite
pip3 install poetry
git clone https://github.com/trezor/python-slip10
cd python-slip10
poetry install
poetry run make test
Interface
All public keys below are compressed.
All path below are a list of integers representing the index of the key at each depth.
network is "main" or "test".
curve_name is one of "secp256k1", "secp256r1", "ed25519" or "curve25519".
SLIP10
from_seed(seed, network="main", curve_name="secp256k1")
classmethod
Instanciate from a raw seed (as bytes). See SLIP-0010's master key
generation.
from_xpriv(xpriv)
classmethod
Instanciate with an encoded serialized extended private key (as str) as master.
from_xpub(xpub)
classmethod
Instanciate with an encoded serialized extended public key (as str) as master.
You'll only be able to derive unhardened public keys.
get_child_from_path(path)
Returns a SLIP10 instance of the child pointed by the path.
get_extended_privkey_from_path(path)
Returns (chaincode (bytes), privkey (bytes)) of the private key pointed by the path.
get_privkey_from_path(path)
Returns privkey (bytes), the private key pointed by the path.
get_extended_pubkey_from_path(path)
Returns (chaincode (bytes), pubkey (bytes)) of the public key pointed by the path.
Note that you don't need to have provided the master private key if the path doesn't
include an index >= HARDENED_INDEX.
get_pubkey_from_path(path)
Returns pubkey (bytes), the public key pointed by the path.
Note that you don't need to have provided the master private key if the path doesn't
include an index >= HARDENED_INDEX.
get_xpriv_from_path(path)
Returns xpriv (str) the serialized and encoded extended private key pointed by the given
path.
get_xpub_from_path(path)
Returns xpub (str) the serialized and encoded extended public key pointed by the given
path.
Note that you don't need to have provided the master private key if the path doesn't
include an index >= HARDENED_INDEX.
get_xpriv()
Equivalent to get_xpriv_from_path([]).
get_xpriv_bytes()
Equivalent to get_xpriv([]), but not serialized in base58.
get_xpub()
Equivalent to get_xpub_from_path([]).
get_xpub_bytes()
Equivalent to get_xpub([]), but not serialized in base58.
get_fingerprint()
Returns fingerprint (bytes), equivalent to utils._pubkey_to_fingerprint(self.pubkey).
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog.
[1.1.0] - 2026-02-02
Added
- A new method
get_fingerprint()was added.
Changed
- Drop base58 dependency. Port base58 code directly in-tree as a
base58module. - Drop ecdsa dependency. Replace with own implementation of point addition.
[1.0.1] - 2024-09-03
- Support Python 3.8
[1.0.0] - 2024-08-20
- First release forked from Antoine Poinsot's python-bip32.
Metadata
Release files for slip10 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| slip10-1.1.0.tar.gz | 14.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| slip10-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.3 kB
Release files / slip10-1.1.0.tar.gz
| Download URL | slip10-1.1.0.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d248d3df26f123f08474339c45f0f264254f74ae9a5657234a1d5eb91f0c4d54
|
|
BLAKE2b-256 checksum How to use checksums |
dd7a744be94761ace101a8efc91c467cae673da68bea7e4eb50771cd5583119d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.1 CPython/3.10.12 Linux/6.8.0-94-generic
|
Release files / slip10-1.1.0-py3-none-any.whl
| Download URL | slip10-1.1.0-py3-none-any.whl |
|---|---|
| Size | 14.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9baa9fb463f06321ede45b365d431752201a5d5a9465095e44c93df26053ee3
|
|
BLAKE2b-256 checksum How to use checksums |
d63475d55507e384a795a332e3b1f1f294b9a5ce230c99fa670dd6c727d6dfdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.1 CPython/3.10.12 Linux/6.8.0-94-generic
|
Security for slip10 1.1.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.