From d326242ddb9700e66cbf8eb665934069b651293e Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Wed, 17 May 2023 03:26:26 +0000 Subject: automatic import of python-bip32 --- .gitignore | 1 + python-bip32.spec | 467 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ sources | 1 + 3 files changed, 469 insertions(+) create mode 100644 python-bip32.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore index e69de29..f9d799c 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/bip32-3.4.tar.gz diff --git a/python-bip32.spec b/python-bip32.spec new file mode 100644 index 0000000..01faba4 --- /dev/null +++ b/python-bip32.spec @@ -0,0 +1,467 @@ +%global _empty_manifest_terminate_build 0 +Name: python-bip32 +Version: 3.4 +Release: 1 +Summary: Minimalistic implementation of the BIP32 key derivation scheme +License: MIT +URL: http://github.com/darosior/python-bip32 +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/67/06/df2b5d324dfd2f71172edd54db539879362de2be5d9fd897d86b4a2577de/bip32-3.4.tar.gz +BuildArch: noarch + +Requires: python3-base58 +Requires: python3-coincurve + +%description +# python-bip32 + +A basic implementation of the [bip-0032](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki). + +## Usage + +```python +>>> from bip32 import BIP32, HARDENED_INDEX +>>> bip32 = BIP32.from_seed(bytes.fromhex("01")) +# Specify the derivation path as a list ... +>>> bip32.get_xpriv_from_path([1, HARDENED_INDEX, 9998]) +'xprv9y4sBgCuub5x2DtbdNBDDCZ3btybk8YZZaTvzV5rmYd3PbU63XLo2QEj6cUt4JAqpF8gJiRKFUW8Vm7thPkccW2DpUvBxASycypEHxmZzts' +# ... Or in usual m/the/path/ +>>> bip32.get_xpriv_from_path("m/1/0'/9998") +'xprv9y4sBgCuub5x2DtbdNBDDCZ3btybk8YZZaTvzV5rmYd3PbU63XLo2QEj6cUt4JAqpF8gJiRKFUW8Vm7thPkccW2DpUvBxASycypEHxmZzts' +>>> bip32.get_xpub_from_path([HARDENED_INDEX, 42]) +'xpub69uEaVYoN1mZyMon8qwRP41YjYyevp3YxJ68ymBGV7qmXZ9rsbMy9kBZnLNPg3TLjKd2EnMw5BtUFQCGrTVDjQok859LowMV2SEooseLCt1' +# You can also use "h" or "H" to signal for hardened derivation +>>> bip32.get_xpub_from_path("m/0h/42") +'xpub69uEaVYoN1mZyMon8qwRP41YjYyevp3YxJ68ymBGV7qmXZ9rsbMy9kBZnLNPg3TLjKd2EnMw5BtUFQCGrTVDjQok859LowMV2SEooseLCt1' +# You can use pubkey-only derivation +>>> bip32 = BIP32.from_xpub("xpub6AKC3u8URPxDojLnFtNdEPFkNsXxHfgRhySvVfEJy9SVvQAn14XQjAoFY48mpjgutJNfA54GbYYRpR26tFEJHTHhfiiZZ2wdBBzydVp12yU") +>>> bip32.get_xpub_from_path([42, 43]) +'xpub6FL7T3s7GuVb4od1gvWuumhg47y6TZtf2DSr6ModQpX4UFGkQXw8oEVhJXcXJ4edmtAWCTrefD64B9RP4sYSkSumTW1wadTS3SYurBGYccT' +>>> bip32.get_xpub_from_path("m/42/43") +'xpub6FL7T3s7GuVb4od1gvWuumhg47y6TZtf2DSr6ModQpX4UFGkQXw8oEVhJXcXJ4edmtAWCTrefD64B9RP4sYSkSumTW1wadTS3SYurBGYccT' +>>> bip32.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 bip32 +``` + +### Dependencies + +This uses [`coincurve`](https://github.com/ofek/coincurve) as a wrapper for [`libsecp256k1`](https://github.com/bitcoin-core/secp256k1) for EC operations. + +### Running the test suite + +``` +# From the root of the repository +python3 -m venv venv +. venv/bin/activate +pip install -r requirements.txt && pip install pytest +PYTHONPATH=$PYTHONPATH:$PWD/bip32 pytest -vvv +``` + +## Interface + +All public keys below are compressed. + +All `path` below are a list of integers representing the index of the key at each depth. + +### BIP32 + +#### from_seed(seed) + +__*classmethod*__ + +Instanciate from a raw seed (as `bytes`). See [bip-0032's master key +generation](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#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_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(path) + +Equivalent to `get_xpriv_from_path([])`. + +#### get_xpriv_bytes(path) + +Equivalent to `get_xpriv([])`, but not serialized in base58 + +#### get_xpub(path) + +Equivalent to `get_xpub_from_path([])`. + +#### get_xpub_bytes(path) + +Equivalent to `get_xpub([])`, but not serialized in base58 + + + + +%package -n python3-bip32 +Summary: Minimalistic implementation of the BIP32 key derivation scheme +Provides: python-bip32 +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-bip32 +# python-bip32 + +A basic implementation of the [bip-0032](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki). + +## Usage + +```python +>>> from bip32 import BIP32, HARDENED_INDEX +>>> bip32 = BIP32.from_seed(bytes.fromhex("01")) +# Specify the derivation path as a list ... +>>> bip32.get_xpriv_from_path([1, HARDENED_INDEX, 9998]) +'xprv9y4sBgCuub5x2DtbdNBDDCZ3btybk8YZZaTvzV5rmYd3PbU63XLo2QEj6cUt4JAqpF8gJiRKFUW8Vm7thPkccW2DpUvBxASycypEHxmZzts' +# ... Or in usual m/the/path/ +>>> bip32.get_xpriv_from_path("m/1/0'/9998") +'xprv9y4sBgCuub5x2DtbdNBDDCZ3btybk8YZZaTvzV5rmYd3PbU63XLo2QEj6cUt4JAqpF8gJiRKFUW8Vm7thPkccW2DpUvBxASycypEHxmZzts' +>>> bip32.get_xpub_from_path([HARDENED_INDEX, 42]) +'xpub69uEaVYoN1mZyMon8qwRP41YjYyevp3YxJ68ymBGV7qmXZ9rsbMy9kBZnLNPg3TLjKd2EnMw5BtUFQCGrTVDjQok859LowMV2SEooseLCt1' +# You can also use "h" or "H" to signal for hardened derivation +>>> bip32.get_xpub_from_path("m/0h/42") +'xpub69uEaVYoN1mZyMon8qwRP41YjYyevp3YxJ68ymBGV7qmXZ9rsbMy9kBZnLNPg3TLjKd2EnMw5BtUFQCGrTVDjQok859LowMV2SEooseLCt1' +# You can use pubkey-only derivation +>>> bip32 = BIP32.from_xpub("xpub6AKC3u8URPxDojLnFtNdEPFkNsXxHfgRhySvVfEJy9SVvQAn14XQjAoFY48mpjgutJNfA54GbYYRpR26tFEJHTHhfiiZZ2wdBBzydVp12yU") +>>> bip32.get_xpub_from_path([42, 43]) +'xpub6FL7T3s7GuVb4od1gvWuumhg47y6TZtf2DSr6ModQpX4UFGkQXw8oEVhJXcXJ4edmtAWCTrefD64B9RP4sYSkSumTW1wadTS3SYurBGYccT' +>>> bip32.get_xpub_from_path("m/42/43") +'xpub6FL7T3s7GuVb4od1gvWuumhg47y6TZtf2DSr6ModQpX4UFGkQXw8oEVhJXcXJ4edmtAWCTrefD64B9RP4sYSkSumTW1wadTS3SYurBGYccT' +>>> bip32.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 bip32 +``` + +### Dependencies + +This uses [`coincurve`](https://github.com/ofek/coincurve) as a wrapper for [`libsecp256k1`](https://github.com/bitcoin-core/secp256k1) for EC operations. + +### Running the test suite + +``` +# From the root of the repository +python3 -m venv venv +. venv/bin/activate +pip install -r requirements.txt && pip install pytest +PYTHONPATH=$PYTHONPATH:$PWD/bip32 pytest -vvv +``` + +## Interface + +All public keys below are compressed. + +All `path` below are a list of integers representing the index of the key at each depth. + +### BIP32 + +#### from_seed(seed) + +__*classmethod*__ + +Instanciate from a raw seed (as `bytes`). See [bip-0032's master key +generation](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#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_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(path) + +Equivalent to `get_xpriv_from_path([])`. + +#### get_xpriv_bytes(path) + +Equivalent to `get_xpriv([])`, but not serialized in base58 + +#### get_xpub(path) + +Equivalent to `get_xpub_from_path([])`. + +#### get_xpub_bytes(path) + +Equivalent to `get_xpub([])`, but not serialized in base58 + + + + +%package help +Summary: Development documents and examples for bip32 +Provides: python3-bip32-doc +%description help +# python-bip32 + +A basic implementation of the [bip-0032](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki). + +## Usage + +```python +>>> from bip32 import BIP32, HARDENED_INDEX +>>> bip32 = BIP32.from_seed(bytes.fromhex("01")) +# Specify the derivation path as a list ... +>>> bip32.get_xpriv_from_path([1, HARDENED_INDEX, 9998]) +'xprv9y4sBgCuub5x2DtbdNBDDCZ3btybk8YZZaTvzV5rmYd3PbU63XLo2QEj6cUt4JAqpF8gJiRKFUW8Vm7thPkccW2DpUvBxASycypEHxmZzts' +# ... Or in usual m/the/path/ +>>> bip32.get_xpriv_from_path("m/1/0'/9998") +'xprv9y4sBgCuub5x2DtbdNBDDCZ3btybk8YZZaTvzV5rmYd3PbU63XLo2QEj6cUt4JAqpF8gJiRKFUW8Vm7thPkccW2DpUvBxASycypEHxmZzts' +>>> bip32.get_xpub_from_path([HARDENED_INDEX, 42]) +'xpub69uEaVYoN1mZyMon8qwRP41YjYyevp3YxJ68ymBGV7qmXZ9rsbMy9kBZnLNPg3TLjKd2EnMw5BtUFQCGrTVDjQok859LowMV2SEooseLCt1' +# You can also use "h" or "H" to signal for hardened derivation +>>> bip32.get_xpub_from_path("m/0h/42") +'xpub69uEaVYoN1mZyMon8qwRP41YjYyevp3YxJ68ymBGV7qmXZ9rsbMy9kBZnLNPg3TLjKd2EnMw5BtUFQCGrTVDjQok859LowMV2SEooseLCt1' +# You can use pubkey-only derivation +>>> bip32 = BIP32.from_xpub("xpub6AKC3u8URPxDojLnFtNdEPFkNsXxHfgRhySvVfEJy9SVvQAn14XQjAoFY48mpjgutJNfA54GbYYRpR26tFEJHTHhfiiZZ2wdBBzydVp12yU") +>>> bip32.get_xpub_from_path([42, 43]) +'xpub6FL7T3s7GuVb4od1gvWuumhg47y6TZtf2DSr6ModQpX4UFGkQXw8oEVhJXcXJ4edmtAWCTrefD64B9RP4sYSkSumTW1wadTS3SYurBGYccT' +>>> bip32.get_xpub_from_path("m/42/43") +'xpub6FL7T3s7GuVb4od1gvWuumhg47y6TZtf2DSr6ModQpX4UFGkQXw8oEVhJXcXJ4edmtAWCTrefD64B9RP4sYSkSumTW1wadTS3SYurBGYccT' +>>> bip32.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 bip32 +``` + +### Dependencies + +This uses [`coincurve`](https://github.com/ofek/coincurve) as a wrapper for [`libsecp256k1`](https://github.com/bitcoin-core/secp256k1) for EC operations. + +### Running the test suite + +``` +# From the root of the repository +python3 -m venv venv +. venv/bin/activate +pip install -r requirements.txt && pip install pytest +PYTHONPATH=$PYTHONPATH:$PWD/bip32 pytest -vvv +``` + +## Interface + +All public keys below are compressed. + +All `path` below are a list of integers representing the index of the key at each depth. + +### BIP32 + +#### from_seed(seed) + +__*classmethod*__ + +Instanciate from a raw seed (as `bytes`). See [bip-0032's master key +generation](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#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_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(path) + +Equivalent to `get_xpriv_from_path([])`. + +#### get_xpriv_bytes(path) + +Equivalent to `get_xpriv([])`, but not serialized in base58 + +#### get_xpub(path) + +Equivalent to `get_xpub_from_path([])`. + +#### get_xpub_bytes(path) + +Equivalent to `get_xpub([])`, but not serialized in base58 + + + + +%prep +%autosetup -n bip32-3.4 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-bip32 -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed May 17 2023 Python_Bot - 3.4-1 +- Package Spec generated diff --git a/sources b/sources new file mode 100644 index 0000000..75f9d70 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +b2c0d0f23cfdeb5d0f54dd127b0cdb82 bip32-3.4.tar.gz -- cgit v1.2.3