noise: github.com/perlin-network/noise/skademlia Index | Files

package skademlia

import "github.com/perlin-network/noise/skademlia"

Index

Package Files

id.go keys.go mod.go msg.go rpc.go table.go

Constants

const (
    // DefaultC1 is the prefix-matching length for the static crypto puzzle.
    DefaultC1 = 8

    // DefaultC2 is the prefix-matching length for the dynamic crypto puzzle.
    DefaultC2 = 8

    // MaxPuzzleIterations is an internal limit for performing cryptographic puzzles for S/Kademlia.
    // This is set to stop the puzzle after about 1sec of failed continuous checks.
    MaxPuzzleIterations = 1000000
)
const (
    DefaultPrefixDiffLen = 128
    DefaultPrefixDiffMin = 32
)

Variables

var (
    ErrBucketFull = errors.New("kademlia: cannot add ID, bucket is full")
)

func Broadcast Uses

func Broadcast(node *noise.Node, message noise.Message) (errs []error)

Broadcast sends a message denoted by its opcode and content to all S/Kademlia IDs closest in terms of XOR distance to that of a specified node instances ID.

Every message sent will be blocking. To have every message sent not block the current goroutine, refer to `BroadcastAsync(node *noise.Node, message noise.Message)`

It returns a list of errors which have occurred in sending any messages to peers closest to a given node instance.

func BroadcastAsync Uses

func BroadcastAsync(node *noise.Node, message noise.Message)

BroadcastAsync sends a message denoted by its opcode and content to all S/Kademlia IDs closest in terms of XOR distance to that of a specified node instances ID.

Every message sent will be non-blocking. To have every message sent block the current goroutine, refer to `Broadcast(node *noise.Node, message noise.Message) (errs []error)`

func BucketSize Uses

func BucketSize() int

func FindClosestPeers Uses

func FindClosestPeers(t *table, target []byte, K int) (peers []protocol.ID)

FindClosestPeers returns a list of K peers with in order of ascending XOR distance.

func New Uses

func New() *block

func Table Uses

func Table(node *noise.Node) *table

func UpdateTable Uses

func UpdateTable(node *noise.Node, target protocol.ID) (err error)

func VerifyPuzzle Uses

func VerifyPuzzle(publicKey, id, nonce []byte, c1, c2 int) bool

VerifyPuzzle checks whether or not an id is a valid S/Kademlia id that suffices both S/Kademlia's static and dynamic puzzle given constants C1 and C2.

func WaitUntilAuthenticated Uses

func WaitUntilAuthenticated(peer *noise.Peer)

type Evict Uses

type Evict struct{ noise.EmptyMessage }

type ID Uses

type ID struct {
    // contains filtered or unexported fields
}

func FindNode Uses

func FindNode(node *noise.Node, targetID ID, alpha int, numDisjointPaths int) (results []ID)

FindNode implements the `FIND_NODE` RPC method denoted in Section 4.4 of the S/Kademlia paper: `Lookup over disjoint paths`.

Given a node instance N, and a S/Kademlia ID as a target T, α disjoint lookups take place in parallel over all closest peers to N to target T, with at most D lookups happening at once.

Each disjoint lookup queries at most α peers.

It returns at most BUCKET_SIZE S/Kademlia peer IDs closest to that of a specified target T.

func NewID Uses

func NewID(address string, publicKey, nonce []byte) ID

func (ID) Equals Uses

func (a ID) Equals(other protocol.ID) bool

func (ID) Hash Uses

func (a ID) Hash() []byte

func (ID) PublicKey Uses

func (a ID) PublicKey() []byte

func (ID) Read Uses

func (a ID) Read(reader payload.Reader) (msg noise.Message, err error)

func (ID) String Uses

func (a ID) String() string

func (ID) Write Uses

func (a ID) Write() []byte

type Keypair Uses

type Keypair struct {
    Nonce  []byte
    C1, C2 int
    // contains filtered or unexported fields
}

func LoadKeys Uses

func LoadKeys(privateKeyBuf []byte, c1, c2 int) (*Keypair, error)

LoadKeys loads a S/Kademlia given an Ed25519 private key, and validates it through both a static and dynamic crypto puzzle parameterized by constants C1 and C2 respectively.

func NewKeys Uses

func NewKeys(c1, c2 int) *Keypair

NewKeys randomly generates a set of cryptographic keys by solving both a static and dynamic crypto puzzle parameterized by constants C1 and C2 respectively.

func RandomKeys Uses

func RandomKeys() *Keypair

RandomKeys randomly generates a set of cryptographic keys by solving both a static and dynamic crypto puzzle parameterized by constants C1 = 8, and C2 = 8 respectively.

func (*Keypair) ID Uses

func (p *Keypair) ID() []byte

func (*Keypair) PrivateKey Uses

func (p *Keypair) PrivateKey() []byte

func (*Keypair) PublicKey Uses

func (p *Keypair) PublicKey() []byte

func (*Keypair) String Uses

func (p *Keypair) String() string

type LookupRequest Uses

type LookupRequest struct{ ID }

func (LookupRequest) Read Uses

func (m LookupRequest) Read(reader payload.Reader) (noise.Message, error)

type LookupResponse Uses

type LookupResponse struct {
    // contains filtered or unexported fields
}

func (LookupResponse) Read Uses

func (l LookupResponse) Read(reader payload.Reader) (noise.Message, error)

func (LookupResponse) Write Uses

func (l LookupResponse) Write() []byte

type Ping Uses

type Ping struct{ ID }

func (Ping) Read Uses

func (m Ping) Read(reader payload.Reader) (noise.Message, error)

Package skademlia imports 18 packages (graph) and is imported by 4 packages. Updated 2019-02-25. Refresh now. Tools for package owners.