def from_bytes(cls, bytestr): """ :param bytestr: A private key previously encoded as hex. :type bytestr: ``bytes`` :rtype: :class:`~lit.PrivateKey` """ return PrivateKey(ECPrivateKey(bytestr))
def __init__(self, wif=None): if wif: if isinstance(wif, str): private_key_bytes, compressed, _ = wif_to_bytes(wif) self._pk = ECPrivateKey(private_key_bytes) elif isinstance(wif, ECPrivateKey): self._pk = wif compressed = True else: raise TypeError('Wallet Import Format must be a string.') else: self._pk = ECPrivateKey() compressed = True self._public_point = None self._public_key = self._pk.public_key.format(compressed=compressed)
def generate_key_address_pairs(prefix, counter, match, queue): # pragma: no cover context = Context() while True: if match.is_set(): return with counter.get_lock(): counter.value += 1 private_key = ECPrivateKey(context=context) address = b58encode_check( b'\x00' + ripemd160_sha256(private_key.public_key.format()) ) if address.startswith(prefix): match.set() queue.put_nowait((private_key.secret, address)) return
def test_init_from_key(self): pk = ECPrivateKey() base_key = BaseKey(pk) assert base_key._pk == pk
def generate_key_address_pair(): # pragma: no cover private_key = ECPrivateKey() address = public_key_to_address(private_key.public_key.format()) return bytes_to_wif(private_key.secret), address