A class representing MuHash sets * * MuHash is a hashing algorithm that supports adding set elements in any * order but also deleting in any order. As a result, it can maintain a * running sum for a set of data as a whole, and add/remove when data * is added to or removed from it. A downside of MuHash is that computing * an inverse is relatively expensive. This is solved by representing * t
| 92 | * https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-May/014337.html. |
| 93 | */ |
| 94 | class MuHash3072 |
| 95 | { |
| 96 | private: |
| 97 | Num3072 m_numerator; |
| 98 | Num3072 m_denominator; |
| 99 | |
| 100 | Num3072 ToNum3072(Span<const unsigned char> in); |
| 101 | |
| 102 | public: |
| 103 | /* The empty set. */ |
| 104 | MuHash3072() noexcept {}; |
| 105 | |
| 106 | /* A singleton with variable sized data in it. */ |
| 107 | explicit MuHash3072(Span<const unsigned char> in) noexcept; |
| 108 | |
| 109 | /* Insert a single piece of data into the set. */ |
| 110 | MuHash3072& Insert(Span<const unsigned char> in) noexcept; |
| 111 | |
| 112 | /* Remove a single piece of data from the set. */ |
| 113 | MuHash3072& Remove(Span<const unsigned char> in) noexcept; |
| 114 | |
| 115 | /* Multiply (resulting in a hash for the union of the sets) */ |
| 116 | MuHash3072& operator*=(const MuHash3072& mul) noexcept; |
| 117 | |
| 118 | /* Divide (resulting in a hash for the difference of the sets) */ |
| 119 | MuHash3072& operator/=(const MuHash3072& div) noexcept; |
| 120 | |
| 121 | /* Finalize into a 32-byte hash. Does not change this object's value. */ |
| 122 | void Finalize(uint256& out) noexcept; |
| 123 | |
| 124 | SERIALIZE_METHODS(MuHash3072, obj) |
| 125 | { |
| 126 | READWRITE(obj.m_numerator); |
| 127 | READWRITE(obj.m_denominator); |
| 128 | } |
| 129 | }; |
| 130 | |
| 131 | #endif // BITCOIN_CRYPTO_MUHASH_H |
no outgoing calls