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

Method GetInverse

src/crypto/muhash.cpp:144–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144Num3072 Num3072::GetInverse() const
145{
146 // For fast exponentiation a sliding window exponentiation with repunit
147 // precomputation is utilized. See "Fast Point Decompression for Standard
148 // Elliptic Curves" (Brumley, Järvinen, 2008).
149
150 Num3072 p[12]; // p[i] = a^(2^(2^i)-1)
151 Num3072 out;
152
153 p[0] = *this;
154
155 for (int i = 0; i < 11; ++i) {
156 p[i + 1] = p[i];
157 for (int j = 0; j < (1 << i); ++j) p[i + 1].Square();
158 p[i + 1].Multiply(p[i]);
159 }
160
161 out = p[11];
162
163 square_n_mul(out, 512, p[9]);
164 square_n_mul(out, 256, p[8]);
165 square_n_mul(out, 128, p[7]);
166 square_n_mul(out, 64, p[6]);
167 square_n_mul(out, 32, p[5]);
168 square_n_mul(out, 8, p[3]);
169 square_n_mul(out, 2, p[1]);
170 square_n_mul(out, 1, p[0]);
171 square_n_mul(out, 5, p[2]);
172 square_n_mul(out, 3, p[0]);
173 square_n_mul(out, 2, p[0]);
174 square_n_mul(out, 4, p[0]);
175 square_n_mul(out, 4, p[1]);
176 square_n_mul(out, 3, p[0]);
177
178 return out;
179}
180
181void Num3072::Multiply(const Num3072& a)
182{

Callers 1

DivideMethod · 0.80

Calls 3

square_n_mulFunction · 0.85
SquareMethod · 0.80
MultiplyMethod · 0.80

Tested by

no test coverage detected