Documentation
¶
Overview ¶
P2P Noise Library. Please read more about Noise Protocol.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CipherSuite = noise.NewCipherSuite(noise.DH25519, noise.CipherChaChaPoly, noise.HashBLAKE2s)
var HandshakePattern = noise.HandshakeXX
Default Handshake "XX" noise pattern. Our approach its use a balanced "time/security" pattern. Please see NoisePatternExplorer for more details.
Functions ¶
This section is empty.
Types ¶
type BytePool ¶ added in v0.33.0
BytePool implements a leaky pool of []byte in the form of a bounded channel.
type CipherState ¶ added in v0.33.0
type CipherState = *noise.CipherState
CipherState provides symmetric encryption and decryption after a successful handshake. Please see docs for more information.
type Config ¶ added in v0.11.0
type Config interface {
// Default "tcp"
Protocol() string
// Default 0.0.0.0:8010
SelfListeningAddress() string
// Default 100
MaxPeersConnected() uint8
// Default 10 << 20 = 10MB
MaxPayloadSize() uint32
// Default 3600 seconds = 60 minutes
PeerDeadline() time.Duration
// Default 5 seconds
DialTimeout() time.Duration
}
type DHKey ¶ added in v0.34.0
DHKey is a keypair used for Diffie-Hellman key agreement. Please see docs for more details.
type EDKeyPair ¶ added in v0.39.0
type EDKeyPair struct {
Private PrivateKey
Public PublicKey
}
EDKeyPair hold public/private using entropy from rand. Every new handshake generate a new key pair.
type HandshakeState ¶ added in v0.33.0
type HandshakeState interface {
// WriteMessage appends a handshake message to out. The message will include the
// optional payload if provided. If the handshake is completed by the call, two
// CipherStates will be returned, one is used for encryption of messages to the
// remote peer, the other is used for decryption of messages from the remote
// peer. It is an error to call this method out of sync with the handshake
// pattern.
WriteMessage(out, payload []byte) ([]byte, CipherState, CipherState, error)
// ReadMessage processes a received handshake message and appends the payload,
// if any to out. If the handshake is completed by the call, two CipherStates
// will be returned, one is used for encryption of messages to the remote peer,
// the other is used for decryption of messages from the remote peer. It is an
// error to call this method out of sync with the handshake pattern.
ReadMessage(out, message []byte) ([]byte, CipherState, CipherState, error)
// PeerStatic returns the static key provided by the remote peer during
// a handshake. It is an error to call this method if a handshake message
// containing a static key has not been read.
PeerStatic() []byte
// MessageIndex returns the current handshake message id
MessageIndex() int
}
HandshakeState tracks the state of a Noise handshake. It may be discarded after the handshake is complete. Please see docs for more information.
type ID ¶ added in v0.33.0
type ID [32]byte
ID it's identity provider for peer.
type KeyRing ¶ added in v0.39.0
type KeyRing struct {
// contains filtered or unexported fields
}
KeyRing hold the set of local keys to use during handshake and session.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) Dial ¶
Dial attempt to connect to remote node and add connected peer to routing table. Return error if error occurred while dialing node.
func (*Node) Listen ¶
Listen start listening on the given address and wait for new connection. Return error if error occurred while listening.
type OperationalError ¶ added in v0.11.0
OperationalError represents an error that occurred when an operation in node failed. eg. Send a new message to invalid or not connected peer. eg. Error during Handshake.
func (OperationalError) Error ¶ added in v0.11.0
func (e OperationalError) Error() string
Error give string representation of error based on error type.
type OverflowError ¶ added in v0.11.0
OverflowError error represents a problem with the maximum setting of a parameter being exceeded. eg. MaxPeersConnected exceeded for incoming connections.
func (OverflowError) Error ¶ added in v0.11.0
func (e OverflowError) Error() string
Error give string representation of error based on error type.
type PrivateKey ¶ added in v0.39.0
type PrivateKey = ed25519.PrivateKey
type Signal ¶ added in v0.30.0
type Signal struct {
// contains filtered or unexported fields
}
Signal it is a message interface to transport network events. Each Signal keep a immutable state holding original header and body.