Exemple #1
0
    def test_from_private_key(self):
        raw = encoding.a2b_hex(data['privkey_hex'])
        priv = privkey.PrivateKey.from_bytes(raw)
        pub = priv.public_key()

        assert pub.network is priv.network
        assert pub.compressed == priv.compressed
        assert pub.key.public_numbers().x == data['pubkey_pair'][0]
        assert pub.key.public_numbers().y == data['pubkey_pair'][1]
Exemple #2
0
    def from_hex(cls, string):
        """TODO"""

        try:
            data = encoding.a2b_hex(string)

        except encoding.InvalidEncoding as e:
            raise InvalidEncoding(e.message)

        return cls.from_bytes(data)
Exemple #3
0
    def from_hex(cls, string):
        """TODO"""

        try:
            data = encoding.a2b_hex(string)

        except encoding.InvalidEncoding as e:
            raise InvalidEncoding(e.message)

        return cls.from_bytes(data)
Exemple #4
0
    def test_bitcoind_valid_wifs(self, valid_wifs):
        for wif, secret_hex, attrs in valid_wifs:
            secret = encoding.b2i_bigendian(encoding.a2b_hex(secret_hex))
            network_ = network.testnet if attrs['isTestnet'] else network.livenet
            compressed = attrs['isCompressed']

            k = PrivateKey.from_wif(wif)

            assert k.key.private_numbers().private_value == secret
            assert k.network is network_
            assert k.compressed == compressed