Added gmp

parent a3e35722
...@@ -19,3 +19,7 @@ install-sh ...@@ -19,3 +19,7 @@ install-sh
/.deps/ /.deps/
/CMakeCache.txt /CMakeCache.txt
/cmake_install.cmake /cmake_install.cmake
/sgxd.cbp
/sgx-gmp/
!/sgx-sdk-build/
/secure_enclave/Makefile
...@@ -24,24 +24,30 @@ std::string* stringFromKey(libff::alt_bn128_Fr* _key) { ...@@ -24,24 +24,30 @@ std::string* stringFromKey(libff::alt_bn128_Fr* _key) {
} }
libff::alt_bn128_Fr* keyFromString(std::string* _keyString) { libff::alt_bn128_Fr* keyFromString(std::string& _keyString) {
return new libff::alt_bn128_Fr(_keyString->c_str()); return new libff::alt_bn128_Fr(_keyString.c_str());
} }
void import_key() { void import_key(const char* _keyString) {
std::string keyString = "4160780231445160889237664391382223604184857153814275770598791864649971919844";
auto key1 = keyFromString(&keyString); if (_keyString == nullptr)
throw std::exception();
std::string ks(_keyString);
//std::string keyString = "4160780231445160889237664391382223604184857153814275770598791864649971919844";
auto key1 = keyFromString(ks);
auto s1 = stringFromKey(key1); auto s1 = stringFromKey(key1);
auto key2 = keyFromString(s1); auto key2 = keyFromString(*s1);
auto s2 = stringFromKey(key2); auto s2 = stringFromKey(key2);
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#define EXTERNC #define EXTERNC
#endif #endif
EXTERNC void import_key(); EXTERNC void import_key(const char* _keyString);
#endif //SGXD_BLSUTILS_H #endif //SGXD_BLSUTILS_H
...@@ -177,10 +177,12 @@ void e_mpf_div(mpf_t *c_un, mpf_t *a_un, mpf_t *b_un) ...@@ -177,10 +177,12 @@ void e_mpf_div(mpf_t *c_un, mpf_t *a_un, mpf_t *b_un)
mpz_t c3, c4, c5; mpz_t c3, c4, c5;
int pi_init= 0; int pi_init= 0;
void encrypt_key (mpf_t *pi_un, uint64_t digits) void encrypt_key (mpf_t *pi_un, uint64_t digits, char key[100])
{ {
import_key();
import_key(key);
mpf_t pi; mpf_t pi;
......
...@@ -21,7 +21,7 @@ enclave { ...@@ -21,7 +21,7 @@ enclave {
[user_check] mpf_t *c, [user_check] mpf_t *a, [user_check] mpf_t *b [user_check] mpf_t *c, [user_check] mpf_t *a, [user_check] mpf_t *b
); );
public void encrypt_key ([user_check] mpf_t *pi, uint64_t digits); public void encrypt_key ([user_check] mpf_t *pi, uint64_t digits, [in] char key[100]);
}; };
......
...@@ -112,7 +112,15 @@ int main (int argc, char *argv[]) ...@@ -112,7 +112,15 @@ int main (int argc, char *argv[])
mpf_init(pi); mpf_init(pi);
status= encrypt_key(eid, &pi, digits);
const char* key = "4160780231445160889237664391382223604184857153814275770598791864649971919844";
char keyArray[100];
strncpy(keyArray, key, 100);
status= encrypt_key(eid, &pi, digits, keyArray);
if ( status != SGX_SUCCESS ) { if ( status != SGX_SUCCESS ) {
fprintf(stderr, "ECALL e_pi: 0x%04x\n", status); fprintf(stderr, "ECALL e_pi: 0x%04x\n", status);
return 1; return 1;
......
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