apos

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: GPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ROUND_OK = iota
	ROUND_HANGFOREVER
	ROUND_NO_BLOCK
	ROUND_STOP
	ROUND_INSERT_ERR
	ROUND_WRITE_CERTIFICATE_ERR
)
View Source
const (
	//font style
	COLOR_STYLE_RESET     = ";0"
	COLOR_STYLE_HIGHLIGHT = ";1"
	COLOR_STYLE_DIM       = ";2"
	COLOR_STYLE_UNDERLINE = ";4"
	COLOR_STYLE_REV       = ";7"

	COLOR_FRONT_BLACK  = COLOR_PREFIX + ";30" + COLOR_SUFFIX
	COLOR_FRONT_RED    = COLOR_PREFIX + ";31" + COLOR_SUFFIX
	COLOR_FRONT_GREEN  = COLOR_PREFIX + ";32" + COLOR_SUFFIX
	COLOR_FRONT_YELLOW = COLOR_PREFIX + ";33" + COLOR_SUFFIX
	COLOR_FRONT_BLUE   = COLOR_PREFIX + ";34" + COLOR_SUFFIX
	COLOR_FRONT_PINK   = COLOR_PREFIX + ";35" + COLOR_SUFFIX
	COLOR_FRONT_CYAN   = COLOR_PREFIX + ";36" + COLOR_SUFFIX
	COLOR_FRONT_WHITE  = COLOR_PREFIX + ";37" + COLOR_SUFFIX

	//background color
	COLOR_BACK_BLACK  = COLOR_PREFIX + ";40" + COLOR_SUFFIX
	COLOR_BACK_RED    = COLOR_PREFIX + ";41" + COLOR_SUFFIX
	COLOR_BACK_GREEN  = COLOR_PREFIX + ";42" + COLOR_SUFFIX
	COLOR_BACK_YELLOW = COLOR_PREFIX + ";43" + COLOR_SUFFIX
	COLOR_BACK_BLUE   = COLOR_PREFIX + ";44" + COLOR_SUFFIX
	COLOR_BACK_PINK   = COLOR_PREFIX + ";45" + COLOR_SUFFIX
	COLOR_BACK_CYAN   = COLOR_PREFIX + ";46" + COLOR_SUFFIX
	COLOR_BACK_WHITE  = COLOR_PREFIX + ";47" + COLOR_SUFFIX

	//prefix
	COLOR_PREFIX = "\033["
	COLOR_SUFFIX = "m"

	//short struct
	COLOR_SHORT_RESET = COLOR_PREFIX + COLOR_STYLE_RESET + COLOR_SUFFIX
)
View Source
const (
	StepBp         = STEP_BP
	StepReduction1 = STEP_REDUCTION_1
	StepReduction2 = STEP_REDUCTION_2
	StepFinal      = STEP_FINAL
)
View Source
const (
	STEP_BP = iota + 0xffff
	STEP_REDUCTION_1
	STEP_REDUCTION_2
	STEP_FINAL
	STEP_IDLE
)

Variables

View Source
var (
	ErrBlockTime = errors.New("timestamp less than or equal parent's timestamp")
	ErrSignature = errors.New("signature is not right")
	ErrAposID    = errors.New("consensus Id is not apos")
	ErrAposData  = errors.New("apos consensus fail")
	ErrAposSign  = errors.New("apos consensus signature is not equal to header")
	ErrCertSteps = errors.New("apos consensus certificate step is not same")
	ErrCertPHash = errors.New("apos consensus certificate parent hash is not same")
	ErrCertStep  = errors.New("apos consensus certificate step is not bba step")
	ErrCertVotes = errors.New("apos consensus certificate votes is not enough")
)
View Source
var (
	ErrDuplicateMsg          = errors.New("recovery duplicate credential message")
	ErrDuplicatePropagateMsg = errors.New("recovery duplicate Propagate credential message")
)
View Source
var (
	ErrInvalidSig     = errors.New("invalid  v, r, s values")
	ErrInvalidChainId = errors.New("invalid chain id for signer")
)
View Source
var (
	ConsensusDataId = "apos"
)
View Source
var (
	TimeOut types.Hash = types.HexToHash("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
)

Functions

func CheckCertificate

func CheckCertificate(header *block.Header, data []byte) error

func Config

func Config() *config

get the msgcore singleton

func GetCredentialVotes

func GetCredentialVotes(cs *CredentialSign) float64

func MsgTransfer

func MsgTransfer() *msgTransfer

get the MsgTransfer singleton

func NewMsgBlockProposal

func NewMsgBlockProposal(bp *BlockProposal) *msgBlockProposal

new a message

func NewMsgByzantineAgreementStar

func NewMsgByzantineAgreementStar(ba *ByzantineAgreementStar) *msgByzantineAgreementStar

func NewMsgCredential

func NewMsgCredential(c *CredentialSign) *msgCredentialSig

Types

type Apos

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

func NewApos

func NewApos(bcHandler BlockChainHandler, producerHandler BlockProducerHandler, mux *event.TypeMux) *Apos

Create Apos

func (*Apos) InRecovering

func (this *Apos) InRecovering() bool

func (*Apos) SetCoinBase

func (this *Apos) SetCoinBase(coinBase types.Address)

func (*Apos) SetPriKey

func (this *Apos) SetPriKey(priKey *ecdsa.PrivateKey)

func (*Apos) Start

func (this *Apos) Start()

type BaEvent

type BaEvent struct{ Ba *ByzantineAgreementStar }

func (*BaEvent) DecodeMsg

func (z *BaEvent) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*BaEvent) EncodeMsg

func (z *BaEvent) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*BaEvent) MarshalMsg

func (z *BaEvent) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*BaEvent) Msgsize

func (z *BaEvent) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*BaEvent) UnmarshalMsg

func (z *BaEvent) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type BlockCertificate

type BlockCertificate []*CredentialSign

func (*BlockCertificate) DecodeMsg

func (z *BlockCertificate) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (BlockCertificate) EncodeMsg

func (z BlockCertificate) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (BlockCertificate) MarshalMsg

func (z BlockCertificate) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (BlockCertificate) Msgsize

func (z BlockCertificate) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*BlockCertificate) UnmarshalMsg

func (z *BlockCertificate) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type BlockChainHandler

type BlockChainHandler interface {
	CurrentBlock() *block.Block
	CurrentBlockNum() uint64
	GetNowBlockHash() types.Hash
	InsertChain(chain block.Blocks) (int, error)
	GetBlockByNumber(number uint64) *block.Block
	GetHeaderByNumber(number uint64) *block.Header
	StateAt(root types.Hash) (*state.StateDB, error)
	GetDb() database.IDatabase
	GetBlockByHash(hash types.Hash) *block.Block
	SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription
	GetConsensusData(key types.Hash) []byte
	WriteConsensusData(key types.Hash, value []byte) error
	GetExtra(key []byte) []byte
	VerifyNextRoundBlock(block *block.Block) bool
}

type BlockProducerHandler

type BlockProducerHandler interface {
	GetProducerNewBlock(data *block.ConsensusData, timeLimit int64) *block.Block
}

type BlockProposal

type BlockProposal struct {
	Block      *block.Block
	Esig       *EphemeralSign
	Credential *CredentialSign
}

step1 (Block Proposal) message m(r,1) = (Br, esig(H(Br)), σr1)

func (*BlockProposal) DecodeMsg

func (z *BlockProposal) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*BlockProposal) EncodeMsg

func (z *BlockProposal) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*BlockProposal) MarshalMsg

func (z *BlockProposal) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*BlockProposal) Msgsize

func (z *BlockProposal) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*BlockProposal) UnmarshalMsg

func (z *BlockProposal) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type BpEvent

type BpEvent struct{ Bp *BlockProposal }

func (*BpEvent) DecodeMsg

func (z *BpEvent) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*BpEvent) EncodeMsg

func (z *BpEvent) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*BpEvent) MarshalMsg

func (z *BpEvent) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*BpEvent) Msgsize

func (z *BpEvent) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*BpEvent) UnmarshalMsg

func (z *BpEvent) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type BpObj

type BpObj struct {
	BpHeap BpWithPriorityHeap
	// contains filtered or unexported fields
}

func (*BpObj) CommitteeVote

func (this *BpObj) CommitteeVote(data *VoteData)

type BpWithPriority

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

type BpWithPriorityHeap

type BpWithPriorityHeap []*BpWithPriority

func (BpWithPriorityHeap) Len

func (h BpWithPriorityHeap) Len() int

func (BpWithPriorityHeap) Less

func (h BpWithPriorityHeap) Less(i, j int) bool

func (*BpWithPriorityHeap) Pop

func (h *BpWithPriorityHeap) Pop() interface{}

func (*BpWithPriorityHeap) Push

func (h *BpWithPriorityHeap) Push(x interface{})

func (BpWithPriorityHeap) Swap

func (h BpWithPriorityHeap) Swap(i, j int)

type ByzantineAgreementStar

type ByzantineAgreementStar struct {
	Hash       types.Hash     //voted block's hash.
	Esig       *EphemeralSign //the signature of somebody's ephemeral secret key
	Credential *CredentialSign
}

func (*ByzantineAgreementStar) BaHash

func (ba *ByzantineAgreementStar) BaHash() types.Hash

func (*ByzantineAgreementStar) DecodeMsg

func (z *ByzantineAgreementStar) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*ByzantineAgreementStar) EncodeMsg

func (z *ByzantineAgreementStar) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*ByzantineAgreementStar) MarshalMsg

func (z *ByzantineAgreementStar) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*ByzantineAgreementStar) Msgsize

func (z *ByzantineAgreementStar) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*ByzantineAgreementStar) UnmarshalMsg

func (z *ByzantineAgreementStar) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type CommonCoinMinHash

type CommonCoinMinHash struct {
	H types.Hash
	J int
}

func (*CommonCoinMinHash) DecodeMsg

func (z *CommonCoinMinHash) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*CommonCoinMinHash) EncodeMsg

func (z *CommonCoinMinHash) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*CommonCoinMinHash) MarshalMsg

func (z *CommonCoinMinHash) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*CommonCoinMinHash) Msgsize

func (z *CommonCoinMinHash) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*CommonCoinMinHash) UnmarshalMsg

func (z *CommonCoinMinHash) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type CommonTools

type CommonTools interface {
	//Note: apos no right to hold a privateKey , so the Sig in commontools just though a privateKey to apos
	Sig(pCs *CredentialSign) error
	Esig(pEphemeralSign *EphemeralSign) error
	SigHash(hash types.Hash) []byte
	SeedSig(psd *SeedData) error

	ESigVerify(hash types.Hash, sig []byte) error
	ESender(hash types.Hash, sig []byte) (types.Address, error)

	GetLastQrSignature() []byte
	GetQrSignature(round uint64) []byte
	GetNowBlockNum() uint64
	GetNextRound() int
	GetNowBlockHash() types.Hash

	SetPriKey(priKey *ecdsa.PrivateKey)
	SetCoinBase(coinbase types.Address)
	GetCoinBase() types.Address

	CreateTmpPriKey(step int)
	DelTmpKey(step int)
	ClearTmpKeys()

	GetProducerNewBlock(data *block.ConsensusData, timeLimit int64) *block.Block //get a new block from block producer
	MakeEmptyBlock(data *block.ConsensusData) *block.Block
	InsertChain(chain block.Blocks) (int, error)
	GetCurrentBlock() *block.Block
	GetBlockByNum(num uint64) *block.Block
	VerifyNextRoundBlock(block *block.Block) bool

	//version 1.1
	GetBlockByHash(hash types.Hash) *block.Block
	SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription

	WriteBlockCertificate(blk *block.Block, certificate BlockCertificate) error
	GetBlockCertificate(blockHash types.Hash) BlockCertificate
	GetWeight(r uint64, addr types.Address) (int64, int64)
}

some out tools offered by Bchain,such as signer and blockInfo getter

type CredentialSigForHash

type CredentialSigForHash struct {
	Round    uint64 // round
	Step     uint64 // step
	Quantity []byte // quantity(seed, Qr-1)
}

func (*CredentialSigForHash) DecodeMsg

func (z *CredentialSigForHash) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*CredentialSigForHash) EncodeMsg

func (z *CredentialSigForHash) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*CredentialSigForHash) MarshalMsg

func (z *CredentialSigForHash) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*CredentialSigForHash) Msgsize

func (z *CredentialSigForHash) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*CredentialSigForHash) UnmarshalMsg

func (z *CredentialSigForHash) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type CredentialSign

type CredentialSign struct {
	Signature
	Round      uint64 // round
	Step       uint64 // step
	ParentHash types.Hash
	Time       *types.BigInt
	// contains filtered or unexported fields
}

long-term key singer

func (*CredentialSign) Cmp

func (a *CredentialSign) Cmp(b *CredentialSign) int

func (*CredentialSign) CsHash

func (cs *CredentialSign) CsHash() types.Hash

func (*CredentialSign) DecodeMsg

func (z *CredentialSign) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*CredentialSign) EncodeMsg

func (z *CredentialSign) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*CredentialSign) MarshalMsg

func (z *CredentialSign) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*CredentialSign) Msgsize

func (z *CredentialSign) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*CredentialSign) Sender

func (cret *CredentialSign) Sender() (types.Address, error)

func (*CredentialSign) UnmarshalMsg

func (z *CredentialSign) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type CsEvent

type CsEvent struct{ Cs *CredentialSign }

func (*CsEvent) DecodeMsg

func (z *CsEvent) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*CsEvent) EncodeMsg

func (z *CsEvent) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*CsEvent) MarshalMsg

func (z *CsEvent) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*CsEvent) Msgsize

func (z *CsEvent) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*CsEvent) UnmarshalMsg

func (z *CsEvent) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type EngineApos

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

func NewAposEngine

func NewAposEngine(prv *ecdsa.PrivateKey) *EngineApos

func (*EngineApos) Author

func (this *EngineApos) Author(chain consensus.ChainReader, header *block.Header) (types.Address, error)

func (*EngineApos) Finalize

func (this *EngineApos) Finalize(chain consensus.ChainReader, header *block.Header, state *state.StateDB, txs []*transaction.Transaction, receipts []*transaction.Receipt, sign bool) (*block.Block, error)

todo this need interpreter process interpreter need change state

func (*EngineApos) Incentive

func (this *EngineApos) Incentive(producer types.Address, state *state.StateDB, header *block.Header) (*transaction.Transaction, error)

func (*EngineApos) Prepare

func (this *EngineApos) Prepare(chain consensus.ChainReader, header *block.Header) error

func (*EngineApos) Seal

func (this *EngineApos) Seal(chain consensus.ChainReader, block *block.Block, stop <-chan struct{}) (*block.Block, error)

func (*EngineApos) SetKey

func (this *EngineApos) SetKey(prv *ecdsa.PrivateKey)

func (*EngineApos) VerifyHeader

func (this *EngineApos) VerifyHeader(chain consensus.ChainReader, header *block.Header, seal bool) error

func (*EngineApos) VerifyHeaders

func (this *EngineApos) VerifyHeaders(chain consensus.ChainReader, headers []*block.Header, seals []bool) (chan<- struct{}, <-chan error)

VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers concurrently. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications.

func (*EngineApos) VerifySeal

func (this *EngineApos) VerifySeal(chain consensus.ChainReader, header *block.Header) error

verify block certificate

type EphemeralSigForHash

type EphemeralSigForHash struct {
	Round uint64 // round
	Step  uint64 // step
	Val   []byte // Val = Hash(B), or Val = 0, or Val = 1
}

func (*EphemeralSigForHash) DecodeMsg

func (z *EphemeralSigForHash) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*EphemeralSigForHash) EncodeMsg

func (z *EphemeralSigForHash) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*EphemeralSigForHash) MarshalMsg

func (z *EphemeralSigForHash) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*EphemeralSigForHash) Msgsize

func (z *EphemeralSigForHash) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*EphemeralSigForHash) UnmarshalMsg

func (z *EphemeralSigForHash) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type EphemeralSign

type EphemeralSign struct {
	Signature
	// contains filtered or unexported fields
}

TODO: In current, EphemeralSig is the same as the Credential, need to be modified in the next version ephemeral key singer

func (*EphemeralSign) DecodeMsg

func (z *EphemeralSign) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*EphemeralSign) EncodeMsg

func (z *EphemeralSign) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*EphemeralSign) GetStep

func (esig *EphemeralSign) GetStep() uint64

func (*EphemeralSign) MarshalMsg

func (z *EphemeralSign) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*EphemeralSign) Msgsize

func (z *EphemeralSign) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*EphemeralSign) UnmarshalMsg

func (z *EphemeralSign) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type OutMsger

type OutMsger interface {
	GetDataMsg() <-chan dataPack
	SendInner(dataPack) error
	Send2Apos(dataPack)
	PropagateMsg(dataPack) error //just send propagate msg to other nodes
	// contains filtered or unexported methods
}

type PriKeyHandler

type PriKeyHandler interface {
	GetBasePriKey(kind reflect.Type) *ecdsa.PrivateKey
}

type QuantityEmpty

type QuantityEmpty struct {
	LstQuantity types.Hash
	Round       uint64
}

empty block Qr = H(Qr−1, r)

func (*QuantityEmpty) DecodeMsg

func (z *QuantityEmpty) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*QuantityEmpty) EncodeMsg

func (z *QuantityEmpty) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*QuantityEmpty) Hash

func (this *QuantityEmpty) Hash() types.Hash

func (*QuantityEmpty) MarshalMsg

func (z *QuantityEmpty) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*QuantityEmpty) Msgsize

func (z *QuantityEmpty) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*QuantityEmpty) UnmarshalMsg

func (z *QuantityEmpty) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Round

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

round context

type SeedData

type SeedData struct {
	Signature // SIGℓr (Qr−1) is the signature of leader bp
	Round     uint64
}

Qr = H(SIGℓr (Qr−1), r),

func (*SeedData) DecodeMsg

func (z *SeedData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*SeedData) EncodeMsg

func (z *SeedData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*SeedData) Hash

func (this *SeedData) Hash() types.Hash

use this , we get Qr-1

func (*SeedData) MarshalMsg

func (z *SeedData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*SeedData) Msgsize

func (z *SeedData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*SeedData) UnmarshalMsg

func (z *SeedData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type SeedDataSigForHash

type SeedDataSigForHash struct {
	Round uint64 // round
	Seed  []byte // quantity(seed, Qr-1)
}

ReadMe: what the relationship between SeedDataSigForHash and SeedData? if I say hash-SeedData is Qr-1 and hash-SeedDataSigForHash is Qr , it's not wrong. although hash-SeedDataSigForHash just a hash not equal Qr and Qr-1,but it's used for producing Qr. like this below: h := hash-SeedDataSigForHash SeedData.sign(h , privateKey),the sign will fill the R,S,V in SeedData and the consensusData.para = SeedData.toBytes(),the function toBytes() equal SeedData.Signature.toBytes(),it's meaning that the bytes equal R,S,V. But the consensusData not equal the Qr-1/r ,it's just a part of Qr-1/r

but now,how to get hash-SeedDataSigForHash? The defination of SeedDataSigForHash like below:

type SeedDataSigForHash struct {
	Round    uint64 // round
	Seed     []byte // quantity(seed, Qr-1)
}

here we know Round,but,what is Seed? 1.Seed-Round(Qr) is depend on Qr-1 2.Qr = H(Qr-1 , r)

so we know Seed is Qr-1(hash -> bytes) sigBytes(r-1) = block(r-1).consensusData.Para Signature(r-1) = Signature.get(sigBytes(r-1)) SeedData(Signature(r-1) , r-1).Hash()-->Qr-1

so ,here we know how to get Qr-1,now ,how to get Qr? First,it's a bad question,the result we get is not Qr,just a part of Qr--we called Signature's bytes. SeedDataSigForHash{Round:r , Seed:bytes(Qr-1)}-->hash,this hash just for sign,because we want get signature's bytes

h := hash-SeedDataSigForHash{Round:r , Seed:bytes(Qr-1)} SeedData{Signature:init() , r}.sign(h , privateKey),the r is useless in sign,but we fill Signature in this fucntion. so A PART OF Qr = SeedData{Signature:signed and filled , r}.toBytes().

Another tips: Seed is continuous , but Credential is not like: Seed0->Seed1->Seed2->Seed3->Seed4 C1(Seed0)->C2(Seed0)->C3(Seed0)->C4(Seed1)->C5(Seed1)->C6(Seed1)......

func (*SeedDataSigForHash) DecodeMsg

func (z *SeedDataSigForHash) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*SeedDataSigForHash) EncodeMsg

func (z *SeedDataSigForHash) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*SeedDataSigForHash) MarshalMsg

func (z *SeedDataSigForHash) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*SeedDataSigForHash) Msgsize

func (z *SeedDataSigForHash) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*SeedDataSigForHash) UnmarshalMsg

func (z *SeedDataSigForHash) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Signature

type Signature struct {
	R *types.BigInt
	S *types.BigInt
	V *types.BigInt
}

signature R, S, V

func MakeEmptySignature

func MakeEmptySignature() *Signature

func (*Signature) DecodeMsg

func (z *Signature) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Signature) EncodeMsg

func (z *Signature) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Signature) FillBySig

func (s *Signature) FillBySig(sig []byte) (R, S, V *big.Int, err error)

func (*Signature) Hash

func (s *Signature) Hash() types.Hash

func (*Signature) Init

func (s *Signature) Init()

func (*Signature) MarshalMsg

func (z *Signature) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Signature) Msgsize

func (z *Signature) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Signature) UnmarshalMsg

func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type SortitionPriority

type SortitionPriority interface {
	// contains filtered or unexported methods
}

type VoteData

type VoteData struct {
	Round uint64
	Step  uint64
	Value types.Hash
}

type VoteObj

type VoteObj struct {
	SendStatus map[uint64]*VoteData
	// contains filtered or unexported fields
}

func (*VoteObj) CommitteeVote

func (this *VoteObj) CommitteeVote(data *VoteData)

func (*VoteObj) SendVoteData

func (this *VoteObj) SendVoteData(r, s uint64, hash types.Hash)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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