Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/summa-tx/riemann-keys
cryptocurrency hd keys for humansππ
https://github.com/summa-tx/riemann-keys
Last synced: 2 months ago
JSON representation
cryptocurrency hd keys for humansππ
- Host: GitHub
- URL: https://github.com/summa-tx/riemann-keys
- Owner: summa-tx
- License: other
- Created: 2018-08-16T20:22:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T06:36:00.000Z (about 2 years ago)
- Last Synced: 2023-03-02T19:15:42.840Z (almost 2 years ago)
- Language: Python
- Homepage:
- Size: 355 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE2.md
Awesome Lists containing this project
README
## HDKey: HD Wallets for humans
HDKey is an implementation of bip32 HD Wallets using libsecp256k1 for signing, verification, and derivation.
### Installation, Development, & Running Tests
Install from pypi for use in your project:
```
$ pip3 install hdkey
# or
$ pip3 install riemann-keys
```## Development Setup (MacOsX)
Install pyenv:
```
$ brew update
$ brew install pyenv
$ env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.7.0
```Install pipenv:
```
$ brew update
$ brew install pipenv
```To use pyenv inconjuction with pipenv:
```
$ pipenv --python
```
(Typically the path is `~/.pyenv/versions/3.7.0/bin/python3.7`)## Development Install
```
$ git clone [email protected]:summa-tx/riemann-keys.git
$ cd riemann-keys
$ pipenv install
```#### Install libsecp256k1 for development
HDKey requires libsecp256k1 to be installed on your system.
Full installation instructions are located here: [link](https://github.com/bitcoin-core/secp256k1)
```
$ sudo apt install libtool, autoconf
$ git clone [email protected]:bitcoin-core/secp256k1.git
$ cd secp256k1
$ ./autogen.sh
$ ./configure
$ make
$ ./tests
$ sudo make install # optional
```#### Running tests
libsecp256k1 is required to run tests.
```
$ tox
```### Usage
#### General
```Python
from riemann_keys import HDKey
my_key = HDKey.from_entropy(b'\x00' * 16)
print(my_key.xpriv) # This is not actually a good ideadescendant = my_key.derive_path('m/44h/0h/0/0/0/7')
print(descendant.derive_child(79).path) # m/44h/0h/0/0/0/7/79
print(descendant.derive_child('79h').path) # m/44h/0h/0/0/0/7/79hmsg = b'a messsage for signing'
sig = descendant.sign(msg) # DER-encoded RFC6979 ECDSA sigdescendant.verify(sig=sig, msg=msg) # return True or False
```#### Instantiation
```Python
# From outside material
HDKey.from_xpub(xpub: str) # an xpub
HDKey.from_xpriv(xpriv: str) # an xpriv
HDKey.from_pubkey(pub: bytes) # compressed pubkey
HDKey.from_privkey(priv: bytes) # private key
HDKey.from_root_seed(seed: bytes) # root seed
HDKey.from_entropy(entrpopy: bytes) # bip39 entropy
HDKey.from_mnemonic(mnemonic: str) # bip39 mnemonic# child node derivation (requires chain code)
key_obj.derive_child(idx: int) # child index eg. 7
key_obj.derive_child(idx: str) # child index eg. '0h'
key_obj.derive_path(path: str) # child path eg 'm/3/9h'
```### Packaging in binaries
If you're looking to use `pyinstaller` to package, we strongly recommend using `pyenv` ([link](https://github.com/pyenv/pyenv)) to manage python installations. Make sure to build with `--enable-shared` or `--enable-framework` ([instructions here](https://github.com/pyenv/pyenv/wiki)) as appropriate.
We have tested `pyinstaller` with libsecp256k1 and HDKey on OSX and Linux.