Added gmp

parent 627c3255
......@@ -4,6 +4,7 @@
#define GMP_WITH_SGX
#include "libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp"
#include "libff/algebra/curves/alt_bn128/alt_bn128_init.hpp"
#include "BLSUtils.h"
......@@ -35,6 +36,8 @@ libff::alt_bn128_Fr* keyFromString(std::string& _keyString) {
void import_key(const char* _keyString, char* encryptedKey, uint64_t bufLen) {
libff::init_alt_bn128_params();
if (encryptedKey == nullptr && bufLen < 100)
throw std::exception();
......@@ -43,26 +46,22 @@ void import_key(const char* _keyString, char* encryptedKey, uint64_t bufLen) {
std::string ks(_keyString);
//std::string keyString = "4160780231445160889237664391382223604184857153814275770598791864649971919844";
auto key1 = keyFromString(ks);
// std::string keyString = "4160780231445160889237664391382223604184857153814275770598791864649971919844";
auto s1 = stringFromKey(key1);
auto key = keyFromString(ks);
auto key2 = keyFromString(*s1);
auto s1 = stringFromKey(key);
auto s2 = stringFromKey(key2);
if (s1->compare(*s2) != 0)
throw std::exception();
if (s1->compare(ks) != 0)
throw std::exception();
if (s1->size() < 10)
throw std::exception();
if (s2->size() == 0)
throw std::exception();
if (s2->size() >= 100)
throw std::exception();
if (s1->size() >= 100)
throw std::exception();
strncpy(encryptedKey, s2->c_str(), 100);
strncpy(encryptedKey, s1->c_str(), 100);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment