diff --git a/crypto.cpp b/crypto.cpp index 48c6fc70c..7e3ce81ab 100644 --- a/crypto.cpp +++ b/crypto.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +//#include #include "TestHelperCrypto.h" using namespace std; @@ -38,6 +38,21 @@ using namespace CryptoPP; BOOST_AUTO_TEST_SUITE(devcrypto) +BOOST_AUTO_TEST_CASE(cryptopp_public_export_import) +{ + ECIES::Decryptor d(pp::PRNG(), pp::secp256k1()); + ECIES::Encryptor e(d.GetKey()); + + Public p = pp::exportPublicKey(e.GetKey()); + Integer x(&p[0], 32); + Integer y(&p[32], 32); + + DL_PublicKey_EC pub; + pub.Initialize(pp::secp256k1(), ECP::Point(x,y)); + + assert(pub == e.GetKey()); +} + BOOST_AUTO_TEST_CASE(eckeypair_encrypt) { ECKeyPair k = ECKeyPair::create(); @@ -50,6 +65,11 @@ BOOST_AUTO_TEST_CASE(eckeypair_encrypt) bytes p = k.decrypt(&b); assert(p == asBytes(original)); + + encrypt(p, k.publicKey()); + assert(p != asBytes(original)); + + // todo: test decrypt w/Secret } BOOST_AUTO_TEST_CASE(ecies)