From e7801b268c97c6b72bfcd76549ce5fd50ab0b1b5 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Tue, 27 Oct 2020 19:16:10 +0100 Subject: added ed25519 signing and SDIs --- instance.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'instance.go') 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 } -- cgit v1.2.3