What is the purpose of having map[peer.ID] => PrivateKey in PeerStore?

I am reading Go PeerStore implementation.

PrivKey - returns the private key of a peer.

What is the purpose of this? Is it possible that peer can know private keys of other peers?

1 Like

We only ever use this to store our own private key, and fetch it from other parts of the stack, rather than passing it around standalone. Some examples:


Identify protocol:

Swarm dialer:

It may be worth documenting the method on the interface to point this out so other users don’t get confused.

1 Like

Agree! Feel free to submit a PR if you’d like to!

1 Like