6 #ifndef PIVX_SAPLING_INCREMENTALMERKLETREE_H
7 #define PIVX_SAPLING_INCREMENTALMERKLETREE_H
26 template<
typename Stream>
29 std::vector<std::vector<unsigned char>> pathBytes;
44 template<
typename Stream>
47 std::vector<std::vector<unsigned char>> pathBytes;
52 for (
size_t i = 0; i < pathBytes.size(); i++) {
54 us.
index.push_back((indexInt >> ((pathBytes.size() - 1) - i)) & 1);
64 template<
size_t Depth,
typename Hash>
69 return Hash::EmptyRoot(depth);
71 template <
size_t D,
typename H>
78 template<
size_t Depth,
typename Hash>
84 template<
size_t Depth,
typename Hash>
85 class IncrementalWitness;
87 template<
size_t Depth,
typename Hash>
107 return root(Depth, std::deque<Hash>());
117 READWRITE(obj.left, obj.right, obj.parents);
125 template <
size_t D,
typename H>
136 MerklePath path(std::deque<Hash> filler_hashes = std::deque<Hash>())
const;
137 Hash root(
size_t depth, std::deque<Hash> filler_hashes = std::deque<Hash>())
const;
143 template<
size_t Depth,
typename Hash>
152 template <
size_t Depth,
typename Hash>
171 return tree.size() - 1;
182 READWRITE(obj.tree, obj.filled, obj.cursor);
183 SER_READ(obj, obj.cursor_depth = obj.tree.next_depth(obj.filled.size()));
186 template <
size_t D,
typename H>
199 template<
size_t Depth,
typename Hash>
240 template<
size_t Depth,
typename Hash>
friend bool operator==(const EmptyMerkleRoots< D, H > &a, const EmptyMerkleRoots< D, H > &b)
Hash empty_root(size_t depth) const
std::array< Hash, Depth+1 > empty_roots
size_t DynamicMemoryUsage() const
MerklePath path(std::deque< Hash > filler_hashes=std::deque< Hash >()) const
size_t next_depth(size_t skip) const
friend class IncrementalWitness< Depth, Hash >
BOOST_STATIC_ASSERT(Depth >=1)
friend bool operator==(const IncrementalMerkleTree< D, H > &a, const IncrementalMerkleTree< D, H > &b)
bool is_complete(size_t depth=Depth) const
std::vector< Optional< Hash > > parents
static EmptyMerkleRoots< Depth, Hash > emptyroots
IncrementalWitness< Depth, Hash > witness() const
SERIALIZE_METHODS(IncrementalMerkleTree, obj)
friend bool operator==(const IncrementalWitness< D, H > &a, const IncrementalWitness< D, H > &b)
SERIALIZE_METHODS(IncrementalWitness, obj)
uint64_t position() const
std::vector< Hash > filled
Optional< IncrementalMerkleTree< Depth, Hash > > cursor
IncrementalWitness(IncrementalMerkleTree< Depth, Hash > tree)
IncrementalMerkleTree< Depth, Hash > tree
std::deque< Hash > partial_path() const
void Unserialize(Stream &s)
void Serialize(Stream &s) const
std::vector< bool > index
std::vector< std::vector< bool > > authentication_path
MerklePath(std::vector< std::vector< bool >> authentication_path, std::vector< bool > index)
static PedersenHash combine(const PedersenHash &a, const PedersenHash &b, size_t depth)
static PedersenHash EmptyRoot(size_t)
PedersenHash(uint256 contents)
static PedersenHash uncommitted()
static SHA256Compress EmptyRoot(size_t)
static SHA256Compress uncommitted()
static SHA256Compress combine(const SHA256Compress &a, const SHA256Compress &b, size_t depth)
SHA256Compress(uint256 contents)
uint256 Hash(const T1 pbegin, const T1 pend)
Compute the 256-bit hash of an object.
libzcash::IncrementalMerkleTree< SAPLING_INCREMENTAL_MERKLE_TREE_DEPTH, libzcash::PedersenHash > SaplingMerkleTree
libzcash::IncrementalWitness< INCREMENTAL_MERKLE_TREE_DEPTH_TESTING, libzcash::PedersenHash > SaplingTestingWitness
libzcash::IncrementalMerkleTree< INCREMENTAL_MERKLE_TREE_DEPTH_TESTING, libzcash::PedersenHash > SaplingTestingMerkleTree
libzcash::IncrementalWitness< SAPLING_INCREMENTAL_MERKLE_TREE_DEPTH, libzcash::PedersenHash > SaplingWitness
bool operator==(const EmptyMerkleRoots< Depth, Hash > &a, const EmptyMerkleRoots< Depth, Hash > &b)
boost::optional< T > Optional
Substitute for C++17 std::optional.
uint64_t convertVectorToInt(const std::vector< bool > &v)
std::vector< bool > convertBytesVectorToVector(const std::vector< unsigned char > &bytes)
#define SER_READ(obj, code)