types

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: MIT Imports: 25 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateIsValidSignature

func GenerateIsValidSignature(sigVerifier func(state *signatures.TreeState) (bool, error)) chaintree.BlockValidatorFunc

isValidSignature checks payloads with both Signature and Tip elements to verify that the Signature is indeed valid for Tip. It is currently used for RECEIVE_TOKEN transactions and so looks for them explicitly, but should be generalized to other transaction types that have similar Signature & Tip elements when/if they appear.

GenerateIsValidSignature is a higher-order function that takes a signature verifier function arg and returns an IsValidSignature validator function (see above) that calls the given sigVerifier with the Signature and Tip it receives and uses its return values to determine validity.

func HasBurnGenerator

func HasBurnGenerator(ctx context.Context, ng *NotaryGroup) (chaintree.BlockValidatorFunc, error)

HasBurnGenerator is a higher-order generator (because we need notary group config for the token name) that returns a ChainTree validator that looks for the precense of a token burn in a block of transactions if the block has a transaction which has a SendToken with the config TransactionToken name, a value > 0 and a "" destination, it is considered a burn.

func IsOwner

func IsOwner(tree *dag.Dag, blockWithHeaders *chaintree.BlockWithHeaders) (bool, chaintree.CodedError)

IsOwner is a chaintree BlockValidator that looks at the block headers and makes sure an authorized owner (in the consensus.TreePathForAuthentications path) has signed this block.

func IsTokenRecipient

func IsTokenRecipient(tree *dag.Dag, blockWithHeaders *chaintree.BlockWithHeaders) (bool, chaintree.CodedError)

IsTokenRecipient is only applicable to RECEIVE_TOKEN transactions it checks whether the destination chaintree id matches our id or not

func RegisterTransactor

func RegisterTransactor(name string, fn chaintree.TransactorFunc) error

RegisterTransactor is used to make transactors available for the human-readable configs

func RegisterValidatorGenerator

func RegisterValidatorGenerator(name string, fn ValidatorGenerator) error

RegisterValidatorGenerator registers your validator generator with a human-readable name so that it can be specified in the on-disk configs.

Types

type Config

type Config struct {
	// ID of the notary group (generally a DID)
	ID string
	// TransactionToken is the token used for transaction fees (in the form <did>/<tokenName>)
	TransactionToken string
	// BurnAmount is the amount of TransactionToken that must be burned for the HasBurn block validator to pass
	BurnAmount uint64
	// TransactionTopic is the topic used to send AddBlockRequests to the notary group
	TransactionTopic string
	// CommitTopic is the topic used to spread the CurrentStates (to both signers and clients)
	CommitTopic string
	// ValidatorGenerators is a slice of generators for chaintree.BlockValidatorFuncs (see ValidatorGenerator)
	ValidatorGenerators []ValidatorGenerator
	// Transactions is the map of all supported transactions by this notary group.
	Transactions map[transactions.Transaction_Type]chaintree.TransactorFunc
	// Signers is the set of VerKey and DestKey necessary to validate and reach a signer
	Signers []PublicKeySet
	//BootstrapAddresses is a slice of PeerIDs to use for bootstrapping this notary group
	BootstrapAddresses []string
}

Config is the simplest thing that could work for now it is just an in-memory only configuration for the notary group.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns what we (as of this commit) use for our block validators GenerateIsValidSignature is ommitted in this first round because it is a higher-order function that needs information from a closure not known to the notary group. it will be special cased over in tupelo and then migrated to this format.

func HumanConfigToConfig

func HumanConfigToConfig(hc *config.NotaryGroup) (*Config, error)

func TomlToConfig

func TomlToConfig(tomlBytes string) (*Config, error)

TomlToConfig will load a notary group config from a toml string Generally these configs are nested and so you will rarely need to use this function, it's more to validate example files and to use in tests.

func (*Config) NotaryGroup

func (c *Config) NotaryGroup(local *Signer) (*NotaryGroup, error)

type NotaryGroup

type NotaryGroup struct {
	ID      string
	Signers map[string]*Signer
	// contains filtered or unexported fields
}

NotaryGroup represents a notary group.

func NewNotaryGroup

func NewNotaryGroup(id string) *NotaryGroup

NewNotaryGroup instantiates a new NotaryGroup.

func NewNotaryGroupFromConfig

func NewNotaryGroupFromConfig(c *Config) *NotaryGroup

func (*NotaryGroup) AddSigner

func (ng *NotaryGroup) AddSigner(signer *Signer)

AddSigner adds a signer to group.

func (*NotaryGroup) AllSigners

func (ng *NotaryGroup) AllSigners() []*Signer

func (*NotaryGroup) BlockValidators

func (ng *NotaryGroup) BlockValidators(ctx context.Context) ([]chaintree.BlockValidatorFunc, error)

func (*NotaryGroup) Config

func (ng *NotaryGroup) Config() *Config

func (*NotaryGroup) GetMajorityCount

func (ng *NotaryGroup) GetMajorityCount() int64

func (*NotaryGroup) GetRandomSigner

func (ng *NotaryGroup) GetRandomSigner() *Signer

func (*NotaryGroup) GetRandomSyncer

func (ng *NotaryGroup) GetRandomSyncer() *actor.PID

func (*NotaryGroup) IndexOfSigner

func (ng *NotaryGroup) IndexOfSigner(signer *Signer) uint64

func (*NotaryGroup) QuorumCount

func (ng *NotaryGroup) QuorumCount() uint64

func (*NotaryGroup) RewardsCommittee

func (ng *NotaryGroup) RewardsCommittee(key []byte, excluding *Signer) ([]*Signer, error)

func (*NotaryGroup) SetupAllRemoteActors

func (ng *NotaryGroup) SetupAllRemoteActors(localKey *ecdsa.PublicKey)

func (*NotaryGroup) SignerAtIndex

func (ng *NotaryGroup) SignerAtIndex(idx int) *Signer

func (*NotaryGroup) Size

func (ng *NotaryGroup) Size() uint64

type PublicKeySet

type PublicKeySet struct {
	VerKey  *bls.VerKey
	DestKey *ecdsa.PublicKey
}

type RoutableAddress

type RoutableAddress string

func NewRoutableAddress

func NewRoutableAddress(from, to string) RoutableAddress

func (RoutableAddress) From

func (ra RoutableAddress) From() string

func (RoutableAddress) String

func (ra RoutableAddress) String() string

func (RoutableAddress) Swap

func (ra RoutableAddress) Swap() RoutableAddress

func (RoutableAddress) To

func (ra RoutableAddress) To() string

type Signer

type Signer struct {
	ID     string
	DstKey *ecdsa.PublicKey
	VerKey *bls.VerKey

	SignKey *bls.SignKey
	Actor   *actor.PID
}

func NewLocalSigner

func NewLocalSigner(dstKey *ecdsa.PublicKey, signKey *bls.SignKey) *Signer

func NewRemoteSigner

func NewRemoteSigner(dstKey *ecdsa.PublicKey, verKey *bls.VerKey) *Signer

func (*Signer) ActorAddress

func (s *Signer) ActorAddress(localKey *ecdsa.PublicKey) string

func (*Signer) ActorName

func (s *Signer) ActorName() string

ActorName returns the default name that should be used for the spawned actor of this signer.

type TomlConfig

type TomlConfig struct {
	*config.NotaryGroup
	Signers []TomlPublicKeySet
}

type TomlPublicKeySet

type TomlPublicKeySet struct {
	VerKeyHex  string
	DestKeyHex string
}

type ValidatorGenerator

type ValidatorGenerator func(ctx context.Context, notaryGroup *NotaryGroup) (chaintree.BlockValidatorFunc, error)

ValidatorGenerator is a higher order function that is used to generate a chaintree.BlockValidator that knows about the context it's being executed in. Specifically this is useful when the BlockValidator needs to know things about the notary group (like the signers) or a config (like a token necessary for transactions) the config stores these generators and the notary group exposes a BlockValidators function in order to generate validators based on the current state of the notary group.

func WrapStatelessValidator

func WrapStatelessValidator(fn chaintree.BlockValidatorFunc) ValidatorGenerator

WrapStatelessValidator is a convenience function when your BlockValidatorFunc does not need any state from the notary group or config. Currently IsOwner and IsTokenRecipient do not need any state and so this lets one easily wrap them.

Jump to

Keyboard shortcuts

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