# Merkle Tree Lib API Reference Doc
## MerkleTree
**MerkleTree**(hash_function: callable, automake: bool = True, aggregateLeafs: (bool, List[type] List[callable]) = , fixed_depth: (bool, bool, int), prefilled: bool, default_vector: List[AnyImmutable])
### Parameters
**hash_function**: hash function used by the Merkle Tree
**automake**: Compute the Merkle Tree at every commitment
**aggregateLeafs**: Assuming same vector format at every leafs, commit children and the added value point-wise of the children.
* First parameter give True/False if the user needs the option.
* Second parameter gives the expected variable type at every position.
* Third parameter gives the function to compute the children values on.
**fixed_depth**: Gives the ability to define a dynamic or fixed sized tree.
* First parameter give True/False if the user wants a fixed size
* Second parameter gives the right to increase/decrease the size later
* Third parameter gives the depth if the Tree is of fixed size
**prefilled**: Gives the ability to define a tree is prefilled with a default vector
**default_vector**: Provides for a prefilled tree the default vector. It can be a singleton or an Iterable of Immutables variables.
---
## MerkleMountainRange
**MerkleMountainRange**(hash_function: callable, automake: bool, aggregateLeafs: bool)
NB: All peaks will be MerkleTreeObjects
Could be implemented:
> SpeaksCommitmentStrategy: An optimization to consider is to commit to both a Tree depending on the number of peaks: A chainhash, a merkle tree or a mix of the two
>
---
### Method
**add**(anyListImmutables) -> add a leaf and turn isReady to False
**addAtIndex**(anyListImmutables, index: int) -> add a leaf at specific index and turn isReady to False
**update**(anyListImmutables, index: int) -> modify a leaf and turn isReady to False
**remove**(index: int) -> burn a leaf and goes to default vector and turn isReady to False
**size** -> number of leafs
**reset**() -> empty a tree and turn isReady to False
**resetSubTree**(depth: int, index: int) -> empty a subtree at depth and index and turn isReady to False
**make**() -> compute tree and turn isReady to True
**isReady** -> Bool: MerkleTree has been constructed
**root** -> get Merkle Root. Raise Error if not make()
**getPath**(index: int) -> provide Path to root
**getBatchPaths**(indexes: List[int]) -> provide path to root
**verifyPath**(index: int, path: List[anyListImmutables]) -> check path to root
**batchVerifyPaths**(indexes: List[int], paths: List[List[anyListImmutables]])-> verify multiple paths at the same time
**decommitAtIndex**(index: int) -> returns the committed vector
**extractNode**(depth: int, index: int) -> Get a specific node from the tree. Return an object from the same class than the parent
**lastIndex** -> Return the last entry index
**print**() -> Displey a representation of the tree
**convertToMerkleTree**(default_vector: List[AnyImmutable]) -> turn a Merkle Mountain range into a Merkle Tree
**serialize**() -> Store an object
**unserialize**() -> Load an object
### Merkle Tree Specific Methods
**convertToMerkleMountainRange**() -> turn a Merkle Tree into a Merkle Mountain Range
**expand**(new_depth:int) -> turn a Merkle Tree into a subtree of a default vector filled tree
### Merkle Mountain Range Specific Methods
**extractPeaks**() -> output peaks
### Helpers
**concat**(trees: List[MerkleTreesObjects]) -> Turn a list of Merkle Tree into a MerkleTree
---
## Elkrem
**Elkrem**(hash_function: callable, entropy: AnyImmutable = secret.token_bytes(32), depth: int = 32)
### Parameters
**entropy**: Provides the seed
**depth**: defined the max number of secrets as 2^depth
---