Skip to main content

verify_block_slice

Function verify_block_slice 

Source
pub fn verify_block_slice(
    slice: &[u8],
    address: &[u8; 32],
    content_len: u64,
    index: u32,
) -> Option<Vec<u8>>
Expand description

Verify a Bao slice for block index against the chunk address (BLAKE3(content)), returning the verified block bytes (auditor, round 2).

content_len is the responder’s round-1 claim. It is NOT bound by the signed commitment (the Merkle leaf hashes only key ‖ bytes_hash), so a malicious responder can claim any length. Left unchecked, a deflation lie forges possession: claiming content_len = 1024 for a 4 MiB chunk collapses block_count to 1, so the auditor can only ever open block 0, and a Bao slice for the prefix range [0, 1024) verifies fine against the true full-content address — a node storing ~1 KiB passes an audit for the whole chunk. To close this, the slice’s own authenticated length header (which the decoder validates against address, so it equals the true content length) must match the claimed content_len. A responder that lies about the length then either fails the header check (claim ≠ true length) or is forced to report the true length — in which case the block index is drawn from the full range and possession of all blocks is required.