fileRoot

fun fileRoot(blockLeaves: List<Sha256Hash>): Sha256Hash

Builds a file's BitTorrent v2 merkle root from its 16 KiB-block SHA-256 leaf hashes. This is the clear top-level entry point a v2 download / torrent creator uses: pass the file's block hashes in order and get the pieces root that ends up in the .torrent.

The leaf count is padded up to the next power of two with zero-hashes (SHA-256(0) at the block layer, folded up the implied padding). This is exactly merkleRoot with the block-layer pad, provided under an explicit name so call sites read clearly. Mirrors merkle_root(leaves).

Parameters

blockLeaves

the file's per-16-KiB-block SHA-256 hashes, in order. Must be non-empty.