Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "reshare", Long: `Refresh the secret shares without changing the public key.`, RunE: func(cmd *cobra.Command, args []string) error { yamlFile, err := os.ReadFile(viper.GetString("config")) if err != nil { return err } cfg := ReshareConfig{} 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, reshareProtocol) for _, p := range cfg.Peers { pm.AddPeer(p.Id, node.GetPeerAddr(p.Port, p.Id)) } dkgResult, err := utils.ConvertDKGResult(cfg.Pubkey, cfg.Share, cfg.BKs) if err != nil { log.Warn("Cannot get DKG result", "err", err) return err } l := node.NewListener() reshareCore, err := reshare.NewReshare(pm, cfg.Threshold, dkgResult.PublicKey, dkgResult.Share, dkgResult.Bks, l) if err != nil { log.Warn("Cannot create a new reshare core", "err", err) return err } node := node.New[*reshare.Message, *reshare.Result](reshareCore, l, pm) if err != nil { log.Crit("Failed to new service", "err", err) } host.SetStreamHandler(reshareProtocol, func(s network.Stream) { node.Handle(s) }) pm.EnsureAllConnected() result, err := node.Process() if err != nil { return err } reshareResult := &ReshareResult{ Share: result.Share.String(), } rawResult, _ := yaml.Marshal(reshareResult) fmt.Println(string(rawResult)) return nil }, }
Functions ¶
This section is empty.
Types ¶
type ReshareConfig ¶
type ReshareConfig struct {}
type ReshareResult ¶
type ReshareResult struct {
} Click to show internal directories.
Click to hide internal directories.