void Secp256k1PP::decrypt(Secret const& _k, bytes& io_text) { CryptoPP::ECIES<CryptoPP::ECP>::Decryptor d; initializeDLScheme(_k, d); if (!io_text.size()) { io_text.resize(1); io_text[0] = 0; } size_t clen = io_text.size(); bytes plain; plain.resize(d.MaxPlaintextLength(io_text.size())); DecodingResult r; { Guard l(x_rng); r = d.Decrypt(m_rng, io_text.data(), clen, plain.data()); } if (!r.isValidCoding) { io_text.clear(); return; } io_text.resize(r.messageLength); io_text = std::move(plain); }
void Secp256k1PP::decrypt(Secret const& _k, bytes& io_text) { auto& ctx = Secp256k1PPCtx::get(); #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" CryptoPP::ECIES<CryptoPP::ECP>::Decryptor d; #pragma GCC diagnostic pop #pragma clang diagnostic pop { Guard l(ctx.x_params); d.AccessKey().Initialize(ctx.m_params, secretToExponent(_k)); } if (!io_text.size()) { io_text.resize(1); io_text[0] = 0; } size_t clen = io_text.size(); bytes plain; plain.resize(d.MaxPlaintextLength(io_text.size())); CryptoPP::DecodingResult r; { Guard l(ctx.x_rng); r = d.Decrypt(ctx.m_rng, io_text.data(), clen, plain.data()); } if (!r.isValidCoding) { io_text.clear(); return; } io_text.resize(r.messageLength); io_text = std::move(plain); }