aboutsummaryrefslogtreecommitdiff
path: root/types/types.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-05-31 13:34:04 +0200
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-05-31 13:34:04 +0200
commitf3465d2088f54e49c4939137116d23e5e26c3d22 (patch)
tree11006fa3d2dc5c91275f9f4db43e95a7f59e1b8a /types/types.go
parent6a20aec8e8a93ce11f8b940659f49c889f94aef1 (diff)
added (un)marshal methods
Diffstat (limited to 'types/types.go')
-rw-r--r--types/types.go63
1 files changed, 54 insertions, 9 deletions
diff --git a/types/types.go b/types/types.go
index 483dac0..2da40da 100644
--- a/types/types.go
+++ b/types/types.go
@@ -6,8 +6,9 @@ import (
)
const (
- HashSize = sha256.Size
- SignatureSize = ed25519.SignatureSize
+ HashSize = sha256.Size
+ SignatureSize = ed25519.SignatureSize
+ VerificationKeySize = ed25519.PublicKeySize
)
// Leaf is the log's Merkle tree leaf.
@@ -22,14 +23,14 @@ type Leaf struct {
// these values to fit the log's shard interval and the opaque data in question.
type Message struct {
ShardHint uint64
- Checksum [HashSize]byte
+ Checksum *[HashSize]byte
}
// SigIdent is composed of a signature-signer pair. The signature is computed
// over the Trunnel-serialized leaf message. KeyHash identifies the signer.
type SigIdent struct {
- Signature [SignatureSize]byte
- KeyHash [HashSize]byte
+ Signature *[SignatureSize]byte
+ KeyHash *[HashSize]byte
}
// SignedTreeHead is composed of a tree head and a list of signature-signer
@@ -40,7 +41,7 @@ type SigIdent struct {
// Ref: https://github.com/system-transparency/stfe/blob/design/doc/api.md#get-tree-head-latest
type SignedTreeHead struct {
TreeHead
- SigIdent []SigIdent
+ SigIdent []*SigIdent
}
// TreeHead is the log's tree head.
@@ -49,7 +50,7 @@ type SignedTreeHead struct {
type TreeHead struct {
Timestamp uint64
TreeSize uint64
- RootHash [HashSize]byte
+ RootHash *[HashSize]byte
}
// ConsistencyProof is a consistency proof that proves the log's append-only
@@ -59,7 +60,7 @@ type TreeHead struct {
type ConsistencyProof struct {
NewSize uint64
OldSize uint64
- Path [][HashSize]byte
+ Path []*[HashSize]byte
}
// InclusionProof is an inclusion proof that proves a leaf is included in the
@@ -69,5 +70,49 @@ type ConsistencyProof struct {
type InclusionProof struct {
TreeSize uint64
LeafIndex uint64
- Path [][HashSize]byte
+ Path []*[HashSize]byte
+}
+
+// LeafList is a list of leaves
+type LeafList []*Leaf
+
+// ConsistencyProofRequest is a get-consistency-proof request
+//
+// Ref: https://github.com/system-transparency/stfe/blob/design/doc/api.md#get-consistency-proof
+type ConsistencyProofRequest struct {
+ NewSize uint64
+ OldSize uint64
+}
+
+// InclusionProofRequest is a get-proof-by-hash request
+//
+// Ref: https://github.com/system-transparency/stfe/blob/design/doc/api.md#get-proof-by-hash
+type InclusionProofRequest struct {
+ LeafHash *[HashSize]byte
+ TreeSize uint64
+}
+
+// LeavesRequest is a get-leaves request
+//
+// Ref: https://github.com/system-transparency/stfe/blob/design/doc/api.md#get-leaves
+type LeavesRequest struct {
+ StartSize uint64
+ EndSize uint64
+}
+
+// LeafRequest is an add-leaf request
+//
+// Ref: https://github.com/system-transparency/stfe/blob/design/doc/api.md#add-leaf
+type LeafRequest struct {
+ Message
+ Signature *[SignatureSize]byte
+ VerificationKey *[VerificationKeySize]byte
+ DomainHint string
+}
+
+// CosignatureRequest is an add-cosignature request
+//
+// Ref: https://github.com/system-transparency/stfe/blob/design/doc/api.md#add-cosignature
+type CosignatureRequest struct {
+ SigIdent
}