Documentation
¶
Overview ¶
Package tnet is a network abstraction
Index ¶
- Constants
- func GenerateSharedKey(nonce []byte, self *PrivateKey, other *PublicKey) ([]byte, error)
- func SharedKey(cnfg.Config) error
- type Acceptor
- type Conn
- type KeyAndNonce
- type Listener
- type Network
- type Node
- type PrivateKey
- type PublicKey
- func (p PublicKey) Equal(o *PublicKey) bool
- func (p PublicKey) Hash() []byte
- func (p PublicKey) MarshalBinary() (data []byte, err error)
- func (p PublicKey) MarshalJSON() (data []byte, err error)
- func (p PublicKey) String() string
- func (p *PublicKey) UnmarshalBinary(data []byte) error
- func (p PublicKey) Verify(hash, sig []byte) error
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)
Types ¶
type Conn ¶
type Conn interface { Remote() Node // can be used in Network.Dial() packet.Connection }
type KeyAndNonce ¶
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 ¶
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
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) MarshalBinary ¶
func (PublicKey) MarshalJSON ¶
func (*PublicKey) UnmarshalBinary ¶
Click to show internal directories.
Click to hide internal directories.