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

Function addnextract2

src/crypto/muhash.cpp:96–114  ·  view source on GitHub ↗

* Add limb a to [c0,c1]: [c0,c1] += a. Then extract the lowest * limb of [c0,c1] into n, and left shift the number by 1 limb. * */

Source from the content-addressed store, hash-verified

94 * limb of [c0,c1] into n, and left shift the number by 1 limb.
95 * */
96inline void addnextract2(limb_t& c0, limb_t& c1, const limb_t& a, limb_t& n)
97{
98 limb_t c2 = 0;
99
100 // add
101 c0 += a;
102 if (c0 < a) {
103 c1 += 1;
104
105 // Handle case when c1 has overflown
106 if (c1 == 0)
107 c2 = 1;
108 }
109
110 // extract
111 n = c0;
112 c0 = c1;
113 c1 = c2;
114}
115
116/** in_out = in_out^(2^sq) * mul */
117inline void square_n_mul(Num3072& in_out, const int sq, const Num3072& mul)

Callers 3

FullReduceMethod · 0.85
MultiplyMethod · 0.85
SquareMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected