def _encrypt_key(
self,
key: bytes,
pubkey: bytes = None
) -> Tuple[bytes, bytes]:
"""
Encrypts the `key` provided for the provided `pubkey` using the ECIES
schema. If no `pubkey` is provided, it uses `self.pub_key`.
:param key: Key to encrypt
:param pubkey: Public Key to encrypt the `key` for
:return (encrypted key, encapsulated ECIES key)
"""
pubkey = pubkey or self.pub_key
symm_key, enc_symm_key = API.ecies_encaspulate(pubkey)
enc_key = API.symm_encrypt(symm_key, key)
return (enc_key, enc_symm_key)
评论列表
文章目录