I find the Bit module the easiest and most straight forward, albeit a tad, limited but with bit you can simply:
from bit import Key
# To generate private key
privKey= Key()
# Create Ripemd-160 Hash (address)
privKey.address
# or
myAddress = privKey.address
# Segwit
MySegwitAddress = privKey.segwit_address
You can also import your own existing private keys like so:
# For wif format:
privKey = Key.('L1VotKmtZRLZSnSPhLhQxfts2aqBMru2APTs4Yuc8TYJ4jNhQoGB')
# For hex format:
privKey = Key.from_hex('ccb8c423403f4d5b6cde505d2a8f39d1d9399f6e06853339f5b11593cc502dc9')
# For int format:
privKey = Key.from_int('92598274663553697917256765988661195316245391320286084491562671024534692310473')
# For bytes format
privKey = Key.from_bytesfrom_der('b'\xcc\xb8\xc4#@b'\xcc\xb8\xc4#@?M[l\xdeP]*\x8f9\xd1\xd99\x9fn\x06\x8539\xf5\xb1\x15\x93\xccP-\xc9'\xc9)
Exporting works pretty much the same way as importing except you replace from.[format here]
with to.[format here]
, you can even import or export a PEM file of your private key.
The documentation is enough for the library to give you the core functions, but is also somewhat lacking, for example you can't create compressed bitcoin addresses. But otherwise you can sign, send transactions, even select exactly which outputs you want to use .etc