| 231 | } |
| 232 | |
| 233 | void 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 | } |
nothing calls this directly
no test coverage detected