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

Function PolyMod

src/minisketch/src/sketch_impl.h:18–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16/** Compute the remainder of a polynomial division of val by mod, putting the result in mod. */
17template<typename F>
18void PolyMod(const std::vector<typename F::Elem>& mod, std::vector<typename F::Elem>& val, const F& field) {
19 size_t modsize = mod.size();
20 CHECK_SAFE(modsize > 0 && mod.back() == 1);
21 if (val.size() < modsize) return;
22 CHECK_SAFE(val.back() != 0);
23 while (val.size() >= modsize) {
24 auto term = val.back();
25 val.pop_back();
26 if (term != 0) {
27 typename F::Multiplier mul(field, term);
28 for (size_t x = 0; x < mod.size() - 1; ++x) {
29 val[val.size() - modsize + 1 + x] ^= mul(mod[x]);
30 }
31 }
32 }
33 while (val.size() > 0 && val.back() == 0) val.pop_back();
34}
35
36/** Compute the quotient of a polynomial division of val by mod, putting the quotient in div and the remainder in val. */
37template<typename F>

Callers 3

GCDFunction · 0.70
TraceModFunction · 0.70
RecFindRootsFunction · 0.70

Calls 3

mulFunction · 0.85
sizeMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected