Merkle Trees as a vector commitment #
This file defines the vector-style Merkle tree API: the oracle spec, the
layered cache, monadic and purely functional builders (buildMerkleTree,
buildMerkleTree_with_hash), proof generation and verification, and the
bridging simulateQ lemmas that translate the monadic operations into their
hash-function counterparts. Completeness of this construction is proven in
VCVio.CryptoFoundations.MerkleTree.Vector.Completeness.
Notes & TODOs #
We want this treatment to be as comprehensive as possible. In particular, our formalization should (eventually) include all complexities such as the following:
- Multi-instance extraction & simulation
- Dealing with arbitrary trees (may have arity > 2, or is not complete)
- Path pruning optimization
Add a base layer to the cache
Instances For
Returns the leaves of the cache
Instances For
Compute the next layer of the Merkle tree
Instances For
Get the root of the Merkle tree
Instances For
Generate a Merkle proof that a given leaf at index i is in the Merkle tree. The proof consists
of the Merkle tree nodes that are needed to recompute the root from the given leaf.
Instances For
Given a leaf index, a leaf at that index, and putative proof, returns the hash that would be the root of the tree if the proof was valid. i.e. the hash obtained by combining the leaf in sequence with each member of the proof, according to its index.
Instances For
Verify a Merkle proof proof that a given leaf at index i is in the Merkle tree with given
root.
Works by computing the putative root based on the branch, and comparing that to the actual root.
Returns true if the proof is valid, and false otherwise.
Instances For
A purely functional version of buildLayer, given an explicit hash function.
Instances For
A purely functional version of buildMerkleTree, given an explicit hash function.
Instances For
A purely functional version of getPutativeRoot, given an explicit hash function.