blob: 2a29628067ce439fae1e204c3dbb77db5b850d5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
package util
import (
"crypto"
"crypto/ed25519"
"fmt"
"git.sigsum.org/sigsum-go/pkg/hex"
)
func SignerFromHex(s string) (crypto.Signer, error) {
b, err := hex.Deserialize(s)
if err != nil {
return nil, fmt.Errorf("util: parse key: %v", err)
}
if len(b) != ed25519.PrivateKeySize {
return nil, fmt.Errorf("util: invalid private key size %d", len(b))
}
return ed25519.PrivateKey(b), nil
}
|