2121#include < vector>
2222
2323#include " scl/bitmap.h"
24+ #include " scl/primitives/hash.h"
2425#include " scl/primitives/merkle_proof.h"
2526
2627namespace scl {
@@ -31,7 +32,7 @@ namespace scl {
3132 * @tparam T the leaf data type.
3233 * @TODO: Switch LEAF and HASH; Default Hash to scl::Hash<256>.
3334 */
34- template <typename HASH , typename LEAF >
35+ template <typename LEAF , typename HASH = Hash< 256 > >
3536struct MerkleTree {
3637 /* *
3738 * @brief The digest type nodes.
@@ -70,8 +71,8 @@ struct MerkleTree {
7071 static std::vector<DigestType> hashLeafs (const std::vector<LEAF>& data);
7172};
7273
73- template <typename HASH , typename LEAF >
74- auto MerkleTree<HASH, LEAF >::hashLeafs(const std::vector<LEAF>& data)
74+ template <typename LEAF , typename HASH >
75+ auto MerkleTree<LEAF, HASH >::hashLeafs(const std::vector<LEAF>& data)
7576 -> std::vector<DigestType> {
7677 std::vector<DigestType> digests;
7778 auto sz = data.size ();
@@ -91,8 +92,8 @@ auto MerkleTree<HASH, LEAF>::hashLeafs(const std::vector<LEAF>& data)
9192 return digests;
9293}
9394
94- template <typename HASH , typename LEAF >
95- auto MerkleTree<HASH, LEAF >::hash(const std::vector<LEAF>& data) -> DigestType {
95+ template <typename LEAF , typename HASH >
96+ auto MerkleTree<LEAF, HASH >::hash(const std::vector<LEAF>& data) -> DigestType {
9697 std::vector<DigestType> digests = hashLeafs (data);
9798
9899 auto sz = digests.size ();
@@ -119,8 +120,8 @@ auto MerkleTree<HASH, LEAF>::hash(const std::vector<LEAF>& data) -> DigestType {
119120 return digests[0 ];
120121}
121122
122- template <typename HASH , typename LEAF >
123- auto MerkleTree<HASH, LEAF >::prove(const std::vector<LEAF>& data,
123+ template <typename LEAF , typename HASH >
124+ auto MerkleTree<LEAF, HASH >::prove(const std::vector<LEAF>& data,
124125 std::size_t index) -> Proof {
125126 std::vector<DigestType> digests = hashLeafs (data);
126127 std::vector<DigestType> path;
@@ -161,8 +162,8 @@ auto MerkleTree<HASH, LEAF>::prove(const std::vector<LEAF>& data,
161162 return {path, Bitmap::fromStdVecBool (direction)};
162163}
163164
164- template <typename HASH , typename LEAF >
165- bool MerkleTree<HASH, LEAF >::verify(const LEAF& leaf,
165+ template <typename LEAF , typename HASH >
166+ bool MerkleTree<LEAF, HASH >::verify(const LEAF& leaf,
166167 const DigestType& root,
167168 const Proof& proof) {
168169 const auto [h, d] = proof;
0 commit comments