Documentation ¶
Index ¶
Constants ¶
const IDLength = 46
Variables ¶
var ( ErrNoPubKey = errors.New("public key is not embedded in peer ID") ErrEmptyPeerID = errors.New("empty peer ID") )
Functions ¶
This section is empty.
Types ¶
type ID ¶
type ID string
ID represents the unique identity of a peer.
func IDFromPriKey ¶
IDFromPriKey returns the Peer ID corresponding to the secret key sk.
func IDFromPubKey ¶
IDFromPubKey returns the Peer ID corresponding to the public key pk.
func (ID) ExtractPubKey ¶
ExtractPubKey attempts to extract the public key from an ID.
This method returns ErrNoPublicKey if the peer ID looks valid, but it can't extract the public key.
func (ID) MatchesPriKey ¶
MatchesPriKey tests whether this ID was derived from the secret key sk.
func (ID) MatchesPubKey ¶
MatchesPubKey tests whether this ID was derived from the public key pk.
func (ID) WeightCompare ¶
WeightCompare compares the weight of our ID with another ID. It determines which peer should be saved when a conflict is found between two peers. The function returns true if the weight of our ID is higher than the other ID's weight.