Documentation ¶
Index ¶
- Constants
- Variables
- func ElGamalVerify(suite abstract.Suite, message []byte, publicKey abstract.Point, sig BasicSig) error
- func NewSigningMessage() interface{}
- type AddVote
- type AnnouncementMessage
- type BasicSig
- type ByVoteResponse
- type CatchUpRequest
- type CatchUpResponse
- type ChallengeMessage
- type CommitFunc
- type CommitmentMessage
- type Count
- type DoneFunc
- type ErrorMessage
- type GroupChangedMessage
- type MessageType
- type Node
- func (sn *Node) Accept(view int, chm *ChallengeMessage) error
- func (sn *Node) Accepted(view, Round int, sm *SigningMessage) error
- func (sn *Node) AddAction(view int, v *Vote)
- func (sn *Node) AddChildrenMerkleRoots(Round int)
- func (sn *Node) AddLocalMerkleRoot(view, Round int)
- func (sn *Node) AddPeer(conn string, PubKey abstract.Point)
- func (sn *Node) AddSelf(parent string) error
- func (sn *Node) AddVotes(Round int, v *Vote)
- func (sn *Node) Announce(view int, am *AnnouncementMessage) error
- func (sn *Node) ApplyAction(view int, v *Vote)
- func (sn *Node) ApplyVote(v *Vote)
- func (sn *Node) ApplyVotes(ch chan *Vote)
- func (sn *Node) CatchUp(vi int, from string)
- func (sn *Node) Challenge(view int, chm *ChallengeMessage) error
- func (sn *Node) ChangeView(vcv *ViewChangeVote)
- func (sn *Node) Close()
- func (sn *Node) CloseAll(view int) error
- func (sn *Node) Commit(view, Round int, sm *SigningMessage) error
- func (sn *Node) CommitedFor(round *Round) bool
- func (sn *Node) ComputeCombinedMerkleRoot(view, Round int)
- func (sn *Node) DefaultTimeout() time.Duration
- func (sn *Node) Done() chan int
- func (sn *Node) FillInWithDefaultMessages(view int, messgs []*SigningMessage) []*SigningMessage
- func (sn *Node) FinalizeCommits(view int, Round int) error
- func (sn *Node) GenSetPool()
- func (sn *Node) HashLog(Round int) error
- func (sn *Node) Hostlist() []string
- func (sn *Node) LastRound() int
- func (sn *Node) Listen() error
- func (sn *Node) NotifyOfAction(view int, v *Vote)
- func (sn *Node) Promise(view, Round int, sm *SigningMessage) error
- func (sn *Node) Propose(view int, am *AnnouncementMessage, from string) error
- func (sn *Node) PutUpError(view int, err error)
- func (sn *Node) ReceivedHeartbeat(view int)
- func (sn *Node) RegisterAnnounceFunc(cf CommitFunc)
- func (sn *Node) RegisterDoneFunc(df DoneFunc)
- func (sn *Node) RemoveSelf() error
- func (sn *Node) Respond(view, Round int, sm *SigningMessage) error
- func (sn *Node) RootFor(view int) string
- func (sn *Node) SendChildrenChallenges(view int, chm *ChallengeMessage) error
- func (sn *Node) SendChildrenChallengesProofs(view int, chm *ChallengeMessage) error
- func (sn *Node) SendLocalMerkleProof(view int, chm *ChallengeMessage) error
- func (sn *Node) SeparateProofs(proofs []proof.Proof, leaves []hashid.HashId, Round int)
- func (sn *Node) SetAccountableRound(Round int)
- func (sn *Node) SetBackLink(Round int)
- func (sn *Node) SetFailureRate(v int)
- func (sn *Node) SetLastSeenRound(round int)
- func (sn *Node) SetTimeout(t time.Duration)
- func (sn *Node) SetupProposal(view int, am *AnnouncementMessage, from string) error
- func (sn *Node) ShouldIFail(phase string) bool
- func (sn *Node) StartAnnouncement(am *AnnouncementMessage) error
- func (sn *Node) StartGossip()
- func (sn *Node) StartSigningRound() error
- func (sn *Node) StartVotingRound(v *Vote) error
- func (sn *Node) StatusConnections(view int, am *AnnouncementMessage) error
- func (sn *Node) StopHeartbeat()
- func (sn *Node) Suite() abstract.Suite
- func (sn *Node) TimeForViewChange() bool
- func (sn *Node) Timeout() time.Duration
- func (sn *Node) TryFailure(view, Round int) error
- func (sn *Node) TryRootFailure(view, Round int) bool
- func (sn *Node) TryViewChange(view int) error
- func (sn *Node) UpdateTimeout(t ...time.Duration)
- func (sn *Node) VerifyAllProofs(view int, chm *ChallengeMessage, proofForClient proof.Proof)
- func (sn *Node) VerifyResponses(view, Round int) error
- func (sn *Node) ViewChangeCh() chan string
- type RemoveVote
- type ResponseMessage
- type Round
- type RoundType
- type SNLog
- type Signer
- type SigningMessage
- type Type
- type ViewChangeVote
- type Vote
- type VoteLog
- type VoteRequestMessage
- type VoteResponse
- type VoteType
Constants ¶
const ( // Default Signature involves creating Merkle Trees MerkleTree = iota // Basic Signature removes all Merkle Trees // Collective public keys are still created and can be used PubKey // Basic Signature on aggregated votes Voter )
const FIRST_ROUND int = 1 // start counting rounds at 1
Variables ¶
var ChangingViewError error = errors.New("In the process of changing view")
var DEBUG bool // to avoid verifying paths and signatures all the time
var ErrImposedFailure error = errors.New("failure imposed")
var ErrPastRound error = errors.New("round number already passed")
var ErrUnknownMessageType error = errors.New("received message of unknown type")
var ErrViewRejected error = errors.New("view Rejected: not all nodes accepted view")
var GOSSIP_TIME time.Duration = 3 * ROUND_TIME
var HEARTBEAT = ROUND_TIME + ROUND_TIME/2
var MAX_WILLING_TO_WAIT time.Duration = 50 * time.Second
var ROUND_TIME time.Duration = 1 * time.Second
Constants we expect might be used by other packages TODO: can this be replaced by the application using the signer?
Functions ¶
func ElGamalVerify ¶
func NewSigningMessage ¶
func NewSigningMessage() interface{}
Types ¶
type AnnouncementMessage ¶
type AnnouncementMessage struct { LogTest []byte // TODO: change LogTest to Messg Round int // VoteRequest *VoteRequest Vote *Vote // Vote Request (propose) }
Broadcasted message initiated and signed by proposer
type ByVoteResponse ¶
type ByVoteResponse []*VoteResponse
for sorting arrays of VoteResponse
func (ByVoteResponse) Len ¶
func (vr ByVoteResponse) Len() int
func (ByVoteResponse) Less ¶
func (vr ByVoteResponse) Less(i, j int) bool
func (ByVoteResponse) Swap ¶
func (vr ByVoteResponse) Swap(i, j int)
type CatchUpRequest ¶
type CatchUpRequest struct {
Index int // index of requested vote
}
type CatchUpResponse ¶
type CatchUpResponse struct {
Vote *Vote
}
type ChallengeMessage ¶
type ChallengeMessage struct { C abstract.Secret // challenge // Depth byte MTRoot hashid.HashId // the very root of the big Merkle Tree Proof proof.Proof // Merkle Path of Proofs from root to us // CountedVotes *CountedVotes // CountedVotes contains the whole tree's votes Vote *Vote // Vote Confirmerd/ Rejected (accept) Round int }
type CommitmentMessage ¶
type CommitmentMessage struct { V abstract.Point // commitment Point V_hat abstract.Point // product of subtree participating nodes' commitment points X_hat abstract.Point // product of subtree participating nodes' public keys MTRoot hashid.HashId // root of Merkle (sub)Tree // public keys of children servers that did not respond to // annoucement from root ExceptionList []abstract.Point // CountedVotes *CountedVotes // CountedVotes contains a subtree's votes Vote *Vote // Vote Response (promise) Round int }
type Count ¶
type Count struct { Responses []*VoteResponse // vote responses from descendants For int // number of votes for Against int // number of votes against }
When sent up in a Committment Message CountedVotes contains a subtree's votes When sent down in a Challenge Message CountedVotes contains the whole tree's votes
type DoneFunc ¶
Called at the end of a round Allows client of Signer to receive signature, proof, and error via RPC
type ErrorMessage ¶
type ErrorMessage struct {
Err string
}
type GroupChangedMessage ¶
type MessageType ¶
type MessageType int
const ( Unset MessageType = iota Announcement Commitment Challenge Response CatchUpReq CatchUpResp GroupChange GroupChanged StatusConnections CloseAll Default // for internal use Error )
func (MessageType) String ¶
func (m MessageType) String() string
type Node ¶
type Node struct { coconet.Host // Signing Node will Fail at FailureRate probability FailureRate int FailAsRootEvery int FailAsFollowerEvery int Rand *rand.Rand Type Type Height int HostList []string PubKey abstract.Point // long lasting public key PrivKey abstract.Secret // long lasting private key Rounds map[int]*Round Round int // *only* used by Root( by annoucer) RoundTypes []RoundType LastSeenRound int // largest round number I have seen RoundsAsRoot int // latest continuous streak of rounds with sn root AnnounceLock sync.Mutex CommitFunc CommitFunc DoneFunc DoneFunc LogTest []byte // for testing purposes RoundsPerView int ChangingView bool // TRUE if node is currently engaged in changing the view ViewNo int VoteLog *VoteLog // log of all confirmed votes, useful for replay LastSeenVote int64 // max of all Highest Votes we've seen, and our last commited vote LastAppliedVote int64 // last vote we have committed to our log Actions map[int][]*Vote // contains filtered or unexported fields }
func NewKeyedNode ¶
Create new signing node that incorporates a given private key
func (*Node) AddChildrenMerkleRoots ¶
func (*Node) AddLocalMerkleRoot ¶
func (*Node) ApplyAction ¶
func (*Node) ApplyVotes ¶
func (*Node) Challenge ¶
func (sn *Node) Challenge(view int, chm *ChallengeMessage) error
initiated by root, propagated by all others
func (*Node) ChangeView ¶
func (sn *Node) ChangeView(vcv *ViewChangeVote)
func (*Node) CommitedFor ¶
func (*Node) ComputeCombinedMerkleRoot ¶
func (*Node) DefaultTimeout ¶
func (*Node) FillInWithDefaultMessages ¶
func (sn *Node) FillInWithDefaultMessages(view int, messgs []*SigningMessage) []*SigningMessage
Figure out which kids did not submit messages Add default messages to messgs, one per missing child as to make it easier to identify and add them to exception lists in one place
func (*Node) FinalizeCommits ¶
Called *only* by root node after receiving all commits
func (*Node) GenSetPool ¶
func (sn *Node) GenSetPool()
func (*Node) NotifyOfAction ¶
func (*Node) Propose ¶
func (sn *Node) Propose(view int, am *AnnouncementMessage, from string) error
A propose for a view change would come on current view + sth when we receive view change message on a future view, we must be caught up, create that view and apply actions on it
func (*Node) PutUpError ¶
func (*Node) ReceivedHeartbeat ¶
func (*Node) RegisterAnnounceFunc ¶
func (sn *Node) RegisterAnnounceFunc(cf CommitFunc)
func (*Node) RegisterDoneFunc ¶
func (*Node) RemoveSelf ¶
func (*Node) RootFor ¶
Returns name of node who should be the root for the next view round robin is used on the array of host names to determine the next root
func (*Node) SendChildrenChallenges ¶
func (sn *Node) SendChildrenChallenges(view int, chm *ChallengeMessage) error
Send children challenges
func (*Node) SendChildrenChallengesProofs ¶
func (sn *Node) SendChildrenChallengesProofs(view int, chm *ChallengeMessage) error
Create Personalized Merkle Proofs for children servers Send Personalized Merkle Proofs to children servers
func (*Node) SendLocalMerkleProof ¶
func (sn *Node) SendLocalMerkleProof(view int, chm *ChallengeMessage) error
Create Merkle Proof for local client (timestamp server) Send Merkle Proof to local client (timestamp server)
func (*Node) SeparateProofs ¶
Identify which proof corresponds to which leaf Needed given that the leaves are sorted before passed to the function that create the Merkle Tree and its Proofs
func (*Node) SetAccountableRound ¶
*only* called by root node
func (*Node) SetBackLink ¶
func (*Node) SetFailureRate ¶
func (*Node) SetLastSeenRound ¶
func (*Node) SetTimeout ¶
func (*Node) SetupProposal ¶
func (sn *Node) SetupProposal(view int, am *AnnouncementMessage, from string) error
func (*Node) ShouldIFail ¶
func (*Node) StartAnnouncement ¶
func (sn *Node) StartAnnouncement(am *AnnouncementMessage) error
func (*Node) StartGossip ¶
func (sn *Node) StartGossip()
func (*Node) StartSigningRound ¶
func (*Node) StartVotingRound ¶
func (*Node) StatusConnections ¶
func (sn *Node) StatusConnections(view int, am *AnnouncementMessage) error
func (*Node) StopHeartbeat ¶
func (sn *Node) StopHeartbeat()
func (*Node) TimeForViewChange ¶
func (*Node) TryFailure ¶
func (*Node) TryRootFailure ¶
func (*Node) TryViewChange ¶
func (*Node) UpdateTimeout ¶
func (*Node) VerifyAllProofs ¶
func (sn *Node) VerifyAllProofs(view int, chm *ChallengeMessage, proofForClient proof.Proof)
func (*Node) VerifyResponses ¶
Called by every node after receiving aggregate responses from descendants
func (*Node) ViewChangeCh ¶
type RemoveVote ¶
type ResponseMessage ¶
type ResponseMessage struct { R_hat abstract.Secret // response // public keys of children servers that did not respond to // challenge from root ExceptionList []abstract.Point // cummulative point commits of nodes that failed after commit ExceptionV_hat abstract.Point // cummulative public keys of nodes that failed after commit ExceptionX_hat abstract.Point Vote *Vote // Vote Ack/Nack in thr log (ack/nack) Round int }
type Round ¶
type Round struct { Log SNLog // round lasting log structure HashedLog []byte X_hat abstract.Point // aggregate of public keys Commits []*SigningMessage Responses []*SigningMessage // own big merkle subtree MTRoot hashid.HashId // mt root for subtree, passed upwards Leaves []hashid.HashId // leaves used to build the merkle subtre LeavesFrom []string // child names for leaves // mtRoot before adding HashedLog LocalMTRoot hashid.HashId // merkle tree roots of children in strict order CMTRoots []hashid.HashId CMTRootNames []string Proofs map[string]proof.Proof // round-lasting public keys of children servers that did not // respond to latest commit or respond phase, in subtree ExceptionList []abstract.Point // combined point commits of children servers in subtree ChildV_hat map[string]abstract.Point // combined public keys of children servers in subtree ChildX_hat map[string]abstract.Point BackLink hashid.HashId AccRound []byte Vote *Vote // contains filtered or unexported fields }
type SNLog ¶
type SNLog struct { V abstract.Point // round lasting commitment point V_hat abstract.Point // aggregate of commit points // merkle tree roots of children in strict order CMTRoots hashid.HashId // concatenated hash ids of children Suite abstract.Suite // contains filtered or unexported fields }
Signing Node Log for a round For Marshaling and Unrmarshaling to work smoothly crypto fields must appear first in the structure
func (SNLog) MarshalBinary ¶
func (*SNLog) UnmarshalBinary ¶
type Signer ¶
type Signer interface { Name() string IsRoot(view int) bool Suite() abstract.Suite StartSigningRound() error StartVotingRound(v *Vote) error LastRound() int // last round number seen by Signer SetLastSeenRound(int) // impose change in round numbering Hostlist() []string // registers a commitment function to be called // at the start of every round RegisterAnnounceFunc(cf CommitFunc) RegisterDoneFunc(df DoneFunc) // Allows user of Signer to inform Signer to run with simulated failures // As to test robustness of Signer SetFailureRate(val int) ViewChangeCh() chan string Close() Listen() error AddSelf(host string) error RemoveSelf() error }
todo: see where Signer should be located
type SigningMessage ¶
type SigningMessage struct { Type MessageType Am *AnnouncementMessage Com *CommitmentMessage Chm *ChallengeMessage Rm *ResponseMessage Cureq *CatchUpRequest Curesp *CatchUpResponse Vrm *VoteRequestMessage Gcm *GroupChangedMessage Err *ErrorMessage From string View int LastSeenVote int // highest vote ever seen and commited in log, used for catch-up }
Signing Messages are used for all communications between servers It is important for encoding/ decoding for type to be kept as first field
func (*SigningMessage) MarshalBinary ¶
func (sm *SigningMessage) MarshalBinary() ([]byte, error)
func (*SigningMessage) UnmarshalBinary ¶
func (sm *SigningMessage) UnmarshalBinary(data []byte) error
type ViewChangeVote ¶
type Vote ¶
type Vote struct { Index int View int Round int Type VoteType Av *AddVote Rv *RemoveVote Vcv *ViewChangeVote Count *Count Confirmed bool }
Multi-Purpose Vote embeds Action to be voted on, aggregated votes, and decison when embedded in Announce it equals Vote Request (propose) when embedded in Commit it equals Vote Response (promise) when embedded in Challenge it equals Vote Confirmed (accept) when embedded in Response it equals Vote Ack/ Nack (ack/ nack)
func (*Vote) MarshalBinary ¶
func (*Vote) UnmarshalBinary ¶
type VoteLog ¶
type VoteLog struct { Entries []*Vote Last int // last set entry // contains filtered or unexported fields }
func NewVoteLog ¶
func NewVoteLog() *VoteLog
type VoteRequestMessage ¶
type VoteRequestMessage struct {
Vote *Vote
}