Kata for implementing a Merkle Tree class:
A Merkle Tree is a data structure used by Bitcoin and other P2P systems.
- A document will be represented as an string.
- We want to split the document in chunks of N characters and send each chunk separately.
- We are going to use a Merkle root for document integrity validation.
- We always use a pair number of chunks (leaf nodes in the tree). If the number is odd, we have to duplicate the last one.
- We need generate the Merkle root of a document.
- The hash function will be h(x) = xx.
- Allow changing hash function.
- The initial array of chunks is very big and we want to build the tree passing one chuck at a time.
- Given a MerkleTree and a chunk we want to check if that chunk is valid.
- We want to validate a chunk without using the entire MerkleTree. We want to calculate the minimum branch needed to validate a chunk, and use that branch to validate a chunk.