Skip to content

Commit cf11051

Browse files
committed
fix(docs): improve comments for determining left/right sibling with index modulus
1 parent a2dde9e commit cf11051

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/contracts/libraries/Merkle.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ library Merkle {
5555
bytes32 computedHash = leaf;
5656
for (uint256 i = 32; i <= proof.length; i += 32) {
5757
if (index % 2 == 0) {
58-
// if ith bit of index is 0, then computedHash is a left sibling
58+
// if index is even, then computedHash is a left sibling
5959
assembly {
6060
mstore(0x00, computedHash)
6161
mstore(0x20, mload(add(proof, i)))
6262
computedHash := keccak256(0x00, 0x40)
6363
index := div(index, 2)
6464
}
6565
} else {
66-
// if ith bit of index is 1, then computedHash is a right sibling
66+
// if index is odd, then computedHash is a right sibling
6767
assembly {
6868
mstore(0x00, mload(add(proof, i)))
6969
mstore(0x20, computedHash)
@@ -109,15 +109,15 @@ library Merkle {
109109
bytes32[1] memory computedHash = [leaf];
110110
for (uint256 i = 32; i <= proof.length; i += 32) {
111111
if (index % 2 == 0) {
112-
// if ith bit of index is 0, then computedHash is a left sibling
112+
// if index is even, then computedHash is a left sibling
113113
assembly {
114114
mstore(0x00, mload(computedHash))
115115
mstore(0x20, mload(add(proof, i)))
116116
if iszero(staticcall(sub(gas(), 2000), 2, 0x00, 0x40, computedHash, 0x20)) { revert(0, 0) }
117117
index := div(index, 2)
118118
}
119119
} else {
120-
// if ith bit of index is 1, then computedHash is a right sibling
120+
// if index is odd, then computedHash is a right sibling
121121
assembly {
122122
mstore(0x00, mload(add(proof, i)))
123123
mstore(0x20, mload(computedHash))

0 commit comments

Comments
 (0)