diff --git a/lib/ecc.py b/lib/ecc.py index a9997b284..25ce334e8 100644 --- a/lib/ecc.py +++ b/lib/ecc.py @@ -109,13 +109,7 @@ def ser_to_point(ser: bytes) -> (int, int): def _ser_to_python_ecdsa_point(ser: bytes) -> ecdsa.ellipticcurve.Point: - if ser[0] not in (0x02, 0x03, 0x04): - raise ValueError('Unexpected first byte: {}'.format(ser[0])) - x = string_to_number(ser[1:33]) - if ser[0] == 0x04: - y = string_to_number(ser[33:]) - else: - y = get_y_coord_from_x(x, ser[0] == 0x03) + x, y = ser_to_point(ser) return Point(curve_secp256k1, x, y, CURVE_ORDER) diff --git a/lib/ecc_fast.py b/lib/ecc_fast.py index 8413b5317..b98b60e58 100644 --- a/lib/ecc_fast.py +++ b/lib/ecc_fast.py @@ -32,18 +32,13 @@ SECP256K1_EC_COMPRESSED = (SECP256K1_FLAGS_TYPE_COMPRESSION | SECP256K1_FLAGS_BI SECP256K1_EC_UNCOMPRESSED = (SECP256K1_FLAGS_TYPE_COMPRESSION) -# TODO double check ctypes arg/return value types against https://github.com/bitcoin-core/secp256k1/blob/master/src/secp256k1.c def load_library(): - library_path = ctypes.util.find_library('libsecp256k1') or \ - ctypes.util.find_library('secp256k1') - if not library_path: - print_error('[ecc] info: libsecp256k1 library was not found, trying fallback name') - if sys.platform == 'darwin': - library_path = 'libsecp256k1.dylib' - elif sys.platform in ('windows', 'win32'): - library_path = 'libsecp256k1.dll' - else: - library_path = 'libsecp256k1.so.0' + if sys.platform == 'darwin': + library_path = 'libsecp256k1.dylib' + elif sys.platform in ('windows', 'win32'): + library_path = 'libsecp256k1.dll' + else: + library_path = 'libsecp256k1.so.0' secp256k1 = ctypes.cdll.LoadLibrary(library_path) if not secp256k1: