Name | slip10 JSON |
Version |
1.0.1
JSON |
| download |
home_page | https://github.com/trezor/python-slip10 |
Summary | 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. |
upload_time | 2024-09-03 13:50:40 |
maintainer | Andrew R. Kozlik |
docs_url | None |
author | Antoine Poinsot |
requires_python | <4.0,>=3.8 |
license | MIT |
keywords |
bitcoin
slip10
hdwallet
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# python-slip10
A reference implementation of the [SLIP-0010](https://github.com/satoshilabs/slips/blob/master/slip-0010.md) specification, which generalizes the [BIP-0032](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) derivation scheme for private and public key pairs in hierarchical deterministic wallets for the curves secp256k1, NIST P-256, ed25519 and curve25519.
## Usage
```python
>>> 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`](https://pypi.org/project/ecdsa/) as a wrapper for secp256k1 and secp256r1 elliptic curve operations and [`cryptography`](https://pypi.org/project/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](https://github.com/satoshilabs/slips/blob/master/slip-0010.md#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
## 1.0.1
- Support Python 3.8
## 1.0.0
- First release forked from Antoine Poinsot's python-bip32.
Raw data
{
"_id": null,
"home_page": "https://github.com/trezor/python-slip10",
"name": "slip10",
"maintainer": "Andrew R. Kozlik",
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": "andrew.kozlik@satoshilabs.com",
"keywords": "bitcoin, slip10, hdwallet",
"author": "Antoine Poinsot",
"author_email": "darosior@protonmail.com",
"download_url": "https://files.pythonhosted.org/packages/7b/30/6ba9170f06c61f82b4f66bacefd13819a295798f959027a0600211d8f7ad/slip10-1.0.1.tar.gz",
"platform": null,
"description": "# python-slip10\n\nA reference implementation of the [SLIP-0010](https://github.com/satoshilabs/slips/blob/master/slip-0010.md) specification, which generalizes the [BIP-0032](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) derivation scheme for private and public key pairs in hierarchical deterministic wallets for the curves secp256k1, NIST P-256, ed25519 and curve25519.\n\n## Usage\n\n```python\n>>> from slip10 import SLIP10, HARDENED_INDEX\n>>> slip10 = SLIP10.from_seed(bytes.fromhex(\"01\"))\n# Specify the derivation path as a list ...\n>>> slip10.get_xpriv_from_path([1, HARDENED_INDEX, 9998])\n'xprv9y4sBgCuub5x2DtbdNBDDCZ3btybk8YZZaTvzV5rmYd3PbU63XLo2QEj6cUt4JAqpF8gJiRKFUW8Vm7thPkccW2DpUvBxASycypEHxmZzts'\n# ... Or in usual m/the/path/\n>>> slip10.get_xpriv_from_path(\"m/1/0'/9998\")\n'xprv9y4sBgCuub5x2DtbdNBDDCZ3btybk8YZZaTvzV5rmYd3PbU63XLo2QEj6cUt4JAqpF8gJiRKFUW8Vm7thPkccW2DpUvBxASycypEHxmZzts'\n>>> slip10.get_xpub_from_path([HARDENED_INDEX, 42])\n'xpub69uEaVYoN1mZyMon8qwRP41YjYyevp3YxJ68ymBGV7qmXZ9rsbMy9kBZnLNPg3TLjKd2EnMw5BtUFQCGrTVDjQok859LowMV2SEooseLCt1'\n# You can also use \"h\" or \"H\" to signal for hardened derivation\n>>> slip10.get_xpub_from_path(\"m/0h/42\")\n'xpub69uEaVYoN1mZyMon8qwRP41YjYyevp3YxJ68ymBGV7qmXZ9rsbMy9kBZnLNPg3TLjKd2EnMw5BtUFQCGrTVDjQok859LowMV2SEooseLCt1'\n# You can use pubkey-only derivation\n>>> slip10 = SLIP10.from_xpub(\"xpub6AKC3u8URPxDojLnFtNdEPFkNsXxHfgRhySvVfEJy9SVvQAn14XQjAoFY48mpjgutJNfA54GbYYRpR26tFEJHTHhfiiZZ2wdBBzydVp12yU\")\n>>> slip10.get_xpub_from_path([42, 43])\n'xpub6FL7T3s7GuVb4od1gvWuumhg47y6TZtf2DSr6ModQpX4UFGkQXw8oEVhJXcXJ4edmtAWCTrefD64B9RP4sYSkSumTW1wadTS3SYurBGYccT'\n>>> slip10.get_xpub_from_path(\"m/42/43\")\n'xpub6FL7T3s7GuVb4od1gvWuumhg47y6TZtf2DSr6ModQpX4UFGkQXw8oEVhJXcXJ4edmtAWCTrefD64B9RP4sYSkSumTW1wadTS3SYurBGYccT'\n>>> slip10.get_pubkey_from_path(\"m/1/1/1/1/1/1/1/1/1/1/1\")\nb'\\x02\\x0c\\xac\\n\\xa8\\x06\\x96C\\x8e\\x9b\\xcf\\x83]\\x0c\\rCm\\x06\\x1c\\xe9T\\xealo\\xa2\\xdf\\x195\\xebZ\\x9b\\xb8\\x9e'\n```\n\n## Installation\n\n```\npip install slip10\n```\n\n### Dependencies\n\nThis package uses [`ecdsa`](https://pypi.org/project/ecdsa/) as a wrapper for secp256k1 and secp256r1 elliptic curve operations and [`cryptography`](https://pypi.org/project/cryptography/) for Ed25519 and curve25519 operations.\n\n### Running the test suite\n\n```\npip3 install poetry\ngit clone https://github.com/trezor/python-slip10\ncd python-slip10\npoetry install\npoetry run make test\n```\n\n## Interface\n\nAll public keys below are compressed.\n\nAll `path` below are a list of integers representing the index of the key at each depth.\n\n`network` is \"main\" or \"test\".\n\n`curve_name` is one of \"secp256k1\", \"secp256r1\", \"ed25519\" or \"curve25519\".\n\n### SLIP10\n\n#### from_seed(seed, network=\"main\", curve_name=\"secp256k1\")\n\n__*classmethod*__\n\nInstanciate from a raw seed (as `bytes`). See [SLIP-0010's master key\ngeneration](https://github.com/satoshilabs/slips/blob/master/slip-0010.md#master-key-generation).\n\n#### from_xpriv(xpriv)\n\n__*classmethod*__\n\nInstanciate with an encoded serialized extended private key (as `str`) as master.\n\n#### from_xpub(xpub)\n\n__*classmethod*__\n\nInstanciate with an encoded serialized extended public key (as `str`) as master.\n\nYou'll only be able to derive unhardened public keys.\n\n#### get_child_from_path(path)\n\nReturns a SLIP10 instance of the child pointed by the path.\n\n#### get_extended_privkey_from_path(path)\n\nReturns `(chaincode (bytes), privkey (bytes))` of the private key pointed by the path.\n\n#### get_privkey_from_path(path)\n\nReturns `privkey (bytes)`, the private key pointed by the path.\n\n#### get_extended_pubkey_from_path(path)\n\nReturns `(chaincode (bytes), pubkey (bytes))` of the public key pointed by the path.\n\nNote that you don't need to have provided the master private key if the path doesn't\ninclude an index `>= HARDENED_INDEX`.\n\n#### get_pubkey_from_path(path)\n\nReturns `pubkey (bytes)`, the public key pointed by the path.\n\nNote that you don't need to have provided the master private key if the path doesn't\ninclude an index `>= HARDENED_INDEX`.\n\n#### get_xpriv_from_path(path)\n\nReturns `xpriv (str)` the serialized and encoded extended private key pointed by the given\npath.\n\n#### get_xpub_from_path(path)\n\nReturns `xpub (str)` the serialized and encoded extended public key pointed by the given\npath.\n\nNote that you don't need to have provided the master private key if the path doesn't\ninclude an index `>= HARDENED_INDEX`.\n\n#### get_xpriv()\n\nEquivalent to `get_xpriv_from_path([])`.\n\n#### get_xpriv_bytes()\n\nEquivalent to `get_xpriv([])`, but not serialized in base58\n\n#### get_xpub()\n\nEquivalent to `get_xpub_from_path([])`.\n\n#### get_xpub_bytes()\n\nEquivalent to `get_xpub([])`, but not serialized in base58\n\n## 1.0.1\n\n- Support Python 3.8\n\n## 1.0.0\n\n- First release forked from Antoine Poinsot's python-bip32.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "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.",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/trezor/python-slip10",
"Repository": "https://github.com/trezor/python-slip10"
},
"split_keywords": [
"bitcoin",
" slip10",
" hdwallet"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8ecb6547206300861cfbdf8e105ea6e76132550daf48039b7ac9efc9f41f8c27",
"md5": "3bf8deb8b6e3d875da762b40d53fb22a",
"sha256": "4aa764369db0a261e468160ec1afeeb2b22d26392dd118c49b9daa91f642947b"
},
"downloads": -1,
"filename": "slip10-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3bf8deb8b6e3d875da762b40d53fb22a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 10708,
"upload_time": "2024-09-03T13:50:38",
"upload_time_iso_8601": "2024-09-03T13:50:38.884921Z",
"url": "https://files.pythonhosted.org/packages/8e/cb/6547206300861cfbdf8e105ea6e76132550daf48039b7ac9efc9f41f8c27/slip10-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7b306ba9170f06c61f82b4f66bacefd13819a295798f959027a0600211d8f7ad",
"md5": "820fc977853e30df7092792b44ea2bb6",
"sha256": "02b350ae557b591791428b17551f95d7ac57e9211f37debdc814c90b4a123a54"
},
"downloads": -1,
"filename": "slip10-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "820fc977853e30df7092792b44ea2bb6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 11164,
"upload_time": "2024-09-03T13:50:40",
"upload_time_iso_8601": "2024-09-03T13:50:40.537411Z",
"url": "https://files.pythonhosted.org/packages/7b/30/6ba9170f06c61f82b4f66bacefd13819a295798f959027a0600211d8f7ad/slip10-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-03 13:50:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "trezor",
"github_project": "python-slip10",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "slip10"
}