diff --git a/libzerocash/IncrementalMerkleTree.cpp b/libzerocash/IncrementalMerkleTree.cpp index 7633dc3..17084a6 100644 --- a/libzerocash/IncrementalMerkleTree.cpp +++ b/libzerocash/IncrementalMerkleTree.cpp @@ -25,7 +25,7 @@ namespace libzerocash { // IncrementalMerkleTreeCompact class ///////////////////////////////////////////// - std::vector IncrementalMerkleTreeCompact::serialize() { + std::vector IncrementalMerkleTreeCompact::serialize() const { /* Serialization format: * treeHeight (4 bytes, big endian) * hashList (ceil(treeHeight / 8) bytes) @@ -203,7 +203,7 @@ namespace libzerocash { } bool - IncrementalMerkleTree::getRootValue(std::vector& r) { + IncrementalMerkleTree::getRootValue(std::vector& r) const { // Query the root for its hash this->root.getValue(r); @@ -211,7 +211,7 @@ namespace libzerocash { } bool - IncrementalMerkleTree::getRootValue(std::vector& r) { + IncrementalMerkleTree::getRootValue(std::vector& r) const { // Create a temporary byte vector std::vector tempR(r.size() * 8, 0); diff --git a/libzerocash/IncrementalMerkleTree.h b/libzerocash/IncrementalMerkleTree.h index 0b4b0ef..9d1ae1f 100644 --- a/libzerocash/IncrementalMerkleTree.h +++ b/libzerocash/IncrementalMerkleTree.h @@ -45,7 +45,7 @@ class IncrementalMerkleTreeCompact { std::vector< std::vector > const& getHashVec() { return hashVec; } std::vector< bool > const& getHashList() { return hashList; } - std::vector serialize(); + std::vector serialize() const; static IncrementalMerkleTreeCompact deserialize(const std::vector& serialized); private: @@ -84,8 +84,8 @@ class IncrementalMerkleNode { bool isPruned() const { return subtreePruned; } bool hasFreeLeaves() const { return (!subtreeFull); } bool hasRightChildren() const { if (!right) return false; return true; } - void getValue(std::vector &r) { r = value; } - std::vector& getValue() { return value; } + void getValue(std::vector &r) const { r = value; } + const std::vector& getValue() const { return value; } bool checkIfNodeFull(); void updateHashValue(); @@ -115,12 +115,12 @@ class IncrementalMerkleTree { bool insertElement(const std::vector &hashV, std::vector &index); bool insertVector(std::vector< std::vector > &valueVector); bool getWitness(const std::vector &index, merkle_authentication_path &witness); - bool getRootValue(std::vector& r); - bool getRootValue(std::vector& r); + bool getRootValue(std::vector& r) const; + bool getRootValue(std::vector& r) const; std::vectorgetRoot(); bool prune(); IncrementalMerkleTreeCompact getCompactRepresentation() const; - std::vector serialize() { + std::vector serialize() const { auto compact = getCompactRepresentation(); return compact.serialize(); }