Skip to content

Commit

Permalink
fix: use baseHasher.Size for sha256Len instead of n.Size (#93)
Browse files Browse the repository at this point in the history
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview
This PR fixes the bug included in the last release, that resulted
(silently) in producing a different hash than the original hasher.

Related: 
celestiaorg/celestia-core#954
celestiaorg/celestia-node#1651
<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 
-->
  • Loading branch information
distractedm1nd authored Feb 2, 2023
1 parent 75ea372 commit b04eea5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (n *Hasher) Sum([]byte) []byte {
return n.HashLeaf(n.data)
case NodePrefix:
flagLen := int(n.NamespaceLen) * 2
sha256Len := n.Size()
sha256Len := n.baseHasher.Size()
return n.HashNode(n.data[:flagLen+sha256Len], n.data[flagLen+sha256Len:])
default:
panic("nmt node type wasn't set")
Expand Down

0 comments on commit b04eea5

Please sign in to comment.