Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Latest commit

 

History

History
87 lines (63 loc) · 1.87 KB

README.md

File metadata and controls

87 lines (63 loc) · 1.87 KB

Keylib

CircleCI PyPI PyPI Slack

Installation

$ pip install keylib

Usage

Private Keys

>>> from keylib import ECPrivateKey

New Private Keys

>>> private_key = ECPrivateKey()
>>> private_key.to_hex()
'c4bbcb1fbec99d65bf59d85c8cb62ee2db963f0fe106f483d9afa73bd4e39a8a01'
>>> private_key.to_wif()
'L3p8oAcQTtuokSCRHQ7i4MhjWc9zornvpJLfmg62sYpLRJF9woSu'

Imported Private Keys

>>> imported_private_key = ECPrivateKey(private_key.to_hex())
>>> print private_key.to_wif() == imported_private_key.to_wif()
True

Public Keys

>>> from keylib import ECPublicKey

Public Keys from Private Keys

>>> public_key = private_key.public_key()
>>> public_key.to_hex()
'03019979ec442e61ace8d47c6a344d791cee12d4e7bbde05fa91a62c0cda51c834'

Imported Public Keys

>>> imported_public_key = ECPublicKey(public_key.to_hex())
>>> print public_key.to_hex() == imported_public_key.to_hex()
True

Addresses

>>> from keylib import public_key_to_address

Addresses from Public Key Objects

>>> public_key.address()
'12WDrxysCBDtVxaP1n4HHj8BLqqqfaqANd'

RIPEMD160 Hashes from Public Key Objects

>>> public_key.hash160()
'107eecc5868111ba06e6bd9309b2db90c555cb6e'

Addresses from Hex Public Keys

>>> public_key_to_address("030589ee559348bd6a7325994f9c8eff12bd5d73cc683142bd0dd1a17abc99b0dc")
'1KbUJ4x8epz6QqxkmZbTc4f79JbWWz6g37'