Documentation ¶
Overview ¶
package peer implements an object used to represent peers in the ipfs network.
Index ¶
Constants ¶
const MaxInlineKeyLength = 42
MaxInlineKeyLength is the maximum length a key can be for it to be inlined in the peer ID.
- When `len(pubKey.Bytes()) <= MaxInlineKeyLength`, the peer ID is the identity multihash hash of the public key.
- When `len(pubKey.Bytes()) > MaxInlineKeyLength`, the peer ID is the sha2-256 multihash of the public key.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ID ¶
type ID string
ID is a libp2p peer identity.
func IDFromBytes ¶
IDFromBytes cast a string to ID type, and validate the id to make sure it is a multihash.
func IDFromPrivateKey ¶
IDFromPrivateKey returns the Peer ID corresponding to sk
func IDFromPublicKey ¶
IDFromPublicKey returns the Peer ID corresponding to pk
func IDFromString ¶
IDFromString cast a string to ID type, and validate the id to make sure it is a multihash.
func (ID) ExtractPublicKey ¶
ExtractPublicKey attempts to extract the public key from an ID
This method returns nil, nil if the peer ID looks valid but it can't extract the public key.
func (ID) MatchesPrivateKey ¶
MatchesPrivateKey tests whether this ID was derived from sk
func (ID) MatchesPublicKey ¶
MatchesPublicKey tests whether this ID was derived from pk