mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-12 16:10:57 +00:00
Typing and linting fixes
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
from typing import Callable, Tuple
|
||||
from typing import Callable, Tuple, cast
|
||||
|
||||
import Crypto.PublicKey.ECC as ECC
|
||||
|
||||
from libp2p.crypto.ecc import create_new_key_pair
|
||||
from libp2p.crypto.ecc import ECCPrivateKey, create_new_key_pair
|
||||
from libp2p.crypto.keys import PublicKey
|
||||
|
||||
SharedKeyGenerator = Callable[[bytes], bytes]
|
||||
@ -20,7 +20,8 @@ def create_ephemeral_key_pair(curve_type: str) -> Tuple[PublicKey, SharedKeyGene
|
||||
def _key_exchange(serialized_remote_public_key: bytes) -> bytes:
|
||||
remote_public_key = ECC.import_key(serialized_remote_public_key)
|
||||
curve_point = remote_public_key.pointQ
|
||||
secret_point = curve_point * key_pair.private_key.impl.d
|
||||
private_key = cast(ECCPrivateKey, key_pair.private_key)
|
||||
secret_point = curve_point * private_key.impl.d
|
||||
byte_size = secret_point.size_in_bytes()
|
||||
return secret_point.x.to_bytes(byte_size, byteorder="big")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user