-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: backport zetaclient gen-pre-params command
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <path>", | ||
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 | ||
}, | ||
} |