mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
ecc.ECPubkey: also accept bytearray in __init__
This commit is contained in:
parent
9350f9f26a
commit
1a18e70d92
1 changed files with 4 additions and 1 deletions
|
@ -116,6 +116,7 @@ def sig_string_from_r_and_s(r: int, s: int) -> bytes:
|
||||||
|
|
||||||
def _x_and_y_from_pubkey_bytes(pubkey: bytes) -> Tuple[int, int]:
|
def _x_and_y_from_pubkey_bytes(pubkey: bytes) -> Tuple[int, int]:
|
||||||
pubkey_ptr = create_string_buffer(64)
|
pubkey_ptr = create_string_buffer(64)
|
||||||
|
assert isinstance(pubkey, bytes), f'pubkey must be bytes, not {type(pubkey)}'
|
||||||
ret = _libsecp256k1.secp256k1_ec_pubkey_parse(
|
ret = _libsecp256k1.secp256k1_ec_pubkey_parse(
|
||||||
_libsecp256k1.ctx, pubkey_ptr, pubkey, len(pubkey))
|
_libsecp256k1.ctx, pubkey_ptr, pubkey, len(pubkey))
|
||||||
if not ret:
|
if not ret:
|
||||||
|
@ -141,7 +142,9 @@ class ECPubkey(object):
|
||||||
|
|
||||||
def __init__(self, b: Optional[bytes]):
|
def __init__(self, b: Optional[bytes]):
|
||||||
if b is not None:
|
if b is not None:
|
||||||
assert_bytes(b)
|
assert isinstance(b, (bytes, bytearray)), f'pubkey must be bytes-like, not {type(b)}'
|
||||||
|
if isinstance(b, bytearray):
|
||||||
|
b = bytes(b)
|
||||||
self._x, self._y = _x_and_y_from_pubkey_bytes(b)
|
self._x, self._y = _x_and_y_from_pubkey_bytes(b)
|
||||||
else:
|
else:
|
||||||
self._x, self._y = None, None
|
self._x, self._y = None, None
|
||||||
|
|
Loading…
Add table
Reference in a new issue