本文整理汇总了Golang中github.com/dedis/onet.TreeNodeInstance类的典型用法代码示例。如果您正苦于以下问题:Golang TreeNodeInstance类的具体用法?Golang TreeNodeInstance怎么用?Golang TreeNodeInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TreeNodeInstance类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NewNtreeProtocol
// NewNtreeProtocol returns the NtreeProtocol initialized
func NewNtreeProtocol(node *onet.TreeNodeInstance) (*Ntree, error) {
nt := &Ntree{
TreeNodeInstance: node,
verifyBlockChan: make(chan bool),
verifySignatureRequestChan: make(chan bool),
tempBlockSig: new(NaiveBlockSignature),
tempSignatureResponse: &RoundSignatureResponse{new(NaiveBlockSignature)},
}
if err := node.RegisterChannel(&nt.announceChan); err != nil {
return nt, err
}
if err := node.RegisterChannel(&nt.blockSignatureChan); err != nil {
return nt, err
}
if err := node.RegisterChannel(&nt.roundSignatureRequestChan); err != nil {
return nt, err
}
if err := node.RegisterChannel(&nt.roundSignatureResponseChan); err != nil {
return nt, err
}
go nt.listen()
return nt, nil
}
开发者ID:dedis,项目名称:cothority,代码行数:26,代码来源:ntree.go
示例2: NewBroadcastProtocol
// NewBroadcastProtocol returns a new Broadcast protocol
func NewBroadcastProtocol(n *onet.TreeNodeInstance) (onet.ProtocolInstance, error) {
b := &Broadcast{
TreeNodeInstance: n,
tnIndex: -1,
}
for i, tn := range n.Tree().List() {
if tn.ID == n.TreeNode().ID {
b.tnIndex = i
}
}
if b.tnIndex == -1 {
return nil, errors.New("Didn't find my TreeNode in the Tree")
}
err := n.RegisterHandler(b.handleContactNodes)
if err != nil {
return nil, err
}
err = n.RegisterHandler(b.handleDone)
if err != nil {
return nil, err
}
return b, nil
}
开发者ID:dedis,项目名称:cothority,代码行数:24,代码来源:broadcast.go
示例3: NewBFTCoSiProtocol
// NewBFTCoSiProtocol returns a new bftcosi struct
func NewBFTCoSiProtocol(n *onet.TreeNodeInstance, verify VerificationFunction) (*ProtocolBFTCoSi, error) {
// initialize the bftcosi node/protocol-instance
bft := &ProtocolBFTCoSi{
TreeNodeInstance: n,
collectStructs: collectStructs{
prepare: cosi.NewCosi(n.Suite(), n.Private(), n.Roster().Publics()),
commit: cosi.NewCosi(n.Suite(), n.Private(), n.Roster().Publics()),
},
verifyChan: make(chan bool),
VerificationFunction: verify,
threshold: (len(n.Tree().List()) + 1) * 2 / 3,
Msg: make([]byte, 0),
Data: make([]byte, 0),
}
idx, _ := n.Roster().Search(bft.ServerIdentity().ID)
bft.index = idx
// Registering channels.
err := bft.RegisterChannels(&bft.announceChan,
&bft.challengePrepareChan, &bft.challengeCommitChan,
&bft.commitChan, &bft.responseChan)
if err != nil {
return nil, err
}
n.OnDoneCallback(bft.nodeDone)
return bft, nil
}
开发者ID:dedis,项目名称:cothority,代码行数:31,代码来源:bftcosi.go
示例4: NewJVSS
// NewJVSS creates a new JVSS protocol instance and returns it.
func NewJVSS(node *onet.TreeNodeInstance) (onet.ProtocolInstance, error) {
kp := &config.KeyPair{Suite: node.Suite(), Public: node.Public(), Secret: node.Private()}
n := len(node.List())
pk := make([]abstract.Point, n)
var idx int
for i, tn := range node.List() {
if tn.ServerIdentity.Public.Equal(node.Public()) {
idx = i
}
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,
treeIndex: idx,
info: info,
schnorr: new(poly.Schnorr),
secrets: newSecrets(),
ltssInit: false,
longTermSecDone: make(chan bool, 1),
shortTermSecDone: make(chan bool, 1),
sigChan: make(chan *poly.SchnorrSig),
sidStore: newSidStore(),
}
// Setup message handlers
h := []interface{}{
jv.handleSecInit,
jv.handleSecConf,
jv.handleSigReq,
jv.handleSigResp,
}
err := jv.RegisterHandlers(h...)
if err != nil {
return nil, err
}
return jv, err
}
开发者ID:dedis,项目名称:cothority,代码行数:44,代码来源:jvss.go
示例5: NewProtocol
// NewProtocol returns a new pbft protocol
func NewProtocol(n *onet.TreeNodeInstance) (*Protocol, error) {
pbft := new(Protocol)
pbft.state = statePrePrepare
tree := n.Tree()
pbft.TreeNodeInstance = n
pbft.nodeList = tree.List()
idx := notFound
for i, tn := range pbft.nodeList {
if tn.ID.Equal(n.TreeNode().ID) {
idx = i
}
}
if idx == notFound {
panic(fmt.Sprintf("Could not find ourselves %+v in the list of nodes %+v", n, pbft.nodeList))
}
pbft.index = idx
// 2/3 * #participants == threshold FIXME the threshold is actually XXX
pbft.threshold = int(math.Ceil(float64(len(pbft.nodeList)) * 2.0 / 3.0))
pbft.prepMsgCount = 0
pbft.commitMsgCount = 0
if err := n.RegisterChannel(&pbft.prePrepareChan); err != nil {
return pbft, err
}
if err := n.RegisterChannel(&pbft.prepareChan); err != nil {
return pbft, err
}
if err := n.RegisterChannel(&pbft.commitChan); err != nil {
return pbft, err
}
if err := n.RegisterChannel(&pbft.finishChan); err != nil {
return pbft, err
}
return pbft, nil
}
开发者ID:dedis,项目名称:cothority,代码行数:37,代码来源:pbft.go
示例6: NewByzCoinProtocol
// NewByzCoinProtocol returns a new byzcoin struct
func NewByzCoinProtocol(n *onet.TreeNodeInstance) (*ByzCoin, error) {
// create the byzcoin
bz := new(ByzCoin)
bz.TreeNodeInstance = n
bz.suite = n.Suite()
bz.prepare = cosi.NewCosi(n.Suite(), n.Private())
bz.commit = cosi.NewCosi(n.Suite(), n.Private())
bz.verifyBlockChan = make(chan bool)
bz.doneProcessing = make(chan bool, 2)
bz.doneSigning = make(chan bool, 1)
bz.timeoutChan = make(chan uint64, 1)
//bz.endProto, _ = end.NewEndProtocol(n)
bz.aggregatedPublic = n.Roster().Aggregate
bz.threshold = int(math.Ceil(float64(len(bz.Tree().List())) / 3.0))
bz.viewChangeThreshold = int(math.Ceil(float64(len(bz.Tree().List())) * 2.0 / 3.0))
// register channels
if err := n.RegisterChannel(&bz.announceChan); err != nil {
return bz, err
}
if err := n.RegisterChannel(&bz.commitChan); err != nil {
return bz, err
}
if err := n.RegisterChannel(&bz.challengePrepareChan); err != nil {
return bz, err
}
if err := n.RegisterChannel(&bz.challengeCommitChan); err != nil {
return bz, err
}
if err := n.RegisterChannel(&bz.responseChan); err != nil {
return bz, err
}
if err := n.RegisterChannel(&bz.viewchangeChan); err != nil {
return bz, err
}
n.OnDoneCallback(bz.nodeDone)
go bz.listen()
return bz, nil
}
开发者ID:dedis,项目名称:cothority,代码行数:43,代码来源:byzcoin.go
示例7: NewProtocol
// NewProtocol returns a ProtocolCosi with the node set with the right channels.
// Use this function like this:
// ```
// round := NewRound****()
// fn := func(n *onet.Node) onet.ProtocolInstance {
// pc := NewProtocolCosi(round,n)
// return pc
// }
// onet.RegisterNewProtocolName("cothority",fn)
// ```
func NewProtocol(node *onet.TreeNodeInstance) (onet.ProtocolInstance, error) {
var err error
// XXX just need to take care to take the global list of cosigners once we
// do the exception stuff
publics := make([]abstract.Point, len(node.Roster().List))
for i, e := range node.Roster().List {
publics[i] = e.Public
}
c := &CoSi{
cosi: cosi.NewCosi(node.Suite(), node.Private(), publics),
TreeNodeInstance: node,
done: make(chan bool),
tempCommitLock: new(sync.Mutex),
tempResponseLock: new(sync.Mutex),
}
// Register the channels we want to register and listens on
if err := node.RegisterChannel(&c.announce); err != nil {
return c, err
}
if err := node.RegisterChannel(&c.commit); err != nil {
return c, err
}
if err := node.RegisterChannel(&c.challenge); err != nil {
return c, err
}
if err := node.RegisterChannel(&c.response); err != nil {
return c, err
}
return c, err
}
开发者ID:dedis,项目名称:cothority,代码行数:43,代码来源:cosi.go
注:本文中的github.com/dedis/onet.TreeNodeInstance类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论