fromeccimportGfromhelperimportdouble_sha256, encode_base58, hash160components= (
# (compressed, secret)
(True, 888**3),
(False, 321),
(False, 4242424242),
)
# iterate through components# get the public point# get the sec format# hash160 the result# prepend b'\x00' for mainnet b'\x6f' for testnet# raw is the prefix + h160# get the double_sha256 of raw, first 4 bytes are the checksum# append checksum# encode_base58 the whole thing
Test Driven Exercise
fromeccimportS256Point, Gfromhelperimportdouble_sha256, encode_base58, hash160classS256Point(S256Point):
defaddress(self, compressed=True, testnet=False):
'''Returns the address string'''# get the sec# hash160 the sec# raw is hash 160 prepended w/ b'\x00' for mainnet, b'\x6f' for testnet# checksum is first 4 bytes of double_sha256 of raw# encode_base58 the raw + checksum# return as a string, you can use .decode('ascii') to do this.pass