From 16006babb76c7482e9ed88730360e00e792f19a3 Mon Sep 17 00:00:00 2001 From: Uncle Stretch Date: Tue, 8 Sep 2026 22:08:12 +0300 Subject: [PATCH] use prefixes for the merkle tree Signed-off-by: Uncle Stretch --- README.md | 25 +++++++++++++++++-------- forester.py | 7 ++++--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 07d550f..5162b12 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,15 @@ pip install web3 tqdm The Ghost Preclaim Snapshot Tool provides a straightforward command-line interface for collecting NFT snapshot data across multiple blockchain networks. Before running the tool, ensure you have properly configured your environment with the necessary RPC endpoints and network access credentials. ```bash -python finder.py --rpc [--delay 0.3] -``` +usage: finder.py [-h] --rpc RPC [--bonus BONUS] [--delay DELAY] -Parameters: -```bash ---rpc: EVM JSON-RPC endpoint URL ---delay: (Optional) Delay between RPC requests in seconds (default: 0.3) +EVM NFT Snapshot Collector for Ghostchain Preclaims + +options: + -h, --help show this help message and exit + --rpc RPC EVM JSON-RPC Node URL + --bonus BONUS Additional JML ownership amounton top of the collateral (default: 6.9 CSPR) + --delay DELAY Delay between RPC requests in seconds (default: 0.3) ``` Example: @@ -38,13 +40,20 @@ python finder.py --rpc https://sepolia.infura.io/v3/YOUR_KEY The Merkle proof generation module transforms raw snapshot data into cryptographically verifiable proofs that enable efficient and secure preclaim verification on the Ghostchain governance platform. This critical component ensures that only legitimate NFT holders can participate in governance decisions and claim their allocations. ```bash -python forester.py --chain +usage: forester.py [-h] --network-id NETWORK_ID + +Dynamic Merkle Tree for Ghost Preclaims + +options: + -h, --help show this help message and exit + --network-id NETWORK_ID + EVM numeric Network ID to mix into preimage (e.g., 11155111) ``` Example: ```bash -python forester.py --chain 11155111 +python forester.py --network-id 11155111 ``` Output: diff --git a/forester.py b/forester.py index 70fb63c..3054a26 100644 --- a/forester.py +++ b/forester.py @@ -17,7 +17,8 @@ def parse_arguments(): def keccak256(data: bytes) -> bytes: return keccak(data) -EMPTY_HASH = keccak256(b'') +# prefix + empty bytes +EMPTY_HASH = keccak256(b'\x00' + b'\x00' * 32) def next_power_of_two(n: int) -> int: if n <= 1: @@ -47,7 +48,7 @@ def generate_tree(raw_values, network_id): for item in raw_values: idx = item['index'] preimage = generate_preimage(item['token_id'], item['address'], item['shares'], network_id) - merkle_tree[idx] = keccak256(preimage) + merkle_tree[idx] = keccak256(b'\x00' + preimage) layer_start = 0 current_layer_len = padded_leaves @@ -59,7 +60,7 @@ def generate_tree(raw_values, network_id): left_bytes = merkle_tree[layer_index] right_bytes = merkle_tree[layer_index | 1] - combined = left_bytes + right_bytes + combined = b'\x01' + left_bytes + right_bytes merkle_tree[write_ptr] = keccak256(combined) write_ptr += 1