diff --git a/p2p/protocol.go b/p2p/protocol.go
index 1d121a8855792384764efffed7e08dd1e0c5924f..62ada929d70c176d6093648f41565900193a66c1 100644
--- a/p2p/protocol.go
+++ b/p2p/protocol.go
@@ -64,6 +64,10 @@ func (h *handshake) Pubkey() []byte {
 	return h.NodeID
 }
 
+func (h *handshake) PrivKey() []byte {
+	return nil
+}
+
 // Cap is the structure of a peer capability.
 type Cap struct {
 	Name    string
diff --git a/p2p/protocol_test.go b/p2p/protocol_test.go
index b1d10ac5360f2ea61a8eb1cb87d6715b2deec944..6804a9d40bf49e06b98cac20a85310203321a9d6 100644
--- a/p2p/protocol_test.go
+++ b/p2p/protocol_test.go
@@ -11,7 +11,7 @@ import (
 )
 
 type peerId struct {
-	pubkey []byte
+	privKey, pubkey []byte
 }
 
 func (self *peerId) String() string {
@@ -27,6 +27,15 @@ func (self *peerId) Pubkey() (pubkey []byte) {
 	return
 }
 
+func (self *peerId) PrivKey() (privKey []byte) {
+	privKey = self.privKey
+	if len(privKey) == 0 {
+		privKey = crypto.GenerateNewKeyPair().PublicKey
+		self.privKey = privKey
+	}
+	return
+}
+
 func newTestPeer() (peer *Peer) {
 	peer = NewPeer(&peerId{}, []Cap{})
 	peer.pubkeyHook = func(*peerAddr) error { return nil }