aboutsummaryrefslogtreecommitdiff
path: root/instance.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-27 19:16:10 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-27 19:16:10 +0100
commite7801b268c97c6b72bfcd76549ce5fd50ab0b1b5 (patch)
tree1eecf16a6b263750b0d480c3d966dff2f3072cfd /instance.go
parent13dd306e69b26ab8b7aedcd6ed915df4b6672a01 (diff)
added ed25519 signing and SDIs
Diffstat (limited to 'instance.go')
-rw-r--r--instance.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/instance.go b/instance.go
index d4fc004..8914a4b 100644
--- a/instance.go
+++ b/instance.go
@@ -2,10 +2,12 @@ package stfe
import (
"crypto"
- "crypto/x509"
"fmt"
"time"
+ "crypto/x509"
+ "crypto/sha256"
+
"encoding/base64"
"net/http"
@@ -42,18 +44,32 @@ func NewInstance(lp *LogParameters, client trillian.TrillianLogClient, deadline
}
// NewLogParameters returns an initialized LogParameters
-func NewLogParameters(logId []byte, treeId int64, prefix string, anchorPath string) (*LogParameters, error) {
+func NewLogParameters(treeId int64, prefix string, anchorPath, keyPath string) (*LogParameters, error) {
anchorList, anchorPool, err := LoadTrustAnchors(anchorPath)
if err != nil {
return nil, err
}
+ key, err := LoadEd25519SigningKey(keyPath)
+ if err != nil {
+ return nil, err
+ }
+
+ pub, err := x509.MarshalPKIXPublicKey(key.Public())
+ if err != nil {
+ return nil, fmt.Errorf("failed DER encoding SubjectPublicKeyInfo: %v", err)
+ }
+ hasher := sha256.New()
+ hasher.Write(pub)
+ logId := hasher.Sum(nil)
+
return &LogParameters{
LogId: logId,
TreeId: treeId,
Prefix: prefix,
AnchorPool: anchorPool,
AnchorList: anchorList,
+ Signer: key,
}, nil
}