I'm looking for a simple, easy to use Bitcoin library for Python.
What I want to do is verify I can enter a hex private key that I want, and get the expected pubkey in compressed format, and the 1Btc... address.
I've looked at cryptotools on github which looked promising, and easy to use, but it would not accept a hex value that wasn't a multiple of 2. I know that sounds odd, but I want to be able to enter a hex value like c12 and have it work as expected (unless I have to enter 0c12 and that will work, with the leading zero discarded). I expect than when I enter 0cfa721d that this will be interpreted as big endian.
bitcoinlib looks promising, but I find it confusing and I've tried for a couple of hours but unsure of how to get what I want.
- Input private key in hex
- Get back pub key in hash160 format, compressed
- Get the 1Btc... address as well.
I wonder if this is a strict mathematical relationship. For instance could there be an arbitrary or infinite number of pub keys from the private key? Is there a way to ensure I get the pubkey I want from the private key? I want to test known private keys with the pubkey and BTC address generated that corresponds to known private keys and addresses, so I can try and figure out how whoever generated these addresses from choices of private keys I can try to replicate and do the same thing myself.
Thank you for any help or suggestions.
myprivatekey.to_public().to_address('P2PKH', compressed=True)