aboutsummaryrefslogtreecommitdiff
path: root/cmd/sigsum-debug/hashkey/hashkey.go
blob: f195239f67f68759e2289443df5ec996557487f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
}