blob: 368e14b9b853d22cd5c48384b18b499176f7b976 (
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
26
27
28
29
30
31
32
33
34
35
36
37
|
package main
import (
"fmt"
"crypto/ed25519"
"git.sigsum.org/sigsum-go/pkg/hex"
"git.sigsum.org/sigsum-go/pkg/types"
)
func CmdHashLeaf(optPriv string, optShardHint uint64) error {
data, err := readStdin()
if err != nil {
return fmt.Errorf("sign: %v", err)
}
priv, err := privFromHex(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
}
|