MCPcopy Create free account
hub / github.com/LUX-Core/lux / decrypt

Method decrypt

src/cpp-ethereum/libdevcrypto/CryptoPP.cpp:233–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233void Secp256k1PP::decrypt(Secret const& _k, bytes& io_text)
234{
235 auto& ctx = Secp256k1PPCtx::get();
236 CryptoPP::ECIES<CryptoPP::ECP>::Decryptor d;
237 {
238 Guard l(ctx.x_params);
239 d.AccessKey().Initialize(ctx.m_params, secretToExponent(_k));
240 }
241
242 if (!io_text.size())
243 {
244 io_text.resize(1);
245 io_text[0] = 0;
246 }
247
248 size_t clen = io_text.size();
249 bytes plain;
250 plain.resize(d.MaxPlaintextLength(io_text.size()));
251
252 DecodingResult r;
253 {
254 Guard l(ctx.x_rng);
255 r = d.Decrypt(ctx.m_rng, io_text.data(), clen, plain.data());
256 }
257
258 if (!r.isValidCoding)
259 {
260 io_text.clear();
261 return;
262 }
263
264 io_text.resize(r.messageLength);
265 io_text = std::move(plain);
266}

Callers

nothing calls this directly

Calls 7

secretToExponentFunction · 0.85
InitializeMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
DecryptMethod · 0.45
dataMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected