computeProofRoot
Folds a run of base-layer hashes into their subtree root, then walks the proofLayers (uncle / sibling) hashes upward, computing the implied tree root. Pure function: it does not consult or mutate any existing tree, it just computes what root these hashes claim. Compare the returned root against the known file root to accept or reject the proof.
This is the computation behind libtorrent's merkle_validate_and_insert_proofs (here separated from the tree-insertion side effects so it can be reused by both stateless verifyProof and the in-tree path in MerkleTree).
The subtree of baseHashes is padded up to a power of two with padHash (default the all-zero block pad). The first base hash sits at flat index startIndex within the base layer; only its low bit matters at each step to know whether the uncle hash is the left or right sibling.
Parameters
the contiguous run of known hashes at the base layer (block or piece layer). Must be non-empty.
offset of the first base hash within its layer (>= 0). Used to determine left/right sibling parity as we climb.
the uncle (sibling) hashes, bottom-up, one per level from the subtree root toward the file root. May be empty when the base subtree is the whole tree.
the pad hash for the base layer (default SHA-256(0)).