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

Function CreateChecksum

src/bech32.cpp:342–353  ·  view source on GitHub ↗

Create a checksum. */

Source from the content-addressed store, hash-verified

340
341/** Create a checksum. */
342data CreateChecksum(Encoding encoding, const std::string& hrp, const data& values)
343{
344 auto enc = PreparePolynomialCoefficients(hrp, values);
345 enc.insert(enc.end(), CHECKSUM_SIZE, 0x00);
346 uint32_t mod = PolyMod(enc) ^ EncodingConstant(encoding); // Determine what to XOR into those 6 zeroes.
347 data ret(CHECKSUM_SIZE);
348 for (size_t i = 0; i < CHECKSUM_SIZE; ++i) {
349 // Convert the 5-bit groups in mod to checksum values.
350 ret[i] = (mod >> (5 * (5 - i))) & 31;
351 }
352 return ret;
353}
354
355} // namespace
356

Callers 1

EncodeFunction · 0.85

Calls 5

EncodingConstantFunction · 0.85
PolyModFunction · 0.70
insertMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected