Documentation ¶
Overview ¶
Package protocol holds the SporeDB mycelium protocol.
Paquet format: - 1 byte for function selection - n bytes for data length specification (uvarint) - remaining bytes containing data
Index ¶
- Constants
- Variables
- type Call
- type Function
- type Gossip
- type Hello
- func (*Hello) Descriptor() ([]byte, []int)
- func (m *Hello) GetIdentity() string
- func (m *Hello) GetPublicKey() []byte
- func (m *Hello) GetSignature() []byte
- func (m *Hello) GetTimestamp() *google_protobuf.Timestamp
- func (m *Hello) GetVersion() uint64
- func (*Hello) ProtoMessage()
- func (m *Hello) Reset()
- func (m *Hello) String() string
- type InputStream
- type Node
- type Nodes
- type Raw
- type Session
- type Transport
Constants ¶
const ( FnHELLO Function = 0x01 FnSPORE = 0x02 FnENDORSE = 0x03 FnRECOVERREQUEST = 0x04 FnRAW = 0x05 FnGOSSIP = 0x06 FnNODES = 0x07 FnCATALOG = 0x08 )
Function values.
const Version uint64 = 1
Version is the current version of the protocol. Two different versions are not supposed to be able to communicate.
Variables ¶
var ( ErrOldTimestamp = errors.New("session timestamp too old") ErrInvalidPublicKey = errors.New("invalid public key") )
Errors for session management.
Functions ¶
This section is empty.
Types ¶
type Call ¶
Call represents a package that can be sent across the mycelium network.
func (*Call) Unpack ¶
func (c *Call) Unpack(in InputStream) error
Unpack retrieves one Call from raw stream.
type Gossip ¶
type Gossip struct { Spores []string `protobuf:"bytes,1,rep,name=spores" json:"spores,omitempty"` Request bool `protobuf:"varint,2,opt,name=request" json:"request,omitempty"` }
func (*Gossip) Descriptor ¶
func (*Gossip) GetRequest ¶
func (*Gossip) ProtoMessage ¶
func (*Gossip) ProtoMessage()
type Hello ¶
type Hello struct { Version uint64 `protobuf:"varint,1,opt,name=version" json:"version,omitempty"` Identity string `protobuf:"bytes,2,opt,name=identity" json:"identity,omitempty"` Timestamp *google_protobuf.Timestamp `protobuf:"bytes,3,opt,name=timestamp" json:"timestamp,omitempty"` // The public key is used in the ECDHE key exchange. // It MUST be a curve25519 public key. PublicKey []byte `protobuf:"bytes,9,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` // The signature of the Hello message is computed on the message with an empty signature. // signature = signature by emitter ( marshal ( hello without signature ) ) // // It is used as the authentication block of the ECDHE key exchange. // If the used signature key is not trusted by one peer, the connection MAY BE established // in "untrusted" mode, meaning that sensible operations MUST NOT be executed with the // connected peer (vulnerable to MitM attacks). Signature []byte `protobuf:"bytes,10,opt,name=signature,proto3" json:"signature,omitempty"` }
func (*Hello) Descriptor ¶
func (*Hello) GetIdentity ¶
func (*Hello) GetPublicKey ¶
func (*Hello) GetSignature ¶
func (*Hello) GetTimestamp ¶
func (m *Hello) GetTimestamp() *google_protobuf.Timestamp
func (*Hello) GetVersion ¶
func (*Hello) ProtoMessage ¶
func (*Hello) ProtoMessage()
type InputStream ¶
type InputStream interface { io.Reader io.ByteReader }
InputStream represents a reader that can also be read byte by byte.
type Node ¶
type Node struct { Identity string `protobuf:"bytes,1,opt,name=identity" json:"identity,omitempty"` Address string `protobuf:"bytes,2,opt,name=address" json:"address,omitempty"` }
func (*Node) Descriptor ¶
func (*Node) GetAddress ¶
func (*Node) GetIdentity ¶
func (*Node) ProtoMessage ¶
func (*Node) ProtoMessage()
type Nodes ¶
type Nodes struct {
Nodes []*Node `protobuf:"bytes,1,rep,name=nodes" json:"nodes,omitempty"`
}
func (*Nodes) Descriptor ¶
func (*Nodes) ProtoMessage ¶
func (*Nodes) ProtoMessage()
type Raw ¶
type Raw struct { Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` Version *version.V `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"` Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` Signature []byte `protobuf:"bytes,10,opt,name=signature,proto3" json:"signature,omitempty"` }
func (*Raw) Descriptor ¶
func (Raw) GetMessage ¶
GetMessage returns the message used in the signature of a raw message.
func (*Raw) GetSignature ¶
func (*Raw) GetVersion ¶
func (*Raw) ProtoMessage ¶
func (*Raw) ProtoMessage()
type Session ¶
type Session interface { // A Session can acts as a Transport itself, being transparent for the application. Transport // Hello builds a new Hello message (handshake). // It might be called several times, in case of connection reset. Hello() (*Hello, error) // Verify verifies Hello messages for conformity. // It might be called several times, in case of connection reset. Verify(*Hello) error // Open MUST be called after sending an Hello message and having received // a verified Hello message from the peer. It opens incoming and outgoing // encrypted channel. Open(Transport) error // IsTrusted returns weither the peer shall be trusted (is correctly authenticated). IsTrusted() bool }
Session shall be used to establish a secure channel between two peers. It shall act as a proxy between the application and the underlying Transport.
func NewECDHESession ¶
NewECDHESession returns a ECDHE session, using the KeyRing for peer authentication and signature management. Identity must be current node's own identity.
Once Open has been called, every data passing through this Session will be encrypted using AES-256-CTR. Additional data authentication mechanism should be used for sensible informations (Raw messages for instance).
type Transport ¶
type Transport interface { io.ReadWriteCloser io.ByteReader }
Transport is a generic representation of a communication channel.
func NewLocalTransport ¶
func NewLocalTransport() (a, b Transport)
NewLocalTransport returns two bounded Transport for use in tests.