From e49de15227c1b39678227129e260d5c61267c339 Mon Sep 17 00:00:00 2001 From: NIC619 Date: Mon, 25 Nov 2019 16:57:00 +0800 Subject: [PATCH] Add `get_private_key` to `Host` --- libp2p/host/basic_host.py | 3 +++ libp2p/host/host_interface.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/libp2p/host/basic_host.py b/libp2p/host/basic_host.py index cd0d289..48c322b 100644 --- a/libp2p/host/basic_host.py +++ b/libp2p/host/basic_host.py @@ -67,6 +67,9 @@ class BasicHost(IHost): def get_public_key(self) -> PublicKey: return self.peerstore.pubkey(self.get_id()) + def get_private_key(self) -> PublicKey: + return self.peerstore.privkey(self.get_id()) + def get_network(self) -> INetwork: """ :return: network instance of host diff --git a/libp2p/host/host_interface.py b/libp2p/host/host_interface.py index cfba82c..5e28fda 100644 --- a/libp2p/host/host_interface.py +++ b/libp2p/host/host_interface.py @@ -24,6 +24,12 @@ class IHost(ABC): :return: the public key belonging to the peer """ + @abstractmethod + def get_private_key(self) -> PublicKey: + """ + :return: the private key belonging to the peer + """ + @abstractmethod def get_network(self) -> INetwork: """