From 7d0613cb01b5b1f94bbe207fc63036f0139bab12 Mon Sep 17 00:00:00 2001 From: Eduardo Date: Wed, 4 Dec 2019 14:51:37 -0300 Subject: [PATCH] adding gencurve --- cmd/gencurve.go | 21 +++++++++++++++++++++ cmd/root.go | 1 + 2 files changed, 22 insertions(+) create mode 100644 cmd/gencurve.go diff --git a/cmd/gencurve.go b/cmd/gencurve.go new file mode 100644 index 0000000..e44a69c --- /dev/null +++ b/cmd/gencurve.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "fmt" + "github.com/pebbe/zmq4" + "github.com/spf13/cobra" +) + +var genCurveCmd = &cobra.Command{ + Use: "generate-curve", + Short: "Returns a Public Key and a Private Key usable in the system", + RunE: func(cmd *cobra.Command, args []string) error { + pk, sk, err := zmq4.NewCurveKeypair() + if err != nil { + return fmt.Errorf("Cannot generate curve key pair") + } + fmt.Printf("Public Key: %s\n", pk) + fmt.Printf("Private Key: %s\n", sk) + return nil + }, +} diff --git a/cmd/root.go b/cmd/root.go index 96ac7f8..87fd824 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -8,6 +8,7 @@ import ( func init() { rootCmd.AddCommand(rsaCmd) + rootCmd.AddCommand(genCurveCmd) Log = log.New(os.Stderr, "", 0) }