本文整理汇总了Golang中github.com/dedis/cothority/sda.TreeNodeInstance.Suite方法的典型用法代码示例。如果您正苦于以下问题:Golang TreeNodeInstance.Suite方法的具体用法?Golang TreeNodeInstance.Suite怎么用?Golang TreeNodeInstance.Suite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/dedis/cothority/sda.TreeNodeInstance
的用法示例。
在下文中一共展示了TreeNodeInstance.Suite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewJVSS
// NewJVSS creates a new JVSS protocol instance and returns it.
func NewJVSS(node *sda.TreeNodeInstance) (sda.ProtocolInstance, error) {
kp := &config.KeyPair{Suite: node.Suite(), Public: node.Public(), Secret: node.Private()}
n := len(node.List())
pk := make([]abstract.Point, n)
for i, tn := range node.List() {
pk[i] = tn.ServerIdentity.Public
}
// NOTE: T <= R <= N (for simplicity we use T = R = N; might change later)
info := poly.Threshold{T: n, R: n, N: n}
jv := &JVSS{
TreeNodeInstance: node,
keyPair: kp,
pubKeys: pk,
info: info,
schnorr: new(poly.Schnorr),
secrets: make(map[SID]*Secret),
ltssInit: false,
secretsDone: make(chan bool, 1),
sigChan: make(chan *poly.SchnorrSig),
}
// Setup message handlers
h := []interface{}{
jv.handleSecInit,
jv.handleSecConf,
jv.handleSigReq,
jv.handleSigResp,
}
err := jv.RegisterHandlers(h...)
return jv, err
}
示例2: NewBFTCoSiProtocol
// 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
}