From 8fee6561fbc21bd44f67dff9f365aa14da293d99 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Wed, 13 Apr 2022 16:10:43 +0200 Subject: clean-up sigsum-debug structure --- cmd/sigsum-debug/pubkey/pubkey.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 cmd/sigsum-debug/pubkey/pubkey.go (limited to 'cmd/sigsum-debug/pubkey') diff --git a/cmd/sigsum-debug/pubkey/pubkey.go b/cmd/sigsum-debug/pubkey/pubkey.go new file mode 100644 index 0000000..8f3b467 --- /dev/null +++ b/cmd/sigsum-debug/pubkey/pubkey.go @@ -0,0 +1,28 @@ +package pubkey + +import ( + "crypto/ed25519" + "fmt" + + "git.sigsum.org/sigsum-go/pkg/hex" + "git.sigsum.org/sigsum-tools-go/internal/util" +) + +func Main(_ []string) error { + b, err := util.HexFromStdin() + if err != nil { + return err + } + if len(b) != ed25519.PrivateKeySize { + return fmt.Errorf("pubkey: invalid key size %d", len(b)) + } + + priv := ed25519.PrivateKey(b) + pub, ok := priv.Public().(ed25519.PublicKey) + if !ok { + return fmt.Errorf("pubkey: must parse as ed25519") + } + + fmt.Printf("%s\n", hex.Serialize(pub[:])) + return nil +} -- cgit v1.2.3