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 ¶
var ( // ErrEmptyPeerID is an error for empty peer ID. ErrEmptyPeerID = errors.New("empty peer ID") // ErrNoPublickKey is an error for peer IDs that don't embed public keys ErrNoPublicKey = errors.New("public key is not embedded in peer ID") )
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 ErrNoPublicKey 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