bftcosi

package
v0.0.0-...-6588121 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2018 License: GPL-3.0, LGPL-3.0, AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Announce

type Announce struct {
	TYPE    RoundType
	Timeout time.Duration
}

Announce is the struct used during the announcement phase (of both rounds)

type BFTSignature

type BFTSignature struct {
	// cosi signature
	Sig []byte
	Msg []byte
	// List of peers that did not want to sign.
	Exceptions []Exception
}

BFTSignature is what a bftcosi protocol outputs. It contains the signature, the message and some possible exceptions.

func (*BFTSignature) Verify

func (bs *BFTSignature) Verify(s network.Suite, publics []kyber.Point) error

Verify returns whether the verification of the signature succeeds or not. Specifically, it adjusts the signature according to the exception in the signature, so it can be verified by dedis/crypto/cosi. publics is a slice of all public signatures, and the msg is the msg being signed.

type ChallengeCommit

type ChallengeCommit struct {
	// Challenge for the current round
	Challenge kyber.Scalar
	// Signature is the signature response generated at the previous round (prepare)
	Signature *BFTSignature
}

ChallengeCommit is the challenge used by BftCoSi during the "commit" phase. It contains the basic challenge (out of the block we want to sign) + the signature of the "prepare" round. It also contains the exception list coming from the "prepare" phase. This exception list has been collected by the root during the response of the "prepare" phase and broadcast it through the challenge of the "commit". These are needed in order to verify the signature and to see how many peers did not sign. It's not spoofable because otherwise the signature verification will be wrong.

type ChallengePrepare

type ChallengePrepare struct {
	Msg       []byte
	Data      []byte
	Challenge kyber.Scalar
}

ChallengePrepare is the challenge used by ByzCoin during the "prepare" phase. It contains the basic challenge plus the message from which the challenge has been generated.

type Commitment

type Commitment struct {
	TYPE       RoundType
	Commitment kyber.Point
}

Commitment is the commitment packets that is sent for both rounds

type CreateProtocolFunction

type CreateProtocolFunction func(name string, t *onet.Tree) (onet.ProtocolInstance, error)

CreateProtocolFunction is a function type which creates a new protocol used in FtCosi protocol for creating sub leader protocols.

type Exception

type Exception struct {
	Index      int
	Commitment kyber.Point
}

Exception represents the exception mechanism used in BFTCosi to indicate a signer did not want to sign. The index is the index of the public key of the cosigner that do not want to sign. The commit is needed in order to be able to correctly verify the signature

type ProtocolBFTCoSi

type ProtocolBFTCoSi struct {
	// the node we are represented-in
	*onet.TreeNodeInstance

	// The message that will be signed by the BFTCosi
	Msg []byte
	// Data going along the msg to the verification
	Data []byte
	// Timeout is how long to wait while gathering commits.
	Timeout time.Duration

	// VerificationFunction will be called
	// during the (start/handle) challenge prepare phase of the protocol
	VerificationFunction VerificationFunction
	// contains filtered or unexported fields
}

ProtocolBFTCoSi is the main struct for running the protocol

func NewBFTCoSiProtocol

func NewBFTCoSiProtocol(n *onet.TreeNodeInstance, verify VerificationFunction) (*ProtocolBFTCoSi, error)

NewBFTCoSiProtocol returns a new bftcosi struct

func (*ProtocolBFTCoSi) Dispatch

func (bft *ProtocolBFTCoSi) Dispatch() error

Dispatch makes sure that the order of the messages is correct by waiting on each channel in the correct order. By closing the channels for the leafs we can avoid having `if !bft.IsLeaf` in the code.

func (*ProtocolBFTCoSi) RegisterOnDone

func (bft *ProtocolBFTCoSi) RegisterOnDone(fn func())

RegisterOnDone registers a callback to call when the bftcosi protocols has really finished

func (*ProtocolBFTCoSi) RegisterOnSignatureDone

func (bft *ProtocolBFTCoSi) RegisterOnSignatureDone(fn func(*BFTSignature))

RegisterOnSignatureDone register a callback to call when the bftcosi protocol reached a signature on the block

func (*ProtocolBFTCoSi) Shutdown

func (bft *ProtocolBFTCoSi) Shutdown() error

Shutdown closes all channels in case we're done

func (*ProtocolBFTCoSi) Signature

func (bft *ProtocolBFTCoSi) Signature() *BFTSignature

Signature will generate the final signature, the output of the BFTCoSi protocol. The signature contains the commit round signature, with the message. If the prepare phase failed, the signature will be nil and the Exceptions will contain the exception from the prepare phase. It can be useful to see which cosigners refused to sign (each exceptions contains the index of a refusing-to-sign signer). Expect this function to have an undefined behavior when called from a non-root Node.

func (*ProtocolBFTCoSi) Start

func (bft *ProtocolBFTCoSi) Start() error

Start will start both rounds "prepare" and "commit" at same time. The "commit" round will wait till the end of the "prepare" round during its challenge phase.

type Response

type Response struct {
	Response   kyber.Scalar
	Exceptions []Exception
	TYPE       RoundType
}

Response is the struct used by ByzCoin during the response. It contains the response + the basic exception list.

type RoundType

type RoundType int32

RoundType is a type to know if we are in the "prepare" round or the "commit" round

const (
	// RoundPrepare is the first round (prepare)
	RoundPrepare RoundType = iota
	// RoundCommit is the final round (Commit)
	RoundCommit
)

type VerificationFunction

type VerificationFunction func(Msg []byte, Data []byte) bool

VerificationFunction can be passes to each protocol node. It will be called (in a go routine) during the (start/handle) challenge prepare phase of the protocol. The passed message is the same as sent in the challenge phase. The `Data`-part is only to help the VerificationFunction do it's job. In the case of the services, this part should be replaced by the correct passing of the service-configuration-data, which is not done yet.

Jump to

Keyboard shortcuts

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