blsbftv2

package
v0.0.0-...-dbbd7c7 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnExpectedError = iota
	ConsensusTypeNotExistError
	ProducerSignatureError
	CommitteeSignatureError
	CombineSignatureError
	SignDataError
	LoadKeyError
	ConsensusAlreadyStartedError
	ConsensusAlreadyStoppedError
	DecodeValidationDataError
	EncodeValidationDataError
	BlockCreationError
)
View Source
const (
	MSG_PROPOSE    = "propose"
	MSG_VOTE       = "vote"
	MSG_REQUESTBLK = "getblk"
)

Variables

View Source
var ErrCodeMessage = map[int]struct {
	Code    int
	message string
}{
	UnExpectedError:              {-1000, "Unexpected error"},
	ConsensusTypeNotExistError:   {-1001, "Consensus type isn't exist"},
	ProducerSignatureError:       {-1002, "Producer signature error"},
	CommitteeSignatureError:      {-1003, "Committee signature error"},
	CombineSignatureError:        {-1004, "Combine signature error"},
	SignDataError:                {-1005, "Sign data error"},
	LoadKeyError:                 {-1006, "Load key error"},
	ConsensusAlreadyStartedError: {-1007, "consensus already started error"},
	ConsensusAlreadyStoppedError: {-1008, "consensus already stopped error"},
	DecodeValidationDataError:    {-1009, "Decode Validation Data error"},
	EncodeValidationDataError:    {-1010, "Encode Validation Data Error"},
	BlockCreationError:           {-1011, "Block Creation Error"},
}

Functions

func EncodeValidationData

func EncodeValidationData(validationData ValidationData) (string, error)

func ExtractBridgeValidationData

func ExtractBridgeValidationData(block common.BlockInterface) ([][]byte, []int, error)

func LoadUserKeyFromIncPrivateKey

func LoadUserKeyFromIncPrivateKey(privateKey string) (string, error)

func MakeBFTProposeMsg

func MakeBFTProposeMsg(proposeCtn *BFTPropose, chainKey string, ts int64, height uint64) (wire.Message, error)

func MakeBFTRequestBlk

func MakeBFTRequestBlk(request BFTRequestBlock, peerID string, chainKey string) (wire.Message, error)

func MakeBFTVoteMsg

func MakeBFTVoteMsg(vote *BFTVote, chainKey string, ts int64, height uint64) (wire.Message, error)

func NewConsensusError

func NewConsensusError(key int, err error) error

func ValidateCommitteeSig

func ValidateCommitteeSig(block common.BlockInterface, committee []incognitokey.CommitteePublicKey) error

func ValidateProducerSig

func ValidateProducerSig(block common.BlockInterface) error

Types

type BFTPropose

type BFTPropose struct {
	PeerID   string
	Block    json.RawMessage
	TimeSlot uint64
}

type BFTRequestBlock

type BFTRequestBlock struct {
	BlockHash string
	PeerID    string
}

type BFTVote

type BFTVote struct {
	//ViewHash     string
	PrevBlockHash string
	BlockHash     string
	Validator     string
	BLS           []byte
	BRI           []byte
	Confirmation  []byte

	TimeSlot uint64
	// contains filtered or unexported fields
}

type BLSBFT_V2

type BLSBFT_V2 struct {
	Chain    ChainInterface
	Node     NodeInterface
	ChainKey string
	ChainID  int
	PeerID   string

	UserKeySet   *MiningKey
	BFTMessageCh chan wire.MessageBFT

	StopCh chan struct{}
	Logger common.Logger

	ProposeMessageCh chan BFTPropose
	VoteMessageCh    chan BFTVote
	// contains filtered or unexported fields
}

func NewInstance

func NewInstance(chain ChainInterface, chainKey string, chainID int, node NodeInterface, logger common.Logger) *BLSBFT_V2

func (BLSBFT_V2) CreateValidationData

func (e BLSBFT_V2) CreateValidationData(block common.BlockInterface) ValidationData

func (BLSBFT_V2) GetChainID

func (e BLSBFT_V2) GetChainID() int

func (BLSBFT_V2) GetChainKey

func (e BLSBFT_V2) GetChainKey() string

func (*BLSBFT_V2) GetConsensusName

func (e *BLSBFT_V2) GetConsensusName() string

func (*BLSBFT_V2) GetUserPublicKey

func (e *BLSBFT_V2) GetUserPublicKey() *incognitokey.CommitteePublicKey

func (BLSBFT_V2) IsOngoing

func (e BLSBFT_V2) IsOngoing() bool

func (BLSBFT_V2) IsStarted

func (e BLSBFT_V2) IsStarted() bool

func (*BLSBFT_V2) LoadUserKey

func (e *BLSBFT_V2) LoadUserKey(privateSeed string) error

func (*BLSBFT_V2) LoadUserKeyFromIncPrivateKey

func (e *BLSBFT_V2) LoadUserKeyFromIncPrivateKey(privateKey string) (string, error)

func (*BLSBFT_V2) ProcessBFTMsg

func (e *BLSBFT_V2) ProcessBFTMsg(msgBFT *wire.MessageBFT)

func (BLSBFT_V2) SignData

func (e BLSBFT_V2) SignData(data []byte) (string, error)

func (*BLSBFT_V2) Start

func (e *BLSBFT_V2) Start() error

func (*BLSBFT_V2) Stop

func (e *BLSBFT_V2) Stop() error

func (BLSBFT_V2) ValidateBlockWithConsensus

func (e BLSBFT_V2) ValidateBlockWithConsensus(block common.BlockInterface) error

func (BLSBFT_V2) ValidateData

func (e BLSBFT_V2) ValidateData(data []byte, sig string, publicKey string) error

type ChainInterface

type ChainInterface interface {
	GetFinalView() multiview.View
	GetBestView() multiview.View
	GetEpoch() uint64
	GetChainName() string
	GetConsensusType() string
	GetLastBlockTimeStamp() int64
	GetMinBlkInterval() time.Duration
	GetMaxBlkCreateTime() time.Duration
	IsReady() bool
	SetReady(bool)
	GetActiveShardNumber() int
	CurrentHeight() uint64
	GetCommitteeSize() int
	GetCommittee() []incognitokey.CommitteePublicKey
	GetPendingCommittee() []incognitokey.CommitteePublicKey
	GetPubKeyCommitteeIndex(string) int
	GetLastProposerIndex() int
	UnmarshalBlock(blockString []byte) (common.BlockInterface, error)
	CreateNewBlock(version int, proposer string, round int, startTime int64) (common.BlockInterface, error)
	CreateNewBlockFromOldBlock(oldBlock common.BlockInterface, proposer string, startTime int64) (common.BlockInterface, error)
	InsertAndBroadcastBlock(block common.BlockInterface) error
	// ValidateAndInsertBlock(block common.BlockInterface) error
	ValidateBlockSignatures(block common.BlockInterface, committee []incognitokey.CommitteePublicKey) error
	ValidatePreSignBlock(block common.BlockInterface) error
	GetShardID() int

	//for new syncker
	GetBestViewHeight() uint64
	GetFinalViewHeight() uint64
	GetBestViewHash() string
	GetFinalViewHash() string

	GetViewByHash(hash common.Hash) multiview.View
}

type ConsensusError

type ConsensusError struct {
	Code    int
	Message string
	// contains filtered or unexported fields
}

func (ConsensusError) Error

func (e ConsensusError) Error() string

type MiningKey

type MiningKey struct {
	PriKey map[string][]byte
	PubKey map[string][]byte
}

func GetMiningKeyFromPrivateSeed

func GetMiningKeyFromPrivateSeed(privateSeed string) (*MiningKey, error)

func (*MiningKey) BLSSignData

func (miningKey *MiningKey) BLSSignData(
	data []byte,
	selfIdx int,
	committee []blsmultisig.PublicKey,
) (
	[]byte,
	error,
)

func (*MiningKey) BriSignData

func (miningKey *MiningKey) BriSignData(
	data []byte,
) (
	[]byte,
	error,
)

func (*MiningKey) GetPublicKey

func (miningKey *MiningKey) GetPublicKey() incognitokey.CommitteePublicKey

func (*MiningKey) GetPublicKeyBase58

func (miningKey *MiningKey) GetPublicKeyBase58() string

type NodeInterface

type NodeInterface interface {
	PushMessageToChain(msg wire.Message, chain common.ChainInterface) error
	IsEnableMining() bool
	GetMiningKeys() string
	GetPrivateKey() string
	GetUserMiningState() (role string, chainID int)
	RequestMissingViewViaStream(peerID string, hashes [][]byte, fromCID int, chainName string) (err error)
	GetSelfPeerID() peer.ID
}

type ProposeBlockInfo

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

type ValidationData

type ValidationData struct {
	ProducerBLSSig []byte
	ProducerBriSig []byte
	ValidatiorsIdx []int
	AggSig         []byte
	BridgeSig      [][]byte
}

func DecodeValidationData

func DecodeValidationData(data string) (*ValidationData, error)

Jump to

Keyboard shortcuts

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