Remove the Merkle tree hash function's fixed point.
This commit is contained in:
@@ -31,6 +31,22 @@ public:
|
||||
: authentication_path(authentication_path), index(index) { }
|
||||
};
|
||||
|
||||
template<size_t Depth, typename Hash>
|
||||
class EmptyMerkleRoots {
|
||||
public:
|
||||
EmptyMerkleRoots() {
|
||||
empty_roots.at(0) = Hash();
|
||||
for (size_t d = 1; d <= Depth; d++) {
|
||||
empty_roots.at(d) = Hash::combine(empty_roots.at(d-1), empty_roots.at(d-1));
|
||||
}
|
||||
}
|
||||
Hash empty_root(size_t depth) {
|
||||
return empty_roots.at(depth);
|
||||
}
|
||||
private:
|
||||
boost::array<Hash, Depth+1> empty_roots;
|
||||
};
|
||||
|
||||
template<size_t Depth, typename Hash>
|
||||
class IncrementalWitness;
|
||||
|
||||
@@ -64,7 +80,12 @@ public:
|
||||
wfcheck();
|
||||
}
|
||||
|
||||
static Hash empty_root() {
|
||||
return emptyroots.empty_root(Depth);
|
||||
}
|
||||
|
||||
private:
|
||||
static EmptyMerkleRoots<Depth, Hash> emptyroots;
|
||||
boost::optional<Hash> left;
|
||||
boost::optional<Hash> right;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user