Exemplo n.º 1
0
func newSkipchainService(c *onet.Context, path string) onet.Service {
	s := &Service{
		ServiceProcessor: onet.NewServiceProcessor(c),
		path:             path,
		SkipBlockMap:     &SkipBlockMap{make(map[string]*SkipBlock)},
		verifiers:        map[VerifierID]SkipBlockVerifier{},
	}
	var err error
	s.Propagate, err = manage.NewPropagationFunc(c, "SkipchainPropagate", s.PropagateSkipBlock)
	log.ErrFatal(err)
	c.ProtocolRegister(skipchainBFT, func(n *onet.TreeNodeInstance) (onet.ProtocolInstance, error) {
		return bftcosi.NewBFTCoSiProtocol(n, s.bftVerify)
	})
	if err := s.tryLoad(); err != nil {
		log.Error(err)
	}
	log.ErrFatal(s.RegisterHandlers(s.ProposeSkipBlock, s.SetChildrenSkipBlock,
		s.GetUpdateChain))
	if err := s.RegisterVerification(VerifyShard, s.VerifyShardFunc); err != nil {
		log.Panic(err)
	}
	if err := s.RegisterVerification(VerifyNone, s.VerifyNoneFunc); err != nil {
		log.Panic(err)
	}
	return s
}
Exemplo n.º 2
0
func newIdentityService(c *onet.Context, path string) onet.Service {
	s := &Service{
		ServiceProcessor: onet.NewServiceProcessor(c),
		StorageMap:       &StorageMap{make(map[string]*Storage)},
		skipchain:        skipchain.NewClient(),
		path:             path,
	}
	var err error
	s.propagateIdentity, err =
		manage.NewPropagationFunc(c, "IdentityPropagateID", s.propagateIdentityHandler)
	if err != nil {
		return nil
	}
	s.propagateSkipBlock, err =
		manage.NewPropagationFunc(c, "IdentityPropagateSB", s.propagateSkipBlockHandler)
	if err != nil {
		return nil
	}
	s.propagateConfig, err =
		manage.NewPropagationFunc(c, "IdentityPropagateConf", s.propagateConfigHandler)
	if err != nil {
		return nil
	}
	if err := s.tryLoad(); err != nil {
		log.Error(err)
	}
	for _, f := range []interface{}{s.ProposeSend, s.ProposeVote,
		s.CreateIdentity, s.ProposeUpdate, s.ConfigUpdate} {
		if err := s.RegisterHandler(f); err != nil {
			log.Fatal("Registration error:", err)
		}
	}
	return s
}
Exemplo n.º 3
0
func newCoSiService(c *onet.Context, path string) onet.Service {
	s := &CoSi{
		ServiceProcessor: onet.NewServiceProcessor(c),
		path:             path,
	}
	err := s.RegisterHandler(s.SignatureRequest)
	if err != nil {
		log.ErrFatal(err, "Couldn't register message:")
	}
	return s
}
Exemplo n.º 4
0
// newGuardService creates a new service that is built for Guard.
func newGuardService(c *onet.Context, path string) onet.Service {
	s := &Guard{
		ServiceProcessor: onet.NewServiceProcessor(c),
		path:             path,
	}
	err := s.RegisterHandler(s.Request)
	if err != nil {
		log.ErrFatal(err, "Couldn't register message:")
	}

	//This is the area where Z is generated for a server
	const n = 88
	lel := make([]byte, n)
	_, err = rand.Read(lel)
	log.ErrFatal(err)
	s.Z = lel

	return s
}