peer

package module
v0.0.0-...-5f23346 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2017 License: MIT Imports: 10 Imported by: 0

README

go-libp2p-peer

standard-readme compliant GoDoc Coverage Status Build Status

PKI based identities for use in go-libp2p

Install

TODO

Usage

TODO

Format

An ID is a multihash with type either SHA2_256 or identity.

For most key types the type is SHA2_256 and the payload is the value of github.com/libp2p/go-libp2p-crypto.PubKey.Bytes().

<SHA2_256 mc><length (32)><SHA256 hash>
<0x12       ><0x20       ><SHA256 hash>

Ed25519 public keys instead are encoded with type identity and as payload a multicodec key in packed format.

<identity mc><length (2 + 32 = 34)><ed25519-pub mc><ed25519 pubkey>
<0x00       ><0x22                ><0xed01        ><ed25519 pubkey>

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

Want to hack on IPFS?

License

MIT

Documentation

Overview

package peer implements an object used to represent peers in the ipfs network.

Index

Constants

This section is empty.

Variables

View Source
var CodePrefixErr = errors.New("unexpected code prefix")
View Source
var MultihashCodecErr = errors.New("unexpected multihash codec")
View Source
var MultihashDecodeErr = errors.New("unable to decode multihash")
View Source
var MultihashLengthErr = errors.New("unexpected multihash length")

Functions

func IDB58Encode

func IDB58Encode(id ID) string

IDB58Encode returns b58-encoded string

func IDHexEncode

func IDHexEncode(id ID) string

IDHexEncode returns b58-encoded string

Types

type ID

type ID string

func IDB58Decode

func IDB58Decode(s string) (ID, error)

IDB58Decode returns a b58-decoded Peer

func IDFromBytes

func IDFromBytes(b []byte) (ID, error)

IDFromBytes cast a string to ID type, and validate the id to make sure it is a multihash.

func IDFromEd25519PublicKey

func IDFromEd25519PublicKey(pk ic.PubKey) (ID, error)

IDFromEd25519PublicKey returns the Peer ID corresponding to Id25519 pk

func IDFromPrivateKey

func IDFromPrivateKey(sk ic.PrivKey) (ID, error)

IDFromPrivateKey returns the Peer ID corresponding to sk

func IDFromPublicKey

func IDFromPublicKey(pk ic.PubKey) (ID, error)

IDFromPublicKey returns the Peer ID corresponding to pk

func IDFromString

func IDFromString(s string) (ID, error)

IDFromString cast a string to ID type, and validate the id to make sure it is a multihash.

func IDHexDecode

func IDHexDecode(s string) (ID, error)

IDHexDecode returns a b58-decoded Peer

func (ID) ExtractEd25519PublicKey

func (id ID) ExtractEd25519PublicKey() (ic.PubKey, error)

func (ID) ExtractPublicKey

func (id ID) ExtractPublicKey() ic.PubKey

ExtractPublicKey attempts to extract the public key from an ID

func (ID) Loggable

func (id ID) Loggable() map[string]interface{}

func (ID) MatchesPrivateKey

func (id ID) MatchesPrivateKey(sk ic.PrivKey) bool

MatchesPrivateKey tests whether this ID was derived from sk

func (ID) MatchesPublicKey

func (id ID) MatchesPublicKey(pk ic.PubKey) bool

MatchesPublicKey tests whether this ID was derived from pk

func (ID) Pretty

func (id ID) Pretty() string

Pretty returns a b58-encoded string of the ID

func (ID) String

func (id ID) String() string

String prints out the peer.

TODO(brian): ensure correctness at ID generation and enforce this by only exposing functions that generate IDs safely. Then any peer.ID type found in the codebase is known to be correct.

type IDSlice

type IDSlice []ID

IDSlice for sorting peers

func (IDSlice) Len

func (es IDSlice) Len() int

func (IDSlice) Less

func (es IDSlice) Less(i, j int) bool

func (IDSlice) Swap

func (es IDSlice) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL