Commit d227f618 authored by zelig's avatar zelig Committed by Felix Lange

fix protocol to accomodate privkey

parent 88167f39
...@@ -64,6 +64,10 @@ func (h *handshake) Pubkey() []byte { ...@@ -64,6 +64,10 @@ func (h *handshake) Pubkey() []byte {
return h.NodeID return h.NodeID
} }
func (h *handshake) PrivKey() []byte {
return nil
}
// Cap is the structure of a peer capability. // Cap is the structure of a peer capability.
type Cap struct { type Cap struct {
Name string Name string
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
) )
type peerId struct { type peerId struct {
pubkey []byte privKey, pubkey []byte
} }
func (self *peerId) String() string { func (self *peerId) String() string {
...@@ -27,6 +27,15 @@ func (self *peerId) Pubkey() (pubkey []byte) { ...@@ -27,6 +27,15 @@ func (self *peerId) Pubkey() (pubkey []byte) {
return 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) { func newTestPeer() (peer *Peer) {
peer = NewPeer(&peerId{}, []Cap{}) peer = NewPeer(&peerId{}, []Cap{})
peer.pubkeyHook = func(*peerAddr) error { return nil } peer.pubkeyHook = func(*peerAddr) error { return nil }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment