authority

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: BSD-3-Clause Imports: 7 Imported by: 8

Documentation

Overview

Package authority defines the collective authority for cosipbft.

The package also contains an implementation of a roster and the related change set. A roster is a list of participants where each of them has an Mino address and a corresponding public key that supports aggregation for the collective signing.

Documentation Last Review: 13.10.2020

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterChangeSetFormat

func RegisterChangeSetFormat(c serde.Format, f serde.FormatEngine)

RegisterChangeSetFormat registers the engine for the provided format.

func RegisterRosterFormat

func RegisterRosterFormat(c serde.Format, f serde.FormatEngine)

RegisterRosterFormat registers the engine for the provided format.

Types

type AddrKeyFac

type AddrKeyFac struct{}

AddrKeyFac is the key for the address factory.

type Authority

type Authority interface {
	serde.Message
	serde.Fingerprinter
	crypto.CollectiveAuthority

	// Apply must apply the change set to the collective authority. It should
	// first remove, then add the new players.
	Apply(ChangeSet) Authority

	// Diff should return the change set to apply to get the given authority.
	Diff(Authority) ChangeSet
}

Authority is an extension of the collective authority to provide primitives to append new players to it.

type ChangeSet

type ChangeSet interface {
	serde.Message

	// NumChanges returns the number of changes that will be applied with this
	// change set.
	NumChanges() int

	// GetNewAddresses returns the list of addresses for the new members.
	GetNewAddresses() []mino.Address
}

ChangeSet is the return of a diff between two authorities.

type ChangeSetFactory

type ChangeSetFactory interface {
	serde.Factory

	ChangeSetOf(serde.Context, []byte) (ChangeSet, error)
}

ChangeSetFactory is the factory to deserialize change sets.

func NewChangeSetFactory

func NewChangeSetFactory(af mino.AddressFactory, pkf crypto.PublicKeyFactory) ChangeSetFactory

NewChangeSetFactory returns a new change set factory.

type Factory

type Factory interface {
	serde.Factory

	AuthorityOf(serde.Context, []byte) (Authority, error)
}

Factory is the factory to deserialize authorities.

func NewFactory

NewFactory creates a new instance of the authority factory.

type PubKeyFac

type PubKeyFac struct{}

PubKeyFac is the key for the public key factory.

type Roster

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

Roster contains a list of participants with their addresses and public keys.

- implements authority.Authority

func FromAuthority

func FromAuthority(authority crypto.CollectiveAuthority) Roster

FromAuthority returns a viewchange roster from a collective authority.

func New

func New(addrs []mino.Address, pubkeys []crypto.PublicKey) Roster

New creates a new roster from the list of addresses and public keys.

func (Roster) AddressIterator

func (r Roster) AddressIterator() mino.AddressIterator

AddressIterator implements mino.Players. It returns an iterator of the addresses of the roster in a deterministic order.

func (Roster) Apply

func (r Roster) Apply(in ChangeSet) Authority

Apply implements authority.Authority. It returns a new authority after applying the change set. The removals must be sorted by descending order and unique or the behaviour will be undefined.

func (Roster) Diff

func (r Roster) Diff(o Authority) ChangeSet

Diff implements authority.Authority. It returns the change set that must be applied to the current authority to get the given one.

func (Roster) Fingerprint

func (r Roster) Fingerprint(w io.Writer) error

Fingerprint implements serde.Fingerprinter. It marshals the roster and writes the result in the given writer.

func (Roster) GetPublicKey

func (r Roster) GetPublicKey(target mino.Address) (crypto.PublicKey, int)

GetPublicKey implements crypto.CollectiveAuthority. It returns the public key of the address if it exists, nil otherwise. The second return is the index of the public key in the authority.

func (Roster) Len

func (r Roster) Len() int

Len implements mino.Players. It returns the length of the authority.

func (Roster) PublicKeyIterator

func (r Roster) PublicKeyIterator() crypto.PublicKeyIterator

PublicKeyIterator implements crypto.CollectiveAuthority. It returns an iterator of the public keys of the roster in a deterministic order.

func (Roster) Serialize

func (r Roster) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message. It returns the serialized data for this roster.

func (Roster) Take

func (r Roster) Take(updaters ...mino.FilterUpdater) mino.Players

Take implements mino.Players. It returns a subset of the roster according to the filter.

type RosterChangeSet

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

RosterChangeSet is the smallest data model to update an authority to another.

- implements authority.ChangeSet

func NewChangeSet

func NewChangeSet() *RosterChangeSet

NewChangeSet creates a new empty change set.

func (*RosterChangeSet) Add

func (set *RosterChangeSet) Add(addr mino.Address, pubkey crypto.PublicKey)

Add appends the address and the public key to the list of new participants.

func (*RosterChangeSet) GetNewAddresses

func (set *RosterChangeSet) GetNewAddresses() []mino.Address

GetNewAddresses implements authority.ChangeSet. It returns the list of addresses of the new members.

func (*RosterChangeSet) GetPublicKeys

func (set *RosterChangeSet) GetPublicKeys() []crypto.PublicKey

GetPublicKeys returns the list of public keys of the new participants.

func (*RosterChangeSet) GetRemoveIndices

func (set *RosterChangeSet) GetRemoveIndices() []uint

GetRemoveIndices returns the list of indices to remove from the authority.

func (*RosterChangeSet) NumChanges

func (set *RosterChangeSet) NumChanges() int

NumChanges implements authority.ChangeSet. It returns the number of changes that is applied with the change set.

func (*RosterChangeSet) Remove

func (set *RosterChangeSet) Remove(index uint)

Remove appends the index to the list of removals.

func (*RosterChangeSet) Serialize

func (set *RosterChangeSet) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message. It returns the serialized data for this change set.

type SimpleChangeSetFactory

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

SimpleChangeSetFactory is a message factory to deserialize a change set.

- roster.ChangeSetFactory

func (SimpleChangeSetFactory) ChangeSetOf

func (f SimpleChangeSetFactory) ChangeSetOf(ctx serde.Context, data []byte) (ChangeSet, error)

ChangeSetOf implements roster.ChangeSetFactory. It returns the change set from the data if appropriate, otherwise an error.

func (SimpleChangeSetFactory) Deserialize

func (f SimpleChangeSetFactory) Deserialize(ctx serde.Context, data []byte) (serde.Message, error)

Deserialize implements serde.Factory. It returns the change set from the data if appropriate, otherwise an error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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