removed useless functions
@@ -167,24 +167,24 @@ def _magic_hash(msg: Union[bytes, str]) -> bytes:
return sha256(t).digest()
-def _serialize(rf: int, r: int, s: int) -> bytes:
- # serialize [1-byte rf][32-bytes r][32-bytes s]
- if rf < 27 or rf > 42:
- raise ValueError(f"Invalid recovery flag: {rf}")
- dsa._check_sig(r, s)
- return bytes([rf]) + r.to_bytes(32, 'big') + s.to_bytes(32, 'big')
-
-
def serialize(rf: int, r: int, s: int) -> bytes:
"""Return the address-based compact signature as base64-encoding.
The compact signature is [1-byte rf][32-bytes r][32-bytes s]
"""
- sig = _serialize(rf, r, s)
+ if rf < 27 or rf > 42:
+ raise ValueError(f"Invalid recovery flag: {rf}")
+ dsa._check_sig(r, s)
+ sig = bytes([rf]) + r.to_bytes(32, 'big') + s.to_bytes(32, 'big')
return b64encode(sig)
-def _deserialize(sig: bytes) -> Tuple[int, int, int]:
+def deserialize(base64sig: Octets) -> Tuple[int, int, int]:
+ """Return the elements of the address-based compact signature.
+
+ The compact signature is [1-byte rf][32-bytes r][32-bytes s]
+ """
+ sig = b64decode(base64sig)
if len(sig) != 65:
raise ValueError(f"Wrong signature length: {len(sig)} instead of 65")
rf = sig[0]
@@ -196,15 +196,6 @@ def _deserialize(sig: bytes) -> Tuple[int, int, int]:
return rf, r, s
-def deserialize(base64sig: Octets) -> Tuple[int, int, int]:
- """Return the elements of the address-based compact signature.
-
- The compact signature is [1-byte rf][32-bytes r][32-bytes s]
- """
- sig = b64decode(base64sig)
- return _deserialize(sig)
-
-
def sign(msg: Union[bytes, str], wif: WIF,
addr: Optional[Address] = None) -> Tuple[int, int, int]:
"""Generate address-based compact signature for the provided message."""
