keyper

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: MIT Imports: 43 Imported by: 0

Documentation

Overview

Package keyper contains the keyper implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsWebsocketURL

func IsWebsocketURL(url string) bool

IsWebsocketURL returns true iff the given URL is a websocket URL, i.e. if it starts with ws:// or wss://. This is needed for the watchMainChainHeadBlock method.

func NewContractCallerFromConfig

func NewContractCallerFromConfig(config Config) (contract.Caller, error)

Types

type Batch

type Batch struct {
	BatchIndex               uint64
	DecryptionSignatureHash  []byte
	DecryptedTransactions    [][]byte
	DecryptedBatchHash       []byte
	DecryptionSignatureIndex int
	VerifiedSignatures       map[common.Address][]byte
	IsEmpty                  bool
}

Batch is used to store local state about a single Batch.

func (*Batch) AddSignature

func (batch *Batch) AddSignature(sender common.Address, signature []byte)

func (*Batch) VerifySignature

func (batch *Batch) VerifySignature(sender common.Address, signature []byte) bool

VerifySignature checks if the sender signed the batches' DecryptionSignatureHash.

type Config

type Config struct {
	ShuttermintURL              string
	EthereumURL                 string
	DBDir                       string
	SigningKey                  *ecdsa.PrivateKey
	ValidatorKey                ed25519.PrivateKey `mapstructure:"ValidatorSeed"`
	EncryptionKey               *ecies.PrivateKey
	ConfigContractAddress       common.Address `mapstructure:"ConfigContract"`
	BatcherContractAddress      common.Address `mapstructure:"BatcherContract"`
	KeyBroadcastContractAddress common.Address `mapstructure:"KeyBroadcastContract"`
	ExecutorContractAddress     common.Address `mapstructure:"ExecutorContract"`
	DepositContractAddress      common.Address `mapstructure:"DepositContract"`
	KeyperSlasherAddress        common.Address `mapstructure:"KeyperSlasher"`
	MainChainFollowDistance     uint64         // in main chain blocks
	ExecutionStaggering         uint64         // in main chain blocks
	DKGPhaseLength              uint64         // in shuttermint blocks
	GasPriceMultiplier          float64
}

Config contains validated configuration parameters for the keyper client.

func (*Config) Address

func (config *Config) Address() common.Address

Address returns the keyper's Ethereum address.

func (*Config) GenerateNewKeys

func (config *Config) GenerateNewKeys() error

GenerateNewKeys generates new keys and stores them inside the Config object.

func (*Config) Unmarshal

func (config *Config) Unmarshal(v *viper.Viper) error

Unmarshal unmarshals a keyper Config from the the given Viper object.

func (*Config) WriteTOML

func (config *Config) WriteTOML(w io.Writer) error

WriteTOML writes a toml configuratio file with the given config.

type DKG

type DKG struct {
	Eon                  uint64
	StartBatchIndex      uint64
	Keypers              []common.Address
	Pure                 *puredkg.PureDKG
	OutgoingPolyEvalMsgs []puredkg.PolyEvalMsg
	PhaseLength          PhaseLength
}

DKG is used to store local state about active DKG processes. Each DKG has a corresponding observe.Eon struct stored in observe.Shutter, which we can find with Shutter's FindEon method.

func (*DKG) IsFinalized

func (dkg *DKG) IsFinalized() bool

func (*DKG) ShortInfo

func (dkg *DKG) ShortInfo() string

type Decider

type Decider struct {
	Config      Config
	State       *State
	Shutter     *observe.Shutter
	MainChain   *observe.MainChain
	Actions     []fx.IAction
	PhaseLength PhaseLength
}

Decider decides on the next actions to take based on our internal State and the current Shutter and MainChain state for a single step. For each step the keyper creates a new Decider. The actions to run are stored inside the Actions field.

func NewDecider

func NewDecider(kpr *Keyper) Decider

func (*Decider) Decide

func (dcdr *Decider) Decide()

Decide determines the next actions to run.

type EKG

type EKG struct {
	Eon     uint64
	Keypers []common.Address
	EpochKG *epochkg.EpochKG
}

EKG is used to store local state about the epoch key generation process.

type Keyper

type Keyper struct {
	Config Config // Configuration of the keyper client read from the config file
	State  *State // keyper's internal state

	ContractCaller contract.Caller

	MessageSender fx.MessageSender
	// contains filtered or unexported fields
}

func NewKeyper

func NewKeyper(kc Config) Keyper

func (*Keyper) CurrentWorld

func (kpr *Keyper) CurrentWorld() observe.World

func (*Keyper) LoadState

func (kpr *Keyper) LoadState() error

func (*Keyper) Run

func (kpr *Keyper) Run(ctx context.Context) error

func (*Keyper) ShortInfo

func (kpr *Keyper) ShortInfo() string

type PhaseLength

type PhaseLength struct {
	Off         int64
	Dealing     int64
	Accusing    int64
	Apologizing int64
}

PhaseLength is used to store the accumulated lengths of the DKG phases.

func NewConstantPhaseLength

func NewConstantPhaseLength(l int64) PhaseLength

NewConstantPhaseLength creates a new phase length definition where each phase has the same length.

type State

type State struct {
	CheckInMessageSent       bool
	LastSentBatchConfigIndex uint64
	LastEonStarted           uint64
	DKGs                     []DKG
	EKGs                     []*EKG
	PendingHalfStep          *uint64
	PendingAppeals           map[uint64]struct{}
	NextEpochSecretShare     uint64
	Batches                  map[uint64]*Batch
	HalfStepsChecked         uint64

	// We store the actions that should be executed together with a counter. When starting the
	// program, we feed these actions into runenv, which can use the counter to identify the
	// actions.
	ActionCounter uint64
	Actions       []fx.IAction

	SyncHeight int64
}

State is the keyper's internal state.

func NewState

func NewState() *State

NewState creates an empty State object.

func (*State) FindEKGByEon

func (st *State) FindEKGByEon(eon uint64) (*EKG, error)

func (*State) GetShutterFilter

func (st *State) GetShutterFilter(mainChain *observe.MainChain) observe.ShutterFilter

GetShutterFilter returns the shutter filter to be applied to the Shutter state.

Directories

Path Synopsis
epochkg implements the epoch key generation given the result of a successful DKG generation with puredkg
epochkg implements the epoch key generation given the result of a successful DKG generation with puredkg
Package fx is used to effect changes on the outside world, i.e.
Package fx is used to effect changes on the outside world, i.e.
Package gaspricer is used to multiply the gas price by a configurable factor.
Package gaspricer is used to multiply the gas price by a configurable factor.
Package observe contains the MainChain and Shutter structs, which the keyper uses to fetch the necessary information from the ethereum node and the shuttermint node.
Package observe contains the MainChain and Shutter structs, which the keyper uses to fetch the necessary information from the ethereum node and the shuttermint node.
Package puredkg implements the DKG protocol.
Package puredkg implements the DKG protocol.
Package shutterevents contains types to represent deserialized shuttermint/tendermint events
Package shutterevents contains types to represent deserialized shuttermint/tendermint events
evtype
evtype declares the the different event types sent by shuttermint
evtype declares the the different event types sent by shuttermint

Jump to

Keyboard shortcuts

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