1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 04:18:10 +00:00

chore(core): Add HashContextInitable protocol class.

This commit is contained in:
Andrew Kozlik 2022-01-17 18:31:17 +01:00 committed by Andrew Kozlik
parent f17a435cdf
commit 83686d1be2
3 changed files with 8 additions and 7 deletions

View File

@ -68,7 +68,7 @@ class CoinInfo:
if curve_name == "secp256k1-groestl":
self.b58_hash = groestl512d_32
self.sign_hash_double = False
self.script_hash: type[utils.HashContext] = sha256_ripemd160
self.script_hash: type[utils.HashContextInitable] = sha256_ripemd160
elif curve_name == "secp256k1-decred":
self.b58_hash = blake256d_32
self.sign_hash_double = False

View File

@ -68,7 +68,7 @@ class CoinInfo:
if curve_name == "secp256k1-groestl":
self.b58_hash = groestl512d_32
self.sign_hash_double = False
self.script_hash: type[utils.HashContext] = sha256_ripemd160
self.script_hash: type[utils.HashContextInitable] = sha256_ripemd160
elif curve_name == "secp256k1-decred":
self.b58_hash = blake256d_32
self.sign_hash_double = False

View File

@ -145,17 +145,18 @@ def chunks_intersperse(items: str, size: int, sep: str = "\n") -> Iterator[str]:
if TYPE_CHECKING:
class HashContext(Protocol):
def __init__( # pylint: disable=super-init-not-called
self, __data: bytes = None
) -> None:
...
def update(self, __buf: bytes) -> None:
...
def digest(self) -> bytes:
...
class HashContextInitable(HashContext, Protocol):
def __init__( # pylint: disable=super-init-not-called
self, __data: bytes = None
) -> None:
...
class Writer(Protocol):
def append(self, __b: int) -> None:
...