celestiaorg / nmt

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

feat: ensures VerifyLeafHashes rejects leafHashes with wrong namespaces #207

Closed staheri14 closed 1 year ago

staheri14 commented 1 year ago

Overview

Closes #183. The modifications in this PR are also in line with empowering light clients to furnish BEFPs for proofs that encounter unsuccessful verification outcomes (where the early termination of verification upon encountering invalid leaf hashes, with mismatching namespaces, gives a clear indication of the failure root cause, enabling them to decide on whether to craft BEFPs or not accordingly).

Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #207 (b1bd9ce) into master (033ce9e) will decrease coverage by 1.37%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #207      +/-   ##
==========================================
- Coverage   95.39%   94.03%   -1.37%     
==========================================
  Files           5        5              
  Lines         565      570       +5     
==========================================
- Hits          539      536       -3     
- Misses         15       19       +4     
- Partials       11       15       +4     
Impacted Files Coverage Δ
proof.go 88.51% <100.00%> (-5.20%) :arrow_down:
staheri14 commented 1 year ago

After investigating the code to determine the cause of the coverage decline, I have discovered the reason:

In the updated version of the code, the computeRoot function no longer has the potential to fail or produce errors. Errors can only occur when attempting to use the HashNode, which can only happen when incorrect inputs are provided. However, as a result of this PR, all the inputs given to the function are guaranteed to be well-formatted and valid. Specifically, they meet the following criteria:

Therefore, it is safe to disregard the reduced coverage and proceed with merging the PR.