Browse Source

crypto: (trivial) add some type-hints

master
SomberNight 1 year ago
parent
commit
ffdd45ee6f
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 14
      electrum/crypto.py

14
electrum/crypto.py

@ -446,7 +446,12 @@ def chacha20_decrypt(*, key: bytes, nonce: bytes, data: bytes) -> bytes:
raise Exception("no chacha20 backend found")
def ecies_encrypt_message(ec_pubkey, message: bytes, *, magic: bytes = b'BIE1') -> bytes:
def ecies_encrypt_message(
ec_pubkey: 'ecc.ECPubkey',
message: bytes,
*,
magic: bytes = b'BIE1',
) -> bytes:
"""
ECIES encryption/decryption methods; AES-128-CBC with PKCS7 is used as the cipher; hmac-sha256 is used as the mac
"""
@ -462,7 +467,12 @@ def ecies_encrypt_message(ec_pubkey, message: bytes, *, magic: bytes = b'BIE1')
return base64.b64encode(encrypted + mac)
def ecies_decrypt_message(ec_privkey, encrypted: Union[str, bytes], *, magic: bytes=b'BIE1') -> bytes:
def ecies_decrypt_message(
ec_privkey: 'ecc.ECPrivkey',
encrypted: Union[str, bytes],
*,
magic: bytes = b'BIE1',
) -> bytes:
encrypted = base64.b64decode(encrypted) # type: bytes
if len(encrypted) < 85:
raise Exception('invalid ciphertext: length')

Loading…
Cancel
Save