Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "signer", Long: `Signing for using the secret shares to generate a signature.`, RunE: func(cmd *cobra.Command, args []string) error { yamlFile, err := os.ReadFile(viper.GetString("config")) if err != nil { return err } cfg := SignerConfig{} err = yaml.Unmarshal(yamlFile, &cfg) if err != nil { return err } rawIdentity, err := base64.StdEncoding.DecodeString(cfg.Identity) priv, err := crypto.UnmarshalPrivateKey(rawIdentity) if err != nil { log.Crit("Failed to unmarshal", "err", err) } host, err := node.MakeBasicHost(cfg.Port, priv) if err != nil { log.Crit("Failed to create a basic host", "err", err) } selfId := host.ID().String() log.Debug("my ID", "id", selfId, "addr", host.Addrs()) pm := node.NewPeerManager(selfId, host, signerProtocol) for _, p := range cfg.Peers { pm.AddPeer(p.Id, node.GetPeerAddr(p.Port, p.Id)) } l := node.NewListener() dkgResult, err := utils.ConvertDKGResult(cfg.Pubkey, cfg.Share, cfg.BKs) if err != nil { log.Warn("Cannot get DKG result", "err", err) return err } paillier, err := paillier.NewPaillier(2048) if err != nil { log.Warn("Cannot create a paillier function", "err", err) return err } signerCore, err := signer.NewSigner(pm, dkgResult.PublicKey, paillier, dkgResult.Share, dkgResult.Bks, []byte(cfg.Message), l) if err != nil { log.Warn("Cannot create a new signer", "err", err) return err } node := node.New[*signer.Message, *signer.Result](signerCore, l, pm) if err != nil { log.Crit("Failed to new service", "err", err) } host.SetStreamHandler(signerProtocol, func(s network.Stream) { node.Handle(s) }) pm.EnsureAllConnected() result, err := node.Process() if err != nil { return err } signerResult := &SignerResult{ R: result.R.String(), S: result.S.String(), } rawResult, _ := yaml.Marshal(signerResult) fmt.Println(string(rawResult)) return nil }, }
Functions ¶
This section is empty.
Types ¶
type SignerConfig ¶
type SignerConfig struct { node.PeerConfig `yaml:",omitempty,inline"` dkg.DKGResult `yaml:",omitempty,inline"` Message string `yaml:"msg"` }
type SignerResult ¶
Click to show internal directories.
Click to hide internal directories.