Reproduce Arweave's Merkle chunk split near a short tail

An uploader that slices every file into rigid 256 KiB pieces can compute a different data root from arweave-js for payloads just above that size.

Apply the final-pair adjustment

For 260 KiB, a full first chunk would leave only 4 KiB. The reference algorithm detects a positive remainder smaller than 32 KiB and divides the remaining bytes into two nearly equal pieces. In this case both pieces contain exactly 133,120 bytes. Preserve the byte ranges when constructing Merkle leaves.

input = 266240 bytes (260 KiB)
naive split = 262144 + 4096
reference split = 133120 + 133120

Cross-check the root

Generate the same deterministic file in both implementations and compare chunk boundaries before comparing the root. If boundaries agree but roots differ, inspect leaf hashing and offset encoding. This example exercises the short-tail branch; exact multiples and empty inputs need their own reference vectors.

Sources