def gen_address(pub: ECG) -> str: x, y = pub.value[0].value, pub.value[1].value if y % 2 == 0: prefix = bytes([0x02]) else: prefix = bytes([0x03]) networkid = bytes([0x00]) hashed = ripemd160( sha256(prefix + x.to_bytes(32, byteorder='big')).digest()) assert len(hashed) == 20 with_network = networkid + hashed auth = dhash256(with_network)[:4] res = with_network + auth assert len(res) == 25 return b58encode(res)
def checksum(a) -> int: assert len(a) == 33 return 'EOS' + b58encode(a + ripemd160(a)[:4])
def gen_address(pub: ECG): pub = to_bytes(pub) pub_sha = hashlib.sha512(pub).digest() addy = ripemd160(pub_sha) return 'EOS' + b58encode(addy + ripemd160(addy)[:4])