aboutsummaryrefslogtreecommitdiffstats
path: root/crypto.cpp
diff options
context:
space:
mode:
authorsubtly <subtly@users.noreply.github.com>2014-10-23 05:59:00 +0800
committersubtly <subtly@users.noreply.github.com>2014-10-23 05:59:00 +0800
commit9308d04a4cc1b93a879f542aa9c3e3e8297410e4 (patch)
tree77dd37412e711cafd6b2f12a6a48897e55deac20 /crypto.cpp
parentd4aea64175fba7185389b7a76e2487c34a9d8a32 (diff)
downloaddexon-solidity-9308d04a4cc1b93a879f542aa9c3e3e8297410e4.tar.gz
dexon-solidity-9308d04a4cc1b93a879f542aa9c3e3e8297410e4.tar.zst
dexon-solidity-9308d04a4cc1b93a879f542aa9c3e3e8297410e4.zip
Export and encrypt via dev::Public. more cryptopp abstraction.
Diffstat (limited to 'crypto.cpp')
-rw-r--r--crypto.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/crypto.cpp b/crypto.cpp
index 48c6fc70..7e3ce81a 100644
--- a/crypto.cpp
+++ b/crypto.cpp
@@ -28,7 +28,7 @@
#include <libethereum/Transaction.h>
#include <boost/test/unit_test.hpp>
#include <libdevcrypto/EC.h>
-#include <libdevcrypto/ECIES.h>
+//#include <libdevcrypto/ECIES.h>
#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<ECP>::Decryptor d(pp::PRNG(), pp::secp256k1());
+ ECIES<ECP>::Encryptor e(d.GetKey());
+
+ Public p = pp::exportPublicKey(e.GetKey());
+ Integer x(&p[0], 32);
+ Integer y(&p[32], 32);
+
+ DL_PublicKey_EC<ECP> 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)