tnet

package
v0.0.0-...-0e8913f Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: Unlicense Imports: 16 Imported by: 0

Documentation

Overview

Package tnet is a network abstraction

Index

Constants

View Source
const Version = "1.0"

Variables

This section is empty.

Functions

func GenerateSharedKey

func GenerateSharedKey(nonce []byte, self *PrivateKey, other *PublicKey) ([]byte, error)

func SharedKey

func SharedKey(cnfg.Config) error

Types

type Acceptor

type Acceptor interface {
	Accept() (io.ReadWriteCloser, error)
	io.Closer
}

type Conn

type Conn interface {
	Remote() Node // can be used in Network.Dial()
	packet.Connection
}

type KeyAndNonce

type KeyAndNonce struct {
	Key   *PublicKey
	Nonce []byte
}

func NewKeyAndNonce

func NewKeyAndNonce(pk *PublicKey) (*KeyAndNonce, error)

type Listener

type Listener interface {
	// Accept a connection asking for any of the given keys
	Accept(...*PrivateKey) (Conn, error)
	io.Closer
}

type Network

type Network interface {
	Addr() string
	Dial(*PrivateKey, Node) (Conn, error)
	Listen() (Listener, error)
}

all communication on network is authenticated by public key

func NewTCPLocalhost

func NewTCPLocalhost(port int) (Network, error)

type Node

type Node struct {
	Address   string     // how to reach the node
	PublicKey *PublicKey // node's public key, kind of like an ID, but may be transient
}

a processing node in the system

func (Node) String

func (n Node) String() string

type PrivateKey

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

func NewKey

func NewKey() (*PrivateKey, error)

func (PrivateKey) MarshalBinary

func (p PrivateKey) MarshalBinary() (data []byte, err error)

func (PrivateKey) Public

func (p PrivateKey) Public() *PublicKey

func (PrivateKey) Sign

func (p PrivateKey) Sign(hash []byte) ([]byte, error)

TODO: need to use schnorr instead; see https://www.coindesk.com/what-bitcoins-white-paper-got-right-wrong-and-what-we-still-dont-know

func (*PrivateKey) UnmarshalBinary

func (p *PrivateKey) UnmarshalBinary(data []byte) error

type PublicKey

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

func (PublicKey) Equal

func (p PublicKey) Equal(o *PublicKey) bool

func (PublicKey) Hash

func (p PublicKey) Hash() []byte

func (PublicKey) MarshalBinary

func (p PublicKey) MarshalBinary() (data []byte, err error)

func (PublicKey) MarshalJSON

func (p PublicKey) MarshalJSON() (data []byte, err error)

func (PublicKey) String

func (p PublicKey) String() string

func (*PublicKey) UnmarshalBinary

func (p *PublicKey) UnmarshalBinary(data []byte) error

func (PublicKey) Verify

func (p PublicKey) Verify(hash, sig []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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