fn gen_cached_top_tree_proof<Arity: Unsigned>(
        &self,
        i: usize,
        rows_to_discard: Option<usize>,
    ) -> Result<Proof<E, BaseTreeArity>> {
        ensure!(Arity::to_usize() != 0, "Invalid top-tree arity");
        ensure!(
            i < self.leafs,
            "{} is out of bounds (max: {})",
            i,
            self.leafs
        ); // i in [0 .. self.leafs)

        // Locate the sub-tree the leaf is contained in.
        ensure!(self.data.sub_trees().is_some(), "sub trees required");
        let trees = &self.data.sub_trees().unwrap();
        let tree_index = i / (self.leafs / Arity::to_usize());
        let tree = &trees[tree_index];
        let tree_leafs = tree.leafs();

        // Get the leaf index within the sub-tree.
        let leaf_index = i % tree_leafs;

        // Generate the proof that will validate to the provided
        // sub-tree root (note the branching factor of B).
        let sub_tree_proof = tree.gen_cached_proof(leaf_index, rows_to_discard)?;

        // Construct the top layer proof.  'lemma' length is
        // top_layer_nodes - 1 + root == top_layer_nodes
        let mut path: Vec<usize> = Vec::with_capacity(1); // path - 1
        let mut lemma: Vec<E> = Vec::with_capacity(Arity::to_usize());
        for i in 0..Arity::to_usize() {
            if i != tree_index {
                lemma.push(trees[i].root())
            }
        }

        lemma.push(self.root());
        path.push(tree_index);

        // Generate the final compound tree proof which is composed of
        // a sub-tree proof of branching factor B and a top-level
        // proof with a branching factor of SubTreeArity.
        Proof::new::<TopTreeArity, SubTreeArity>(Some(Box::new(sub_tree_proof)), lemma, path)
    }
/// Generate merkle sub-tree inclusion proof for leaf `i` using
/// partial trees built from cached data if needed at that layer.
Generate merkle sub-tree inclusion proof for leaf `i` using
partial trees built from cached data if needed at that layer.
Generate merkle sub - tree inclusion proof for leaf ` i ` using partial trees built from cached data if needed at that layer .
fn gen_cached_top_tree_proof<Arity: Unsigned>(
        &self,
        i: usize,
        rows_to_discard: Option<usize>,
    ) -> Result<Proof<E, BaseTreeArity>> {
        ensure!(Arity::to_usize() != 0, "Invalid top-tree arity");
        ensure!(
            i < self.leafs,
            "{} is out of bounds (max: {})",
            i,
            self.leafs
        ); // i in [0 .. self.leafs)
        // Locate the sub-tree the leaf is contained in.
        ensure!(self.data.sub_trees().is_some(), "sub trees required");
        let trees = &self.data.sub_trees().unwrap();
        let tree_index = i / (self.leafs / Arity::to_usize());
        let tree = &trees[tree_index];
        let tree_leafs = tree.leafs();
        // Get the leaf index within the sub-tree.
        let leaf_index = i % tree_leafs;
        // Generate the proof that will validate to the provided
        // sub-tree root (note the branching factor of B).
        let sub_tree_proof = tree.gen_cached_proof(leaf_index, rows_to_discard)?;
        // Construct the top layer proof.  'lemma' length is
        // top_layer_nodes - 1 + root == top_layer_nodes
        let mut path: Vec<usize> = Vec::with_capacity(1); // path - 1
        let mut lemma: Vec<E> = Vec::with_capacity(Arity::to_usize());
        for i in 0..Arity::to_usize() {
            if i != tree_index {
                lemma.push(trees[i].root())
            }
        }
        lemma.push(self.root());
        path.push(tree_index);
        // Generate the final compound tree proof which is composed of
        // a sub-tree proof of branching factor B and a top-level
        // proof with a branching factor of SubTreeArity.
        Proof::new::<TopTreeArity, SubTreeArity>(Some(Box::new(sub_tree_proof)), lemma, path)
    }
fn gen_cached_top_tree_proof < Arity : Unsigned > ( & self , i : usize , rows_to_discard : Option < usize > , ) -> Result < Proof < E , BaseTreeArity > > { ensure ! ( Arity to_usize ( ) 0 " " ) ; ensure ! ( i self leafs " " i self leafs ) ; // i in [0 .. self.leafs) // Locate the sub-tree the leaf is contained in. ensure ! ( self data sub_trees ( ) is_some ( ) " " ) ; let trees = & self . data . sub_trees ( ) . unwrap ( ) ; let tree_index = i / ( self . leafs / Arity :: to_usize ( ) ) ; let tree = & trees [ tree_index ] ; let tree_leafs = tree . leafs ( ) ; // Get the leaf index within the sub-tree. let leaf_index = i % tree_leafs ; // Generate the proof that will validate to the provided // sub-tree root (note the branching factor of B). let sub_tree_proof = tree . gen_cached_proof ( leaf_index , rows_to_discard ) ? ; // Construct the top layer proof.  'lemma' length is // top_layer_nodes - 1 + root == top_layer_nodes let mut path : Vec < usize > = Vec :: with_capacity ( 1 ) ; // path - 1 let mut lemma : Vec < E > = Vec :: with_capacity ( Arity :: to_usize ( ) ) ; for i in 0 .. Arity :: to_usize ( ) { if i != tree_index { lemma . push ( trees [ i ] . root ( ) ) } } lemma . push ( self . root ( ) ) ; path . push ( tree_index ) ; // Generate the final compound tree proof which is composed of // a sub-tree proof of branching factor B and a top-level // proof with a branching factor of SubTreeArity. Proof :: new :: < TopTreeArity , SubTreeArity > ( Some ( Box :: new ( sub_tree_proof ) ) , lemma , path ) }
Generate merkle sub-tree inclusion proof for leaf `i` using
partial trees built from cached data if needed at that layer.
Generate merkle sub - tree inclusion proof for leaf ` i ` using partial trees built from cached data if needed at that layer .
&self
i
usize
rows_to_discard
Option<usize>