|
@ -24,10 +24,8 @@ |
|
|
# SOFTWARE. |
|
|
# SOFTWARE. |
|
|
|
|
|
|
|
|
import base64 |
|
|
import base64 |
|
|
import hmac |
|
|
|
|
|
import hashlib |
|
|
import hashlib |
|
|
from typing import Union |
|
|
from typing import Union, Tuple |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import ecdsa |
|
|
import ecdsa |
|
|
from ecdsa.ecdsa import curve_secp256k1, generator_secp256k1 |
|
|
from ecdsa.ecdsa import curve_secp256k1, generator_secp256k1 |
|
@ -110,7 +108,7 @@ def get_y_coord_from_x(x: int, odd: bool=True) -> int: |
|
|
raise InvalidECPointException() |
|
|
raise InvalidECPointException() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ser_to_point(ser: bytes) -> (int, int): |
|
|
def ser_to_point(ser: bytes) -> Tuple[int, int]: |
|
|
if ser[0] not in (0x02, 0x03, 0x04): |
|
|
if ser[0] not in (0x02, 0x03, 0x04): |
|
|
raise ValueError('Unexpected first byte: {}'.format(ser[0])) |
|
|
raise ValueError('Unexpected first byte: {}'.format(ser[0])) |
|
|
if ser[0] == 0x04: |
|
|
if ser[0] == 0x04: |
|
@ -227,7 +225,7 @@ class ECPubkey(object): |
|
|
def get_public_key_hex(self, compressed=True): |
|
|
def get_public_key_hex(self, compressed=True): |
|
|
return bh2u(self.get_public_key_bytes(compressed)) |
|
|
return bh2u(self.get_public_key_bytes(compressed)) |
|
|
|
|
|
|
|
|
def point(self) -> (int, int): |
|
|
def point(self) -> Tuple[int, int]: |
|
|
return self._pubkey.point.x(), self._pubkey.point.y() |
|
|
return self._pubkey.point.x(), self._pubkey.point.y() |
|
|
|
|
|
|
|
|
def __mul__(self, other: int): |
|
|
def __mul__(self, other: int): |
|
|