MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / CreateChecksum

Function CreateChecksum

src/bech32.cpp:128–139  ·  view source on GitHub ↗

Create a checksum. */

Source from the content-addressed store, hash-verified

126
127/** Create a checksum. */
128data CreateChecksum(const std::string& hrp, const data& values)
129{
130 data enc = Cat(ExpandHRP(hrp), values);
131 enc.resize(enc.size() + 6); // Append 6 zeroes
132 uint32_t mod = PolyMod(enc) ^ 1; // Determine what to XOR into those 6 zeroes.
133 data ret(6);
134 for (size_t i = 0; i < 6; ++i) {
135 // Convert the 5-bit groups in mod to checksum values.
136 ret[i] = (mod >> (5 * (5 - i))) & 31;
137 }
138 return ret;
139}
140
141} // namespace
142

Callers 1

EncodeFunction · 0.85

Calls 5

CatFunction · 0.85
ExpandHRPFunction · 0.85
PolyModFunction · 0.85
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected