Documentation
      ¶
    
    
  
    
  
    Index ¶
- Variables
 - type Abort
 - type BroadcastContent
 - type BroadcastRound
 - type Content
 - type Helper
 - func (h *Helper) AbortRound(err error, culprits ...party.ID) Session
 - func (h *Helper) BroadcastMessage(out chan<- *Message, broadcastContent Content) error
 - func (h *Helper) FinalRoundNumber() Number
 - func (h *Helper) Group() curve.Curve
 - func (h *Helper) Hash() *hash.Hash
 - func (h *Helper) HashForID(id party.ID) *hash.Hash
 - func (h *Helper) N() int
 - func (h *Helper) OtherPartyIDs() party.IDSlice
 - func (h *Helper) PartyIDs() party.IDSlice
 - func (h *Helper) ProtocolID() string
 - func (h *Helper) ResultRound(result interface{}) Session
 - func (h *Helper) SSID() []byte
 - func (h *Helper) SelfID() party.ID
 - func (h *Helper) SendMessage(out chan<- *Message, content Content, to party.ID) error
 - func (h *Helper) Threshold() int
 - func (h *Helper) UpdateHashState(value hash.WriterToWithDomain)
 
- type Info
 - type Message
 - type NormalBroadcastContent
 - type Number
 - type Output
 - type ReliableBroadcastContent
 - type Round
 - type Session
 
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Abort ¶
Abort is an empty round containing a list of parties who misbehaved.
func (Abort) MessageContent ¶
func (Abort) StoreMessage ¶
func (Abort) VerifyMessage ¶
type BroadcastContent ¶
BroadcastContent wraps a Content, but also indicates whether this content requires reliable broadcast.
type BroadcastRound ¶
type BroadcastRound interface {
	// StoreBroadcastMessage must be run before Round.VerifyMessage and Round.StoreMessage,
	// since those may depend on the content from the broadcast.
	// It changes the round's state to store the message after performing basic validation.
	StoreBroadcastMessage(msg Message) error
	// BroadcastContent returns an uninitialized message.Content for this round's broadcast message.
	//
	// The first round of a protocol, and rounds which do not expect a broadcast message should return nil.
	BroadcastContent() BroadcastContent
	// Round must be implemented by an inherited round which would otherwise function the same way.
	Round
}
    BroadcastRound extends Round in that it expects a broadcast message before the p2p message. Due to the way Go struct inheritance works, it is necessary to implement both methods in a separate struct which itself only inherits the base Round. This way, we do not inherit the broadcast methods, and we can identify a broadcast round by type assertion.
type Content ¶
type Content interface {
	RoundNumber() Number
}
    Content represents the message, either broadcast or P2P returned by a round during finalization.
type Helper ¶
type Helper struct {
	// Pool allows us to parallelize certain operations
	Pool *pool.Pool
	// contains filtered or unexported fields
}
    Helper implements Session without Round, and can therefore be embedded in the first round of a protocol in order to satisfy the Session interface.
func NewSession ¶
func NewSession(info Info, sessionID []byte, pl *pool.Pool, auxInfo ...hash.WriterToWithDomain) (*Helper, error)
NewSession creates a new *Helper which can be embedded in the first Round, so that the full struct implements Session. `sessionID` is an optional byte slice that can be provided by the user. When used, it should be unique for each execution of the protocol. It could be a simple counter which is incremented after execution, or a common random string. `auxInfo` is a variable list of objects which should be included in the session's hash state.
func (*Helper) AbortRound ¶
AbortRound returns a round that contains only the culprits that were able to be identified during a faulty execution of the protocol. The error returned by Round.Finalize() in this case should still be nil.
func (*Helper) BroadcastMessage ¶
BroadcastMessage constructs a Message from the broadcast Content, and sets the header correctly. An error is returned if the message cannot be sent to the out channel.
func (*Helper) FinalRoundNumber ¶
FinalRoundNumber is the number of rounds before the output round.
func (*Helper) HashForID ¶
HashForID returns a clone of the hash.Hash for this session, initialized with the given id.
func (*Helper) OtherPartyIDs ¶
OtherPartyIDs returns a sorted list of parties that does not contain SelfID.
func (*Helper) ProtocolID ¶
ProtocolID is an identifier for this protocol.
func (*Helper) ResultRound ¶
ResultRound returns a round that contains only the result of the protocol. This indicates to the used that the protocol is finished.
func (*Helper) SendMessage ¶
SendMessage is a convenience method for safely sending content to some party. If the message is intended for all participants (but does not require reliable broadcast), the `to` field may be empty (""). Returns an error if the message failed to send over out channel. `out` is expected to be a buffered channel with enough capacity to store all messages.
func (*Helper) Threshold ¶
Threshold is the maximum number of parties that are assumed to be corrupted during the execution of this protocol.
func (*Helper) UpdateHashState ¶
func (h *Helper) UpdateHashState(value hash.WriterToWithDomain)
UpdateHashState writes additional data to the hash state.
type Info ¶
type Info struct {
	// ProtocolID is an identifier for this protocol
	ProtocolID string
	// FinalRoundNumber is the number of rounds before the output round.
	FinalRoundNumber Number
	// SelfID is this party's ID.
	SelfID party.ID
	// PartyIDs is a sorted slice of participating parties in this protocol.
	PartyIDs []party.ID
	// Threshold is the maximum number of parties that are assumed to be corrupted during the execution of this protocol.
	Threshold int
	// Group returns the group used for this protocol execution.
	Group curve.Curve
}
    type NormalBroadcastContent ¶
type NormalBroadcastContent struct{}
    These structs can be embedded in a broadcast message as a way of 1. implementing BroadcastContent 2. indicate to the handler whether the content should be reliably broadcast When non-unanimous halting is acceptable, we can use the echo broadcast.
func (NormalBroadcastContent) Reliable ¶
func (NormalBroadcastContent) Reliable() bool
type Number ¶
type Number uint16
Number is the index of the current round. 0 indicates the output round, 1 is the first round.
type Output ¶
type Output struct {
	*Helper
	Result interface{}
}
    Output is an empty round containing the output of the protocol.
func (Output) MessageContent ¶
func (Output) StoreMessage ¶
func (Output) VerifyMessage ¶
type ReliableBroadcastContent ¶
type ReliableBroadcastContent struct{}
    These structs can be embedded in a broadcast message as a way of 1. implementing BroadcastContent 2. indicate to the handler whether the content should be reliably broadcast When non-unanimous halting is acceptable, we can use the echo broadcast.
func (ReliableBroadcastContent) Reliable ¶
func (ReliableBroadcastContent) Reliable() bool
type Round ¶
type Round interface {
	// VerifyMessage handles an incoming Message and validates its content with regard to the protocol specification.
	// The content argument can be cast to the appropriate type for this round without error check.
	// In the first round, this function returns nil.
	// This function should not modify any saved state as it may be be running concurrently.
	VerifyMessage(msg Message) error
	// StoreMessage should be called after VerifyMessage and should only store the appropriate fields from the
	// content.
	StoreMessage(msg Message) error
	// Finalize is called after all messages from the parties have been processed in the current round.
	// Messages for the next round are sent out through the out channel.
	// If a non-critical error occurs (like a failure to sample, hash, or send a message), the current round can be
	// returned so that the caller may try to finalize again.
	//
	// If an abort occurs, the expected behavior is to return
	//   r.AbortRound(err, culprits), nil.
	// This indicates to the caller that the protocol has aborted due to a "math" error.
	//
	// In the last round, Finalize should return
	//   r.ResultRound(result), nil
	// where result is the output of the protocol.
	Finalize(out chan<- *Message) (Session, error)
	// MessageContent returns an uninitialized message.Content for this round.
	//
	// The first round of a protocol should return nil.
	MessageContent() Content
	// Number returns the current round number.
	Number() Number
}
    type Session ¶
type Session interface {
	// Round is the current round being executed.
	Round
	// Group returns the group used for this protocol execution.
	Group() curve.Curve
	// Hash returns a cloned hash function with the current hash state.
	Hash() *hash.Hash
	// ProtocolID is an identifier for this protocol.
	ProtocolID() string
	// FinalRoundNumber is the number of rounds before the output round.
	FinalRoundNumber() Number
	// SSID the unique identifier for this protocol execution.
	SSID() []byte
	// SelfID is this party's ID.
	SelfID() party.ID
	// PartyIDs is a sorted slice of participating parties in this protocol.
	PartyIDs() party.IDSlice
	// OtherPartyIDs returns a sorted list of parties that does not contain SelfID.
	OtherPartyIDs() party.IDSlice
	// Threshold is the maximum number of parties that are assumed to be corrupted during the execution of this protocol.
	Threshold() int
	// N returns the total number of parties participating in the protocol.
	N() int
}
    Session represents the current execution of a round-based protocol. It embeds the current round, and provides additional