Bitcoin ABC  0.29.2
P2P Digital Currency
compactproofs.cpp
Go to the documentation of this file.
1 // Copyright (c) 2022 The Bitcoin developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
6 
7 #include <avalanche/proofid.h>
8 #include <crypto/siphash.h>
9 
10 namespace avalanche {
11 
14  : CompactProofs() {
15  proofs.forEachLeaf([&](auto pLeaf) {
16  shortproofids.push_back(getShortID(pLeaf->getId()));
17  return true;
18  });
19 }
20 
21 uint64_t CompactProofs::getShortID(const ProofId &proofid) const {
22  static_assert(SHORTPROOFIDS_LENGTH == 6,
23  "shortproofids calculation assumes 6-byte shortproofids");
24  return SipHashUint256(shortproofidk0, shortproofidk1, proofid) &
25  0xffffffffffffL;
26 }
27 
28 } // namespace avalanche
uint64_t getShortID(const ProofId &proofid) const
std::vector< uint64_t > shortproofids
Definition: compactproofs.h:57
static constexpr int SHORTPROOFIDS_LENGTH
Definition: compactproofs.h:61
uint64_t SipHashUint256(uint64_t k0, uint64_t k1, const uint256 &val)
Optimized SipHash-2-4 implementation for uint256.
Definition: siphash.cpp:99
bool forEachLeaf(Callable &&func) const
Definition: radix.h:144