Generate public keys from Extended Public Key in python


I’d like to get a regular public key from an extended public key in Python. Actually I want to get the same result over here In the Extended Public Key Children section. I know I need this structure:

child_public_key = parent_public_key + point(lefthand_hash_output)

I used this to get the left hand hash:

         0x00 not sure if I need this                                         Index
         --                                                                  --------             
pub_key="000343b337dec65a47b3362c9620a6e6ff39a1ddfa908abab1666c8a30a3f8a7cccc00000000"
chain_code="1d7d2a4c940be028b945302ad79dd2ce2afe5ed55e1a2937a5af57f8401e73dd"

h = hmac.new( chain_code.encode("utf-8"),pub_key.encode("utf-8"), hashlib.sha512 ).digest()
lefthand_hash_output=slice(0,len(h)//2)

But now I don’t know how to do this point(lefthand_hash_output).

I also tried this, but I get an error

seed=b'...' # replaced with the seed
root_key = bip32utils.BIP32Key.fromEntropy(seed)
root_public_hex = root_key.PublicKey().hex()
key=bip32utils.BIP32Key.CKDpub((root_public_hex) ,0)
print(key)

The sample code could be very useful. Thanks in advance!



Source link

Related Posts