aboutsummaryrefslogtreecommitdiff
path: root/cmd/sigsum-debug/pubkey.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/sigsum-debug/pubkey.go')
-rw-r--r--cmd/sigsum-debug/pubkey.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/cmd/sigsum-debug/pubkey.go b/cmd/sigsum-debug/pubkey.go
new file mode 100644
index 0000000..586d19a
--- /dev/null
+++ b/cmd/sigsum-debug/pubkey.go
@@ -0,0 +1,27 @@
+package main
+
+import (
+ "crypto/ed25519"
+ "fmt"
+
+ "git.sigsum.org/sigsum-lib-go/pkg/hex"
+)
+
+func CmdPubKey() error {
+ b, err := decodeHexFromStdin()
+ if err != nil {
+ return err
+ }
+ if len(b) != ed25519.PrivateKeySize {
+ return fmt.Errorf("invalid private key: size")
+ }
+
+ priv := ed25519.PrivateKey(b)
+ pub, ok := priv.Public().(ed25519.PublicKey)
+ if !ok {
+ return fmt.Errorf("failed converting to public key")
+ }
+
+ fmt.Printf("%s\n", hex.Serialize(pub[:]))
+ return nil
+}