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/hashleaf/hashleaf.go | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 cmd/sigsum-debug/hashleaf/hashleaf.go (limited to 'cmd/sigsum-debug/hashleaf') diff --git a/cmd/sigsum-debug/hashleaf/hashleaf.go b/cmd/sigsum-debug/hashleaf/hashleaf.go new file mode 100644 index 0000000..00f8bbb --- /dev/null +++ b/cmd/sigsum-debug/hashleaf/hashleaf.go @@ -0,0 +1,38 @@ +package hashleaf + +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, optPriv string, optShardHint uint64) error { + data, err := util.BytesFromStdin() + if err != nil { + return fmt.Errorf("sign: %v", err) + } + priv, err := util.SignerFromHex(optPriv) + if err != nil { + return fmt.Errorf("sign: %v", err) + } + stm := types.Statement{ + ShardHint: optShardHint, + Checksum: *types.HashFn(data), + } + sig, err := stm.Sign(priv) + if err != nil { + fmt.Errorf("sign: %v", err) + } + leaf := types.Leaf{ + Statement: stm, + Signature: *sig, + KeyHash: *types.HashFn(priv.Public().(ed25519.PublicKey)[:]), + } + lh := types.LeafHash(leaf.ToBinary()) + + fmt.Printf("%s\n", hex.Serialize(lh[:])) + return nil +} -- cgit v1.2.3