client

package
v0.0.0-...-938bef1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2017 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PROTOCOL_PDKG = iota
	PROTOCOL_RDKG = iota
)

Variables

View Source
var (
	Blake2 = "blake2"
)

encoder of the "application" message layer

View Source
var DefaultHash = Blake2
View Source
var ErrClosed = errors.New("stream: closed")

ErrClosed is returned when one call send() or receive() over a stream while the stream is closed

View Source
var ErrTimeout = errors.New("stream: timeout occured")

ErrTimeout is returned when a timeout has occured on a stream

View Source
var MaxIncorrectMessages = 100

how many incorrect messages do we allow before returning an error. This is necessary since anybody could join and spam any channel.

View Source
var ReliableMessageBuffer = 100

ReliableMessageBuffer indicates the maximum number of messages the reliable stream meachanism can hold in memory for the application layer to read

View Source
var ReliableReadTimeout = 1 * time.Minute

ReliableReadTimeout indicates how much time to wait for a "receive" operation using the reliable stream mechanism

View Source
var ReliableWaitRetry = 1 * time.Second

ReliableWaitRetry indicates the idle period between re-sending a packet to get an ACK

View Source
var ReliableWriteTimeout = 10 * time.Second

ReliableWriteTimeout indicates how much to wait for a "send" operation using the reliable stream meachanism

View Source
var SupportedHashes = []string{Blake2}

Functions

func NewHash

func NewHash(s string) (hash.Hash, error)

func NewPrivateIdentity

func NewPrivateIdentity(name string, r io.Reader) (*Private, *Identity, error)

func RegisterFileFetcher

func RegisterFileFetcher(ff FileFetcher)

Types

type Client

type Client struct {
}

Client can performs all distributed operations such as: - generating a random distributed secret (rds) - with two rds, it can sign a message

  • a self key signing process to be pgp compatible
  • a regular signing process to sign any message in a pgp compatible way

func NewClient

func NewClient() *Client

type ClientMessage

type ClientMessage struct {
	Type uint32

	PDkg *PDkg
}

type DKG

type DKG struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewDKG

func NewDKG(priv *Private, participants []*Identity, r *Router) (*DKG, error)

func (*DKG) Process

func (d *DKG) Process(id *Identity, cm *ClientMessage)

func (*DKG) Run

func (d *DKG) Run() (*dkg.DistKeyShare, error)

type Dispatcher

type Dispatcher interface {
	RegisterProcessor(Processor)
	Dispatch(*Identity, *ClientMessage)
}

Dispatcher receives messages, decode them and dispatch them to the registered processors. If multiple processors are registered, each message is dispatched to each processors.

type FileFetcher

type FileFetcher interface {
	Accept(url string) bool
	Grab(url string) ([]byte, error)
}

func FindFileFetcher

func FindFileFetcher(url string) FileFetcher

FindFileFetcher returns a FileFetcher for this URL or nil if none accept this URL.

func NewHttpFetcher

func NewHttpFetcher() FileFetcher

type GroupConfig

type GroupConfig struct {
	Name    string
	Email   string
	Comment string

	// coefficients of the public polynomial
	Public []kyber.Point
	// list of node's identity participating
	Ids []Identity
	// threshold of the group
	T int

	PgpID     uint64
	PgpPublic string
}

GroupConfig is the public configuration of a group using mulsigo. It is similar to a public pgp identity with a name, email and comment. It contains the additional public information on all the participants of the group.

type HttpFetcher

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

func (*HttpFetcher) Accept

func (h *HttpFetcher) Accept(url string) bool

func (*HttpFetcher) Grab

func (h *HttpFetcher) Grab(url string) ([]byte, error)

type Identity

type Identity struct {
	Name      string
	Key       []byte
	CreatedAt int64
	Signature []byte
	// reachable - usually empty if using a relay but if provided, will enable
	// one to make direct connection between a pair of peers.
	Address net.Address
}

func (*Identity) FromToml

func (i *Identity) FromToml(f string) error

func (*Identity) ID

func (i *Identity) ID() string

func (*Identity) Point

func (i *Identity) Point() kyber.Point

func (*Identity) PublicCurve25519

func (i *Identity) PublicCurve25519() [32]byte

func (*Identity) Repr

func (i *Identity) Repr() string

func (*Identity) Toml

func (i *Identity) Toml() interface{}

type Leader

type Leader struct {
	*Client
}

Leader is a Client that can performs the initial operations such as sending the first message containing the public informations of the pgp key (name, email etc), sending the file/text to sign.

func NewLeader

func NewLeader() *Leader

type NonBlockingRouter

type NonBlockingRouter struct {
	Router
}

NonBlockingRouter is a middleware around Router that sends and broadcasts messages in a asynchornous way using goroutine. Each methods returns a channel that will dispatch any future error if any.

func NewNonBlockingRouter

func NewNonBlockingRouter(r Router) *NonBlockingRouter

NewNonBlockingRouter returns a router that sends message asynchronously.

func (*NonBlockingRouter) Broadcast

func (n *NonBlockingRouter) Broadcast(cm *ClientMessage, ids ...*Identity) chan error

func (*NonBlockingRouter) Send

func (n *NonBlockingRouter) Send(id *Identity, cm *ClientMessage) chan error

Send use the underlying router's Send method to send the message in a goroutine. It returns a channel where the error will be dispatched.

type Object

type Object struct {
}

func NewLocalFileObject

func NewLocalFileObject(path string) (*Object, error)

func NewRemoteFileObject

func NewRemoteFileObject(url string) (*Object, error)

func NewTextObject

func NewTextObject(text string) *Object

type ObjectHandler

type ObjectHandler interface {
	Accept(*Object) bool
}

ObjectHandler is an interface allowing one to provide custom verification function on any object to be signed. A default impl. is provided which always accept to sign. Another one can be provided that ask to the user on the command line if it's OK or not etc... Implementations can use in conjunctions any FileGrabber implementation if the Object is a RemoteFile object.

type PDkg

type PDkg struct {
	Deal          *dkg.Deal
	Response      *dkg.Response
	Justification *dkg.Justification
}

type Private

type Private struct {
	Public *Identity
	// contains filtered or unexported fields
}

func (*Private) FromToml

func (p *Private) FromToml(f string) error

func (*Private) PrivateCurve25519

func (p *Private) PrivateCurve25519() [32]byte

func (*Private) PublicCurve25519

func (p *Private) PublicCurve25519() [32]byte

func (*Private) Scalar

func (p *Private) Scalar() kyber.Scalar

func (*Private) Toml

func (p *Private) Toml() interface{}

type Processor

type Processor interface {
	Process(*Identity, *ClientMessage)
}

Processor receives a message from a dispatcher.

type ReliablePacket

type ReliablePacket struct {
	Type     ReliableType
	Sequence uint32
	Data     []byte `protobuf:"opt"`
}

type ReliableType

type ReliableType bool
const (
	RELIABLE_DATA ReliableType = true
	RELIABLE_ACK  ReliableType = false
)

type Router

type Router struct {
	// dispatcher used to dispatch message
	Dispatcher

	// global lock making one Send at a time
	// XXX would there be a way to remove that constraint...
	sync.Mutex
	// contains filtered or unexported fields
}

Router is the main "network" entry point enabling one to send messages to a peer and to receive any messages. If it were an interface, it would look like:

type Router interface
   Dispatcher
	Send(*Identity, *ClientMessage) error
	Broadcast(cm *ClientMessage, ids ...*Identity) error
	Close()
}

Originally, the router was an interface but then extracted the only generic behavior to streamFactory.

func NewRouter

func NewRouter(factory streamFactory) *Router

NewRouter returns a router that handles streams connections and is the main public înterface to send / receive message

func (*Router) Broadcast

func (blr *Router) Broadcast(msg *ClientMessage, ids ...*Identity) error

Broadcast sends the message in parallel to all destinations given in ids. It returns the first error encountered.

func (*Router) Close

func (blr *Router) Close()

Close will close all registered streams.

func (*Router) Send

func (blr *Router) Send(remote *Identity, msg *ClientMessage) error

Send fetch or create the corresponding channel corresponding to the pair tied to the given remote identity. It then sends the message down that channel.

Jump to

Keyboard shortcuts

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