celestiaorg / nmt

Namespaced Merkle Tree
Apache License 2.0
113 stars 39 forks source link

redundant hashing in the computeRoot #143

Closed staheri14 closed 1 year ago

staheri14 commented 1 year ago

Problem

The computeRoot function currently calculates the root from the leaves even if if the leaves are already hashed and the result is available in the leafHashes of NamespacedMerkleTree. This can result in redundant hashing and is inconsistent with the purpose of the leafHashes field, which is intended to act as a cache for hashed leaves and save computational time.

Acceptance Criteria

The computeRoot function should be modified to use the leafHashes field if it is non-empty.

staheri14 commented 1 year ago

Closed by https://github.com/celestiaorg/nmt/pull/172