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 --- reqres.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'reqres.go') diff --git a/reqres.go b/reqres.go index e1f97ee..fe79d51 100644 --- a/reqres.go +++ b/reqres.go @@ -33,6 +33,11 @@ type GetProofByHashRequest struct { TreeSize int64 `json:"tree_size"` // Tree head size to base proof on } +// AddEntryResponse is an assembled add-entry response +type AddEntryResponse struct { + SignedDebugInfo string `json:"sdi"` +} + // GetEntryResponse is an assembled log entry and its associated appendix type GetEntryResponse struct { Leaf string `json:"leaf"` // base64-encoded StItem @@ -118,6 +123,17 @@ func NewGetProofByHashRequest(httpRequest *http.Request) (GetProofByHashRequest, return GetProofByHashRequest{TreeSize: treeSize, Hash: hash}, nil } +// NewAddEntryResponse assembles an add-entry response from an SDI +func NewAddEntryResponse(sdi StItem) (AddEntryResponse, error) { + b, err := tls.Marshal(sdi) + if err != nil { + return AddEntryResponse{}, fmt.Errorf("tls marshal failed: %v", err) + } + return AddEntryResponse{ + SignedDebugInfo: base64.StdEncoding.EncodeToString(b), + }, nil +} + // NewGetEntryResponse assembles a log entry and its appendix func NewGetEntryResponse(leaf, appendix []byte) (GetEntryResponse, error) { var app Appendix -- cgit v1.2.3