Compare commits

..

2 Commits

Author SHA1 Message Date
6998355887
mocked implementation of weaver logic
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2026-07-30 22:12:27 +03:00
253a6314e0
hashing for tree leaves added
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2026-07-30 22:11:29 +03:00
3 changed files with 29 additions and 3 deletions

20
src/mocks/WeaverMock.sol Normal file
View File

@ -0,0 +1,20 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Weaver} from "../types/Weaver.sol";
contract WeaverMock is Weaver {
constructor() Weaver() {}
function insertTreeNode(bytes32 receiver, uint256 amount) external returns (uint256) {
return _insertTreeNode(receiver, amount);
}
function computeArgumentsHash(
uint256 index,
uint256 amount,
bytes32 receiver
) external pure returns (bytes32) {
return _computeArgumentsHash(index, amount, receiver);
}
}

View File

@ -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));
}
}

View File

@ -76,6 +76,8 @@ contract GatekeeperVerification is Gatekeeper {
unchecked { ++i; }
}
computedHash = Hashes.efficientKeccak256(computedHash);
i = 0;
for (; i < proof.length; ) {
if (slotIndex % 2 == 0) {