diff options
author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-10-27 19:16:10 +0100 |
---|---|---|
committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-10-27 19:16:10 +0100 |
commit | e7801b268c97c6b72bfcd76549ce5fd50ab0b1b5 (patch) | |
tree | 1eecf16a6b263750b0d480c3d966dff2f3072cfd /reqres.go | |
parent | 13dd306e69b26ab8b7aedcd6ed915df4b6672a01 (diff) |
added ed25519 signing and SDIs
Diffstat (limited to 'reqres.go')
-rw-r--r-- | reqres.go | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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 |