mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
add ecies encrypt/decrypt support to common crypto
This commit is contained in:
parent
8f6314b923
commit
ee062e564b
@ -21,23 +21,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4100 4244)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
|
||||
#pragma GCC diagnostic ignored "-Wextra"
|
||||
#include <osrng.h>
|
||||
#include <eccrypto.h> // secp256k1
|
||||
#include <oids.h> // ec domain
|
||||
#include <ecp.h> // ec prime field
|
||||
#include <files.h> // cryptopp buffer
|
||||
#include <aes.h>
|
||||
#include <modes.h> // aes modes
|
||||
#pragma warning(pop)
|
||||
#pragma GCC diagnostic pop
|
||||
#include <libdevcrypto/CryptoPP.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace CryptoPP;
|
||||
|
18
crypto.cpp
18
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());
|
||||
|
Loading…
Reference in New Issue
Block a user