diff options
author | subtly <subtly@users.noreply.github.com> | 2014-10-24 01:06:31 +0800 |
---|---|---|
committer | subtly <subtly@users.noreply.github.com> | 2014-10-24 01:06:31 +0800 |
commit | ee062e564b4cac38a14d755abcde1c68b3ad8b53 (patch) | |
tree | a340bbea6537bbc20a16ec1d41ab62595ec5f4ff /crypto.cpp | |
parent | 8f6314b923efd4b7e3d39e53c8a1cdb518a160bf (diff) | |
download | dexon-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.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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()); |