MCPcopy Create free account
hub / github.com/ElementsProject/elements / PolyMod

Function PolyMod

src/script/descriptor.cpp:84–94  ·  view source on GitHub ↗

* Interprets c as 8 groups of 5 bits which are the coefficients of a degree 8 polynomial over GF(32), * multiplies that polynomial by x, computes its remainder modulo a generator, and adds the constant term val. * * This generator is G(x) = x^8 + {30}x^7 + {23}x^6 + {15}x^5 + {14}x^4 + {10}x^3 + {6}x^2 + {12}x + {9}. * It is chosen to define an cyclic error detecting code which is selected by:

Source from the content-addressed store, hash-verified

82 * print("0x%x" % v)
83 */
84uint64_t PolyMod(uint64_t c, int val)
85{
86 uint8_t c0 = c >> 35;
87 c = ((c & 0x7ffffffff) << 5) ^ val;
88 if (c0 & 1) c ^= 0xf5dee51989;
89 if (c0 & 2) c ^= 0xa9fdca3312;
90 if (c0 & 4) c ^= 0x1bab10e32d;
91 if (c0 & 8) c ^= 0x3706b1677a;
92 if (c0 & 16) c ^= 0x644d626ffd;
93 return c;
94}
95
96std::string DescriptorChecksum(const Span<const char>& span)
97{

Callers 3

DescriptorChecksumFunction · 0.70
BOOST_AUTO_TEST_CASEFunction · 0.50
BOOST_AUTO_TEST_CASEFunction · 0.50

Calls

no outgoing calls

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.40
BOOST_AUTO_TEST_CASEFunction · 0.40