aboutsummaryrefslogtreecommitdiff
path: root/type.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-22 20:15:40 +0200
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-22 20:15:40 +0200
commit6bd17ab810ec1eaa1f93ef7136ee4008337a2f14 (patch)
tree735d2513e83bdb67af637d01be56884c3f329a99 /type.go
parente049d303d911b02d7505214e56744f21437f3916 (diff)
attached InclusionProofV1 onto StItem
Diffstat (limited to 'type.go')
-rw-r--r--type.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/type.go b/type.go
index bd54df6..a734411 100644
--- a/type.go
+++ b/type.go
@@ -44,8 +44,9 @@ func (f StFormat) String() string {
// StItem references a versioned item based on a given format specifier.
type StItem struct {
- Format StFormat `tls:"maxval:65535"`
- ChecksumV1 *ChecksumV1 `tls:"selector:Format,val:5"`
+ Format StFormat `tls:"maxval:65535"`
+ InclusionProofV1 *InclusionProofV1 `tls:"selector:Format,val:4"`
+ ChecksumV1 *ChecksumV1 `tls:"selector:Format,val:5"`
// TODO: add more items
}
@@ -106,17 +107,20 @@ type InclusionProofV1 struct {
InclusionPath []NodeHash `tls:"minlen:1,maxlen:65535"`
}
-func NewInclusionProofV1(logID []byte, treeSize uint64, proof *trillian.Proof) InclusionProofV1 {
+func NewInclusionProofV1(logID []byte, treeSize uint64, proof *trillian.Proof) StItem {
inclusionPath := make([]NodeHash, 0, len(proof.Hashes))
for _, hash := range proof.Hashes {
inclusionPath = append(inclusionPath, NodeHash{Data: hash})
}
- return InclusionProofV1{
- LogID: logID,
- TreeSize: treeSize,
- LeafIndex: uint64(proof.LeafIndex),
- InclusionPath: inclusionPath,
+ return StItem{
+ Format: StFormatInclusionProofV1,
+ InclusionProofV1: &InclusionProofV1{
+ LogID: logID,
+ TreeSize: treeSize,
+ LeafIndex: uint64(proof.LeafIndex),
+ InclusionPath: inclusionPath,
+ },
}
}