Skip to main content

ancestry_proof_positions

Function ancestry_proof_positions 

pub fn ancestry_proof_positions(
    prev_mmr_size: u64,
    mmr_size: u64,
) -> Result<Vec<u64>, Error>
Expand description

The positions of the items MMR::gen_ancestry_proof(prev_mmr_size) emits for an MMR of mmr_size nodes, in proof order — the exact positions its prev_peaks_proof carries, including the single item that stands for a bagged run of right-hand peaks.

An MMR’s shape is fixed by its size, so this is a pure function of the two sizes and needs no store. A verifier that receives an ancestry proof as bare hashes can re-derive their positions with it and hand (position, hash) pairs to NodeMerkleProof.

Verifier-facing, so bad sizes are a CorruptedProof, as the verifiers report them: both must be valid MMR sizes, and prev_mmr_size non-zero and at most mmr_size. gen_ancestry_proof shares the layout below but not these checks. Any u64 sizes are cheap: the result has at most 63 positions.