aboutsummaryrefslogtreecommitdiff
path: root/type.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-17 12:11:30 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-17 12:11:30 +0100
commitf02d9ad52b4b70fc1af8224201cf993faa82eaee (patch)
tree811472fac4b5616f845d64536d5b12169d511f62 /type.go
parentdef4ef7b3b47d955a9a4932549536f36aa6b4745 (diff)
fixed redundant tree head checking
Diffstat (limited to 'type.go')
-rw-r--r--type.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/type.go b/type.go
index 93022b7..7105eff 100644
--- a/type.go
+++ b/type.go
@@ -282,15 +282,13 @@ func NewChecksumV1(identifier []byte, checksum []byte) *StItem {
// NewTreeHead creates a new TreeHeadV1 from a Trillian-signed log root without
// verifying any signature. In other words, Trillian <-> STFE must be trusted.
-func NewTreeHeadV1(lp *LogParameters, slr *trillian.SignedLogRoot) (*TreeHeadV1, error) {
- var lr types.LogRootV1
- if err := lr.UnmarshalBinary(slr.GetLogRoot()); err != nil {
- return nil, fmt.Errorf("failed unmarshaling Trillian slr: %v", err)
+func NewTreeHeadV1(lp *LogParameters, lr *types.LogRootV1) *TreeHeadV1 {
+ return &TreeHeadV1{
+ uint64(lr.TimestampNanos / 1000 / 1000),
+ uint64(lr.TreeSize),
+ NodeHash{lr.RootHash},
+ nil,
}
- if lp.HashType.Size() != len(lr.RootHash) {
- return nil, fmt.Errorf("invalid Trillian root hash: %v", lr.RootHash)
- }
- return &TreeHeadV1{uint64(lr.TimestampNanos / 1000 / 1000), uint64(lr.TreeSize), NodeHash{lr.RootHash}, nil}, nil
}
// NewAppendix creates a new leaf Appendix for an X.509 chain and signature