rmcbox

package
v0.0.0-...-7f98e96 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Overview

Package rmcbox implements a reliable multicast for arbitrary data.

This protocol is based on RBC (reliable broadcast), but has slightly different guarantees. Crucially a piece of data multicast with RMC with a given id will agree among all who received it, i.e. it is unique. The protocol has no hard guarantees pertaining pessimistic message complexity, but can be used in tandem with gossip protocols to disseminate data with proofs of uniqueness.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcceptGreeting

func AcceptGreeting(conn network.Connection) (pid uint16, id uint64, msgType byte, err error)

AcceptGreeting accepts a greeting and returns the information it learned from it.

func Greet

func Greet(w io.Writer, pid uint16, id uint64, msgType byte) error

Greet sends a greeting to the given conn.

Types

type RMC

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

RMC is a structure holding all data related to a series of reliable multicasts.

func New

func New(pubs []*bn256.VerificationKey, priv *bn256.SecretKey) *RMC

New creates a context for executing instances of the reliable multicast.

func (*RMC) AcceptData

func (rmc *RMC) AcceptData(id uint64, pid uint16, r io.Reader) ([]byte, error)

AcceptData reads the id from r, followed by the data and signature of the whole thing. It verifies that the id matches the provided one, and that the signature was made by pid. It returns the data itself, for protocol-independent verification.

func (*RMC) AcceptFinished

func (rmc *RMC) AcceptFinished(id uint64, pid uint16, r io.Reader) ([]byte, error)

AcceptFinished reads a pair of data and proof from r and verifies it corresponds to a successfully finished RMC.

func (*RMC) AcceptProof

func (rmc *RMC) AcceptProof(id uint64, r io.Reader) error

AcceptProof reads a proof from r and verifies it is a proof that id succeeded.

func (*RMC) AcceptSignature

func (rmc *RMC) AcceptSignature(id uint64, pid uint16, r io.Reader) (bool, error)

AcceptSignature reads a signature from r and verifies it represents pid signing the data associated with id. It returns true when the signature is exactly threshold-th signature gathered.

func (*RMC) Clear

func (rmc *RMC) Clear(id uint64)

Clear removes all information concerning id. After a clear the state is Unknown until any further calls with id.

func (*RMC) Data

func (rmc *RMC) Data(id uint64) []byte

Data returns the raw data corresponding to id. If the status differs from Finished, this data might be unreliable!

func (*RMC) InitiateRaw

func (rmc *RMC) InitiateRaw(id uint64, data []byte) error

InitiateRaw data signature gathering. This should be used only when all participants already know the data, and only want to produce a proof that it is agreed between them.

func (*RMC) Proof

func (rmc *RMC) Proof(id uint64) *multi.Signature

Proof returns the proof corresponding to id. If the status differs from Finished, returns nil.

func (*RMC) SendData

func (rmc *RMC) SendData(id uint64, data []byte, w io.Writer) error

SendData writes data concatenated with the id and signed by us to w.

func (*RMC) SendFinished

func (rmc *RMC) SendFinished(id uint64, w io.Writer) error

SendFinished writes the data and proof associated with id to w.

func (*RMC) SendProof

func (rmc *RMC) SendProof(id uint64, w io.Writer) error

SendProof writes the proof associated with id to w.

func (*RMC) SendSignature

func (rmc *RMC) SendSignature(id uint64, w io.Writer) error

SendSignature writes the signature associated with id to w. The signature signs the data.

func (*RMC) Status

func (rmc *RMC) Status(id uint64) Status

Status returns the state corresponding to id.

type Status

type Status byte

Status represents a state of a reliable multicast.

const (
	// Unknown means we either never saw any data related to an instance of RMC, or we deleted it.
	Unknown Status = iota

	// Data means we received or sent data that is being multicast, but we have not yet signed it.
	Data

	// Signed means we signed the piece of data, but we have not yet received the proof that it has been multicast successfully.
	Signed

	// Finished means we received a proof that the data has been multicast successfully.
	Finished
)

Jump to

Keyboard shortcuts

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