[#wallet-DecryptKey]
= xref:wallet.adoc[wallet]::DecryptKey
:relfileprefix: ../
:mrdocs:

Decrypts an encrypted private key and validates it against its public key&period;

== Synopsis

Declared in `&lt;wallet&sol;crypter&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
bool
DecryptKey(
    xref:wallet/CKeyingMaterial.adoc[CKeyingMaterial] const& master&lowbar;key,
    std::span&lt;unsigned char const&gt; crypted&lowbar;secret,
    xref:CPubKey.adoc[CPubKey] const& pub&lowbar;key,
    xref:CKey.adoc[CKey]& key);
----

== Return Value

true if the key was decrypted and matches the public key&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *master&lowbar;key*
| The master key used to decrypt the private key&period;
| *crypted&lowbar;secret*
| The encrypted private key&period;
| *pub&lowbar;key*
| The public key the decrypted key must match&period;
| *key*
| Receives the recovered private key&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
