I'm trying to implement the following steps in Python:
Compressed public key: 02F840A04114081690223B7069071A70D6DABB891763B638CC20C7EC3BD58E6C86 SHA-256 of public key yields: cb05d0fd5e76ba8ea88323fc5d3eefd09a78d8e2a5fd4955307b549657a31330 This step is fairly simple, so I wrote this piece of code to see if it works as planned:
from binascii import hexlify from hashlib import sha256 master_key = hexlify("02F840A04114081690223B7069071A70D6DABB891763B638CC20C7EC3BD58E6C86") print(sha256(master_key).hexdigest()) However, this doesn't yield the expected result. Instead it gives me:
cee4b5650664b11623675d0371ab9dd1e3478758a95b189e54ecf8b7bdd7ba2d Using the string without hex-encoding it first doesn't yield the correct result either. Any ideas?
hexlify()to convert the hex representation of the key to hex. It's already in hex. You probably want to useunhexlify().