Skip to content

Commit ba795ea

Browse files
committed
updated natspec in TxMerkleProof lib
1 parent 006533f commit ba795ea

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

contracts/libs/TxMerkleProof.sol

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,19 @@ pragma solidity ^0.8.28;
66
* Provides functions for processing and verifying Merkle tree proofs
77
*/
88
library TxMerkleProof {
9+
/**
10+
* @notice Emitted when the proof and directions array are of different length.
11+
* This error ensures that only correctly sized proofs are processed
12+
*/
913
error InvalidLengths();
1014

15+
/**
16+
* @notice Returns true if `leaf_` can be proven to be part of a Merkle tree
17+
* defined by `root_`. Requires a `proof_` containing the sibling hashes along
18+
* the path from the leaf to the root. Each byte of `directions_` indicates
19+
* the hashing order for each pair.
20+
* Uses double SHA-256 hashing.
21+
*/
1122
function verify(
1223
bytes32[] memory proof_,
1324
bytes calldata directions_,
@@ -19,6 +30,13 @@ library TxMerkleProof {
1930
return processProof(proof_, directions_, leaf_) == root_;
2031
}
2132

33+
/**
34+
* @notice Returns the rebuilt hash obtained by traversing the Merkle tree
35+
* from `leaf_` using `proof_`. A `proof_` is valid if and only if the rebuilt
36+
* hash matches the given tree root. The pre-images are hashed in the order
37+
* specified by the `directions_` bytes.
38+
* Uses double SHA-256 hashing.
39+
*/
2240
function processProof(
2341
bytes32[] memory proof_,
2442
bytes calldata directions_,

0 commit comments

Comments
 (0)