aboutsummaryrefslogtreecommitdiffstats
path: root/crypto.cpp
diff options
context:
space:
mode:
authorsubtly <subtly@users.noreply.github.com>2014-10-24 01:06:31 +0800
committersubtly <subtly@users.noreply.github.com>2014-10-24 01:06:31 +0800
commitee062e564b4cac38a14d755abcde1c68b3ad8b53 (patch)
treea340bbea6537bbc20a16ec1d41ab62595ec5f4ff /crypto.cpp
parent8f6314b923efd4b7e3d39e53c8a1cdb518a160bf (diff)
downloaddexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.tar
dexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.tar.gz
dexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.tar.bz2
dexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.tar.lz
dexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.tar.xz
dexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.tar.zst
dexon-solidity-ee062e564b4cac38a14d755abcde1c68b3ad8b53.zip
add ecies encrypt/decrypt support to common crypto
Diffstat (limited to 'crypto.cpp')
-rw-r--r--crypto.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/crypto.cpp b/crypto.cpp
index 40e0a6a4..3662bb83 100644
--- a/crypto.cpp
+++ b/crypto.cpp
@@ -37,6 +37,24 @@ using namespace CryptoPP;
BOOST_AUTO_TEST_SUITE(devcrypto)
+BOOST_AUTO_TEST_CASE(common_crypt)
+{
+ string message("Now is the time for all good persons to come to the aide of humanity.");
+ bytes m = asBytes(message);
+ bytesConstRef bcr(&m);
+
+ SecretKeyRef k;
+ bytes cipher;
+ encrypt(k.pub(), bcr, cipher);
+ assert(cipher != asBytes(message) && cipher.size() > 0);
+
+ bytes plain;
+ decrypt(k.sec(), bytesConstRef(&cipher), plain);
+
+ assert(asString(plain) == message);
+ assert(plain == asBytes(message));
+}
+
BOOST_AUTO_TEST_CASE(cryptopp_vs_secp256k1)
{
ECIES<ECP>::Decryptor d(pp::PRNG(), pp::secp256k1());