Simple merkle rfc compatibility (#2713)

* Begin simple merkle compatibility PR

* Fix query_test

* Use trillian test vectors

* Change the split point per RFC 6962

* update spec

* refactor innerhash to match spec

* Update changelog

* Address @liamsi's comments

* Write the comment requested by @liamsi
This commit is contained in:
Dev Ojha
2019-01-13 17:02:38 -06:00
committed by Ethan Buchman
parent 1f68318875
commit ec53ce359b
15 changed files with 233 additions and 112 deletions

View File

@ -9,7 +9,6 @@ import (
"github.com/pkg/errors"
"github.com/tendermint/tendermint/crypto/merkle"
"github.com/tendermint/tendermint/crypto/tmhash"
cmn "github.com/tendermint/tendermint/libs/common"
)
@ -27,16 +26,6 @@ type Part struct {
hash []byte
}
func (part *Part) Hash() []byte {
if part.hash != nil {
return part.hash
}
hasher := tmhash.New()
hasher.Write(part.Bytes) // nolint: errcheck, gas
part.hash = hasher.Sum(nil)
return part.hash
}
// ValidateBasic performs basic validation.
func (part *Part) ValidateBasic() error {
if part.Index < 0 {
@ -217,7 +206,7 @@ func (ps *PartSet) AddPart(part *Part) (bool, error) {
}
// Check hash proof
if part.Proof.Verify(ps.Hash(), part.Hash()) != nil {
if part.Proof.Verify(ps.Hash(), part.Bytes) != nil {
return false, ErrPartSetInvalidProof
}