From f02d9ad52b4b70fc1af8224201cf993faa82eaee Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Tue, 17 Nov 2020 12:11:30 +0100 Subject: fixed redundant tree head checking --- type.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'type.go') 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 -- cgit v1.2.3