// NewBFTCoSiProtocol returns a new bftcosi struct func NewBFTCoSiProtocol(n *sda.TreeNodeInstance, verify VerificationFunction) (*ProtocolBFTCoSi, error) { // initialize the bftcosi node/protocol-instance bft := &ProtocolBFTCoSi{ TreeNodeInstance: n, suite: n.Suite(), prepare: cosi.NewCosi(n.Suite(), n.Private()), commit: cosi.NewCosi(n.Suite(), n.Private()), verifyChan: make(chan bool), doneProcessing: make(chan bool, 2), doneSigning: make(chan bool, 1), verificationFun: verify, AggregatedPublic: n.Roster().Aggregate, threshold: int(2.0 * math.Ceil(float64(len(n.Tree().List()))/3.0)), } // register channels if err := n.RegisterChannel(&bft.announceChan); err != nil { return nil, err } if err := n.RegisterChannel(&bft.commitChan); err != nil { return nil, err } if err := n.RegisterChannel(&bft.challengePrepareChan); err != nil { return nil, err } if err := n.RegisterChannel(&bft.challengeCommitChan); err != nil { return nil, err } if err := n.RegisterChannel(&bft.responseChan); err != nil { return nil, err } n.OnDoneCallback(bft.nodeDone) return bft, nil }