aboutsummaryrefslogtreecommitdiff
path: root/cmd/sigsum-debug/hashkey
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@mullvad.net>2022-04-13 16:10:43 +0200
committerRasmus Dahlberg <rasmus@mullvad.net>2022-04-13 16:10:43 +0200
commit8fee6561fbc21bd44f67dff9f365aa14da293d99 (patch)
treee1f27b545439a7cb47254342cfbff6121bf41f6b /cmd/sigsum-debug/hashkey
parent8a4f764a7304ecbff07d451a21926bdc1a7fb3d4 (diff)
clean-up sigsum-debug structure
Diffstat (limited to 'cmd/sigsum-debug/hashkey')
-rw-r--r--cmd/sigsum-debug/hashkey/hashkey.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/cmd/sigsum-debug/hashkey/hashkey.go b/cmd/sigsum-debug/hashkey/hashkey.go
new file mode 100644
index 0000000..f195239
--- /dev/null
+++ b/cmd/sigsum-debug/hashkey/hashkey.go
@@ -0,0 +1,25 @@
+package hashkey
+
+import (
+ "crypto/ed25519"
+ "fmt"
+
+ "git.sigsum.org/sigsum-go/pkg/hex"
+ "git.sigsum.org/sigsum-go/pkg/types"
+ "git.sigsum.org/sigsum-tools-go/internal/util"
+)
+
+func Main(_ []string) error {
+ b, err := util.HexFromStdin()
+ if err != nil {
+ return fmt.Errorf("hashkey: %v", err)
+ }
+ if len(b) != ed25519.PublicKeySize {
+ return fmt.Errorf("hashkey: invalid private key size %d", len(b))
+ }
+ pub := ed25519.PublicKey(b)
+ keyHash := types.HashFn(pub)
+
+ fmt.Printf("%s\n", hex.Serialize(keyHash[:]))
+ return nil
+}