Skip to content

Commit

Permalink
recompute hash
Browse files Browse the repository at this point in the history
  • Loading branch information
expertdicer committed Feb 19, 2024
1 parent 5e1895c commit 8e0e3de
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion header/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/celestiaorg/celestia-app/pkg/da"
libhead "github.com/celestiaorg/go-header"
"github.com/celestiaorg/rsmt2d"
"github.com/tendermint/tendermint/crypto/merkle"
)

// ConstructFn aliases a function that creates an ExtendedHeader.
Expand Down Expand Up @@ -94,7 +95,17 @@ func (eh *ExtendedHeader) Time() time.Time {
// NOTE: It purposely overrides Hash method of RawHeader to get it directly from Commit without
// recomputing.
func (eh *ExtendedHeader) Hash() libhead.Hash {
return eh.Commit.BlockID.Hash.Bytes()
bs := make([][]byte, len(eh.Commit.Signatures))
for i, commitSig := range eh.Commit.Signatures {
pbcs := commitSig.ToProto()
bz, err := pbcs.Marshal()
if err != nil {
panic(err)
}

bs[i] = bz
}
return merkle.HashFromByteSlices(bs)
}

// LastHeader returns the Hash of the last wrapped RawHeader.
Expand Down

0 comments on commit 8e0e3de

Please sign in to comment.