Exemplo n.º 1
0
def deserialize_xpub(data):
    dbin = convert.b58check_to_bytes(data)
    assert dbin[0:4] == HD_HEADER_PUBLIC

    return {
        'depth': dbin[4],
        'fingerprint': dbin[5:9],
        'i': convert.bytes_to_int(dbin[9:13]),
        'chaincode': dbin[13:45],
        'pub': ecdsa.deserialize_pub(dbin[45:78])
    }
Exemplo n.º 2
0
 def test_serialize(self):
     for _ in range(10):
         priv = ecdsa.random_priv()
         pub = ecdsa.priv_to_pub(priv)
         self.assertEqual(pub, ecdsa.deserialize_pub(ecdsa.serialize_pub(pub, compressed=False)))
         self.assertEqual(pub, ecdsa.deserialize_pub(ecdsa.serialize_pub(pub, compressed=True)))