From 253a6314e04ab1eef89730403feabbc608428e5d Mon Sep 17 00:00:00 2001 From: Uncle Stretch Date: Thu, 30 Jul 2026 22:11:29 +0300 Subject: [PATCH] hashing for tree leaves added Signed-off-by: Uncle Stretch --- src/types/Weaver.sol | 10 +++++++--- test/gatekeeper/GatekeeperWeaver.t.sol | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/types/Weaver.sol b/src/types/Weaver.sol index 8f56034..8443d7f 100644 --- a/src/types/Weaver.sol +++ b/src/types/Weaver.sol @@ -52,7 +52,10 @@ abstract contract Weaver is IWeaver { bytes32 left = bytes32(_treeNodes[session][j].upperLookup(atBlock)); bytes32 right = bytes32(_treeNodes[session][j | 1].upperLookup(atBlock)); - currentLevel[i] = Hashes.efficientKeccak256(left, right); + bytes32 leftHash = Hashes.efficientKeccak256(left); + bytes32 rightHash = Hashes.efficientKeccak256(right); + + currentLevel[i] = Hashes.efficientKeccak256(leftHash, rightHash); unchecked { ++i; } } @@ -89,7 +92,8 @@ abstract contract Weaver is IWeaver { uint256 i; for (; i < currentLevelCount;) { - currentLevel[i] = bytes32(_treeNodes[session][i].upperLookup(atBlock)); + bytes32 leaf = bytes32(_treeNodes[session][i].upperLookup(atBlock)); + currentLevel[i] = Hashes.efficientKeccak256(leaf); unchecked { ++i; } } @@ -144,6 +148,6 @@ abstract contract Weaver is IWeaver { } function _computeArgumentsHash(uint256 i, uint256 a, bytes32 r) internal pure returns (bytes32) { - return Hashes.efficientKeccak256(bytes32(i), Hashes.efficientKeccak256(bytes32(a), r)); + return Hashes.efficientKeccak256(Hashes.efficientKeccak256(bytes32(a), r), bytes32(i)); } } diff --git a/test/gatekeeper/GatekeeperWeaver.t.sol b/test/gatekeeper/GatekeeperWeaver.t.sol index f805412..44f26b3 100644 --- a/test/gatekeeper/GatekeeperWeaver.t.sol +++ b/test/gatekeeper/GatekeeperWeaver.t.sol @@ -76,6 +76,8 @@ contract GatekeeperVerification is Gatekeeper { unchecked { ++i; } } + computedHash = Hashes.efficientKeccak256(computedHash); + i = 0; for (; i < proof.length; ) { if (slotIndex % 2 == 0) {