fn serialize()

in src/proof.rs [432:452]


    fn serialize(&self) -> Vec<u8> {
        // Check if the number of leaves is the same as the number of indexes.
        if self.merkle_proof.indexes.len() != self.leaves.len() {
            panic!("The number of indexes doesn't match with the number of leaves");
        }

        let mut bytes: Vec<u8> = Vec::new();
        bytes.append(&mut TreeIndex::serialize(&[self.index])); // Encode the tree indexes.
        bytes.append(&mut usize_to_bytes(
            self.padding_proofs.len(),
            PADDING_NUM_BYTE_NUM,
        )); // Encode the padding_num.
        for item in &self.padding_proofs {
            bytes.append(&mut V::PaddingProof::serialize(&item)); // Encode the padding proofs.
        }
        bytes.append(&mut self.merkle_proof.serialize()); // Encode the Merkle proof.
        for item in &self.leaves {
            bytes.append(&mut V::ProofNode::serialize(&item)); // Encode the leaves.
        }
        bytes
    }