From dee4d2469a523b59196eb51facdd4cc5039fe32f Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Thu, 20 Jun 2024 12:12:54 -0700 Subject: [PATCH] chore: backport zetaclient gen-pre-params command --- cmd/zetaclientd/gen_pre_params.go | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 cmd/zetaclientd/gen_pre_params.go diff --git a/cmd/zetaclientd/gen_pre_params.go b/cmd/zetaclientd/gen_pre_params.go new file mode 100644 index 0000000000..c797a9f206 --- /dev/null +++ b/cmd/zetaclientd/gen_pre_params.go @@ -0,0 +1,40 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "time" + + "github.com/binance-chain/tss-lib/ecdsa/keygen" + "github.com/spf13/cobra" +) + +func init() { + RootCmd.AddCommand(GenPrePramsCmd) +} + +var GenPrePramsCmd = &cobra.Command{ + Use: "gen-pre-params ", + Short: "Generate pre parameters for TSS", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + startTime := time.Now() + preParams, err := keygen.GeneratePreParams(time.Second * 300) + if err != nil { + return err + } + + file, err := os.OpenFile(args[0], os.O_RDWR|os.O_CREATE, 0600) + if err != nil { + return err + } + defer file.Close() + err = json.NewEncoder(file).Encode(preParams) + if err != nil { + return err + } + fmt.Printf("Generated new pre-parameters in %v\n", time.Since(startTime)) + return nil + }, +}