monero-cpp icon indicating copy to clipboard operation
monero-cpp copied to clipboard

Expose wallet2::{en,de}crypt in monero_wallet_full

Open jbakosi opened this issue 2 years ago • 2 comments

This will only work after https://github.com/monero-project/monero/pull/8515 is merged and integrated here, so after review the API might change. I tested this using:

auto w = monero_wallet_full::create_wallet_random( "", "", monero_network_type::TESTNET );
for (const auto& text : std::array<std::string,4>{"Restricted","Restricted0","Restricted01","Restricted012"}) {
    for (auto authenticated : std::array<bool,2>{false,true}) {
      uint64_t pad;
      auto ciphertext_z85 = w->encrypt_message( text, pad, authenticated );
      auto cleartext = w->decrypt_message( ciphertext_z85, pad, authenticated );
      std::cout << "'" << text << "', " << authenticated << ", " << ciphertext_z85 << ", " << pad << ", '" << cleartext << "'\n";
      assert( text == cleartext );
    }
  }

Please let me know how I can help integrate this better.

jbakosi avatar Aug 19 '22 11:08 jbakosi

Thanks, it looks good at first sight.

woodser avatar Aug 19 '22 12:08 woodser

Please rebase if you still want to add this.

woodser avatar Apr 05 '24 19:04 woodser