Select Git revision
interface.go
interface.go 17.56 KiB
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2022 xx foundation //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file. //
////////////////////////////////////////////////////////////////////////////////
package cmix
import (
"time"
"gitlab.com/elixxir/client/v4/cmix/gateway"
"gitlab.com/elixxir/client/v4/cmix/identity"
"gitlab.com/elixxir/client/v4/cmix/message"
"gitlab.com/elixxir/client/v4/cmix/nodes"
"gitlab.com/elixxir/client/v4/cmix/rounds"
"gitlab.com/elixxir/client/v4/stoppable"
"gitlab.com/elixxir/comms/network"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
)
type Client interface {
// Follow starts the tracking of the network in a new thread.
// Errors that occur are reported on the ClientErrorReport function if
// passed. The returned stoppable can be used to stop the follower.
// Only one follower may run at a time.
Follow(report ClientErrorReport) (stoppable.Stoppable, error)
/* === Sending ========================================================== */
// GetMaxMessageLength returns the max message size for the current network.
GetMaxMessageLength() int
// Send sends a "raw" cMix message payload to the provided recipient.
// Returns the round ID of the round the payload was sent or an error if it
// fails.
// This does not have end-to-end encryption on it and is used exclusively as
// a send for higher order cryptographic protocols. Do not use unless
// implementing a protocol on top.
// recipient - cMix ID of the recipient.
// fingerprint - Key Fingerprint. 256-bit field to store a 255-bit
// fingerprint, highest order bit must be 0 (panic otherwise). If your
// system does not use key fingerprints, this must be random bits.
// service - Reception Service. The backup way for a client to identify
// messages on receipt via trial hashing and to identify notifications.
// If unused, use message.GetRandomService to fill the field with
// random data.
// payload - Contents of the message. Cannot exceed the payload size for a
// cMix message (panic otherwise).
// mac - 256-bit field to store a 255-bit mac, highest order bit must be 0
// (panic otherwise). If used, fill with random bits.
// Will return an error if the network is unhealthy or if it fails to send
// (along with the reason). Blocks until successful sends or errors.
// WARNING: Do not roll your own crypto.
Send(recipient *id.ID, fingerprint format.Fingerprint,
service message.Service, payload, mac []byte, cmixParams CMIXParams) (
rounds.Round, ephemeral.Id, error)
// SendMany sends many "raw" cMix message payloads to the provided
// recipients all in the same round.
// Returns the round ID of the round the payloads was sent or an error if it
// fails.
// This does not have end-to-end encryption on it and is used exclusively as
// a send for higher order cryptographic protocols. Do not use unless
// implementing a protocol on top.
// Due to sending multiple payloads, this leaks more metadata than a