Unverified Commit 82824ef2 authored by Stan Kladko's avatar Stan Kladko Committed by GitHub

Merge pull request #42 from skalenetwork/bug/change-naming

Bug/change naming
parents 0ec388d2 dcd5da17
...@@ -82,7 +82,10 @@ string gen_dkg_poly( int _t){ ...@@ -82,7 +82,10 @@ string gen_dkg_poly( int _t){
uint32_t enc_len = 0; uint32_t enc_len = 0;
status = gen_dkg_secret (eid, &err_status, errMsg.data(), encrypted_dkg_secret.data(), &enc_len, _t); if (!is_aes)
status = gen_dkg_secret (eid, &err_status, errMsg.data(), encrypted_dkg_secret.data(), &enc_len, _t);
else
status = gen_dkg_secret_aes (eid, &err_status, errMsg.data(), encrypted_dkg_secret.data(), &enc_len, _t);
if ( err_status != 0){ if ( err_status != 0){
throw RPCException(-666, errMsg.data() ) ; throw RPCException(-666, errMsg.data() ) ;
} }
...@@ -168,8 +171,12 @@ string get_secret_shares(const string& polyName, const char* encryptedPolyHex, c ...@@ -168,8 +171,12 @@ string get_secret_shares(const string& polyName, const char* encryptedPolyHex, c
throw RPCException(INVALID_HEX, "Invalid encryptedPolyHex"); throw RPCException(INVALID_HEX, "Invalid encryptedPolyHex");
} }
status = set_encrypted_dkg_poly(eid, &err_status, errMsg1, encr_dkg_poly); if (!is_aes)
if ( status != SGX_SUCCESS || err_status!=0){ status = set_encrypted_dkg_poly(eid, &err_status, errMsg1, encr_dkg_poly);
else
status = set_encrypted_dkg_poly_aes(eid, &err_status, errMsg1, encr_dkg_poly, &enc_len);
if ( status != SGX_SUCCESS || err_status != 0){
throw RPCException(-666, errMsg1 ); throw RPCException(-666, errMsg1 );
} }
......
...@@ -466,7 +466,7 @@ Json::Value getVerificationVectorImpl(const string& polyName, int t, int n) { ...@@ -466,7 +466,7 @@ Json::Value getVerificationVectorImpl(const string& polyName, int t, int n) {
for ( int i = 0; i < t; i++){ for ( int i = 0; i < t; i++){
vector<string> cur_coef = verifVector.at(i); vector<string> cur_coef = verifVector.at(i);
for ( int j = 0; j < 4; j++ ){ for ( int j = 0; j < 4; j++ ){
result["Verification Vector"][i][j] = cur_coef.at(j); result["verificationVector"][i][j] = cur_coef.at(j);
} }
} }
...@@ -474,7 +474,7 @@ Json::Value getVerificationVectorImpl(const string& polyName, int t, int n) { ...@@ -474,7 +474,7 @@ Json::Value getVerificationVectorImpl(const string& polyName, int t, int n) {
cerr << " err str " << _e.errString << endl; cerr << " err str " << _e.errString << endl;
result["status"] = _e.status; result["status"] = _e.status;
result["errorMessage"] = _e.errString; result["errorMessage"] = _e.errString;
result["Verification Vector"] = ""; result["verificationVector"] = "";
} }
return result; return result;
...@@ -640,7 +640,7 @@ Json::Value getBLSPublicKeyShareImpl(const string & blsKeyName){ ...@@ -640,7 +640,7 @@ Json::Value getBLSPublicKeyShareImpl(const string & blsKeyName){
} }
vector<string> public_key_vect = GetBLSPubKey(encryptedKeyHex_ptr->c_str()); vector<string> public_key_vect = GetBLSPubKey(encryptedKeyHex_ptr->c_str());
for ( uint8_t i = 0; i < 4; i++) { for ( uint8_t i = 0; i < 4; i++) {
result["BLSPublicKeyShare"][i] = public_key_vect.at(i); result["blsPublicKeyShare"][i] = public_key_vect.at(i);
} }
} catch (RPCException &_e) { } catch (RPCException &_e) {
...@@ -668,7 +668,7 @@ Json::Value complaintResponseImpl(const string& polyName, int ind){ ...@@ -668,7 +668,7 @@ Json::Value complaintResponseImpl(const string& polyName, int ind){
string DHKey = decrypt_DHKey(polyName, ind); string DHKey = decrypt_DHKey(polyName, ind);
result["share*G2"] = *shareG2_ptr; result["share*G2"] = *shareG2_ptr;
result["DHKey"] = DHKey; result["dhKey"] = DHKey;
} catch (RPCException &_e) { } catch (RPCException &_e) {
cerr << " err str " << _e.errString << endl; cerr << " err str " << _e.errString << endl;
...@@ -702,11 +702,21 @@ Json::Value multG2Impl(const string& x){ ...@@ -702,11 +702,21 @@ Json::Value multG2Impl(const string& x){
Json::Value isPolyExistsImpl(const string& polyName){ Json::Value isPolyExistsImpl(const string& polyName){
Json::Value result; Json::Value result;
try {
shared_ptr<string> poly_str_ptr = LevelDB::getLevelDb()->readString(polyName); std::shared_ptr<std::string> poly_str_ptr = LevelDB::getLevelDb()->readString(polyName);
result["IsExist"] = true; result["IsExist"] = true;
result["status"] = 0;
result["errorMessage"] = "";
if (poly_str_ptr == nullptr){ if (poly_str_ptr == nullptr){
result["IsExist"] = false; result["IsExist"] = false;
result["status"] = 0;
result["errorMessage"] = "";
}
} catch (RPCException &_e) {
std::cerr << " err str " << _e.errString << std::endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
result["IsExist"] = false;
} }
return result; return result;
......
# Makefile.in generated by automake 1.15.1 from Makefile.am. # Makefile.in generated by automake 1.16.1 from Makefile.am.
# @configure_input@ # @configure_input@
# Copyright (C) 1994-2017 Free Software Foundation, Inc. # Copyright (C) 1994-2018 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
...@@ -137,7 +137,16 @@ am__v_at_0 = @ ...@@ -137,7 +137,16 @@ am__v_at_0 = @
am__v_at_1 = am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/AESUtils.Po \
./$(DEPDIR)/BLSEnclave.Po ./$(DEPDIR)/DH_dkg.Po \
./$(DEPDIR)/DKGUtils.Po ./$(DEPDIR)/alt_bn128_g1.Po \
./$(DEPDIR)/alt_bn128_g2.Po ./$(DEPDIR)/alt_bn128_init.Po \
./$(DEPDIR)/curves.Po ./$(DEPDIR)/domain_parameters.Po \
./$(DEPDIR)/numbertheory.Po ./$(DEPDIR)/point.Po \
./$(DEPDIR)/secure_enclave.Po ./$(DEPDIR)/secure_enclave_t.Po \
./$(DEPDIR)/signature.Po ./$(DEPDIR)/signed_enclave_debug.Po \
./$(DEPDIR)/signed_enclave_rel.Po
am__mv = mv -f am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
...@@ -366,8 +375,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status ...@@ -366,8 +375,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
*config.status*) \ *config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \ *) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac; esac;
$(top_srcdir)/build-aux/sgx_enclave.am $(am__empty): $(top_srcdir)/build-aux/sgx_enclave.am $(am__empty):
...@@ -432,22 +441,28 @@ mostlyclean-compile: ...@@ -432,22 +441,28 @@ mostlyclean-compile:
distclean-compile: distclean-compile:
-rm -f *.tab.c -rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AESUtils.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AESUtils.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BLSEnclave.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BLSEnclave.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DH_dkg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DH_dkg.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DKGUtils.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DKGUtils.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alt_bn128_g1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alt_bn128_g1.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alt_bn128_g2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alt_bn128_g2.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alt_bn128_init.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alt_bn128_init.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/curves.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/curves.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/domain_parameters.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/domain_parameters.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numbertheory.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numbertheory.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/point.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/point.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/secure_enclave.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/secure_enclave.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/secure_enclave_t.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/secure_enclave_t.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signature.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signature.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signed_enclave_debug.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signed_enclave_debug.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signed_enclave_rel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signed_enclave_rel.Po@am__quote@ # am--include-marker
$(am__depfiles_remade):
@$(MKDIR_P) $(@D)
@echo '# dummy' >$@-t && $(am__mv) $@-t $@
am--depfiles: $(am__depfiles_remade)
.c.o: .c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
...@@ -571,7 +586,10 @@ cscopelist-am: $(am__tagged_files) ...@@ -571,7 +586,10 @@ cscopelist-am: $(am__tagged_files)
distclean-tags: distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES) distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \ list='$(DISTFILES)'; \
...@@ -644,7 +662,22 @@ clean: clean-am ...@@ -644,7 +662,22 @@ clean: clean-am
clean-am: clean-generic clean-libexecPROGRAMS mostlyclean-am clean-am: clean-generic clean-libexecPROGRAMS mostlyclean-am
distclean: distclean-am distclean: distclean-am
-rm -rf ./$(DEPDIR) -rm -f ./$(DEPDIR)/AESUtils.Po
-rm -f ./$(DEPDIR)/BLSEnclave.Po
-rm -f ./$(DEPDIR)/DH_dkg.Po
-rm -f ./$(DEPDIR)/DKGUtils.Po
-rm -f ./$(DEPDIR)/alt_bn128_g1.Po
-rm -f ./$(DEPDIR)/alt_bn128_g2.Po
-rm -f ./$(DEPDIR)/alt_bn128_init.Po
-rm -f ./$(DEPDIR)/curves.Po
-rm -f ./$(DEPDIR)/domain_parameters.Po
-rm -f ./$(DEPDIR)/numbertheory.Po
-rm -f ./$(DEPDIR)/point.Po
-rm -f ./$(DEPDIR)/secure_enclave.Po
-rm -f ./$(DEPDIR)/secure_enclave_t.Po
-rm -f ./$(DEPDIR)/signature.Po
-rm -f ./$(DEPDIR)/signed_enclave_debug.Po
-rm -f ./$(DEPDIR)/signed_enclave_rel.Po
-rm -f Makefile -rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \ distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags distclean-tags
...@@ -690,7 +723,22 @@ install-ps-am: ...@@ -690,7 +723,22 @@ install-ps-am:
installcheck-am: installcheck-am:
maintainer-clean: maintainer-clean-am maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR) -rm -f ./$(DEPDIR)/AESUtils.Po
-rm -f ./$(DEPDIR)/BLSEnclave.Po
-rm -f ./$(DEPDIR)/DH_dkg.Po
-rm -f ./$(DEPDIR)/DKGUtils.Po
-rm -f ./$(DEPDIR)/alt_bn128_g1.Po
-rm -f ./$(DEPDIR)/alt_bn128_g2.Po
-rm -f ./$(DEPDIR)/alt_bn128_init.Po
-rm -f ./$(DEPDIR)/curves.Po
-rm -f ./$(DEPDIR)/domain_parameters.Po
-rm -f ./$(DEPDIR)/numbertheory.Po
-rm -f ./$(DEPDIR)/point.Po
-rm -f ./$(DEPDIR)/secure_enclave.Po
-rm -f ./$(DEPDIR)/secure_enclave_t.Po
-rm -f ./$(DEPDIR)/signature.Po
-rm -f ./$(DEPDIR)/signed_enclave_debug.Po
-rm -f ./$(DEPDIR)/signed_enclave_rel.Po
-rm -f Makefile -rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic maintainer-clean-am: distclean-am maintainer-clean-generic
...@@ -710,19 +758,19 @@ uninstall-am: uninstall-libexecPROGRAMS ...@@ -710,19 +758,19 @@ uninstall-am: uninstall-libexecPROGRAMS
.MAKE: install-am install-strip .MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
clean-libexecPROGRAMS cscopelist-am ctags ctags-am distclean \ clean-generic clean-libexecPROGRAMS cscopelist-am ctags \
distclean-compile distclean-generic distclean-tags distdir dvi \ ctags-am distclean distclean-compile distclean-generic \
dvi-am html html-am info info-am install install-am \ distclean-tags distdir dvi dvi-am html html-am info info-am \
install-data install-data-am install-dvi install-dvi-am \ install install-am install-data install-data-am install-dvi \
install-exec install-exec-am install-html install-html-am \ install-dvi-am install-exec install-exec-am install-html \
install-info install-info-am install-libexecPROGRAMS \ install-html-am install-info install-info-am \
install-man install-pdf install-pdf-am install-ps \ install-libexecPROGRAMS install-man install-pdf install-pdf-am \
install-ps-am install-strip installcheck installcheck-am \ install-ps install-ps-am install-strip installcheck \
installdirs maintainer-clean maintainer-clean-generic \ installcheck-am installdirs maintainer-clean \
mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ maintainer-clean-generic mostlyclean mostlyclean-compile \
ps ps-am tags tags-am uninstall uninstall-am \ mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
uninstall-libexecPROGRAMS uninstall-am uninstall-libexecPROGRAMS
.PRECIOUS: Makefile .PRECIOUS: Makefile
......
...@@ -598,6 +598,7 @@ void set_encrypted_dkg_poly(int *err_status, char *err_string, uint8_t* encrypte ...@@ -598,6 +598,7 @@ void set_encrypted_dkg_poly(int *err_status, char *err_string, uint8_t* encrypte
(const sgx_sealed_data_t *)encrypted_poly, NULL, 0, Decrypted_dkg_poly, &decr_len); (const sgx_sealed_data_t *)encrypted_poly, NULL, 0, Decrypted_dkg_poly, &decr_len);
if (status != SGX_SUCCESS) { if (status != SGX_SUCCESS) {
*err_status = -1;
snprintf(err_string, BUF_LEN,"sgx_unseal_data - encrypted_poly failed with status %d", status); snprintf(err_string, BUF_LEN,"sgx_unseal_data - encrypted_poly failed with status %d", status);
return; return;
} }
...@@ -1276,8 +1277,54 @@ void bls_sign_message_test(int *err_status, char *err_string, uint8_t *encrypted ...@@ -1276,8 +1277,54 @@ void bls_sign_message_test(int *err_status, char *err_string, uint8_t *encrypted
*err_status = -1; *err_status = -1;
return; return;
} }
}
void gen_dkg_secret_aes (int *err_status, char *err_string, uint8_t *encrypted_dkg_secret, uint32_t* enc_len, size_t _t){
char* dkg_secret = (char*)calloc(DKG_BUFER_LENGTH, 1);
if (gen_dkg_poly(dkg_secret, _t) != 0 ){
*err_status = - 1;
return;
}
snprintf(err_string, BUF_LEN,"poly is %s ", dkg_secret);
int status = AES_encrypt(dkg_secret, encrypted_dkg_secret);
if(status != SGX_SUCCESS) {
snprintf(err_string, BUF_LEN,"SGX AES encrypt DKG poly failed");
*err_status = status;
return;
}
*enc_len = strlen(dkg_secret) + SGX_AESGCM_MAC_SIZE + SGX_AESGCM_IV_SIZE;
free(dkg_secret);
}
void decrypt_dkg_secret_aes (int *err_status, char* err_string, uint8_t* encrypted_dkg_secret, uint8_t* decrypted_dkg_secret, uint32_t* dec_len){
int status = AES_decrypt(encrypted_dkg_secret, dec_len, decrypted_dkg_secret);
if (status != SGX_SUCCESS) {
snprintf(err_string, BUF_LEN,"aes decrypt data - encrypted_dkg_secret failed with status %d", status);
*err_status = status;
return;
}
//*dec_len = decr_len;
} }
void set_encrypted_dkg_poly_aes(int *err_status, char *err_string, uint8_t* encrypted_poly, uint64_t* enc_len){
uint32_t decr_len;
int status = AES_decrypt(encrypted_poly, enc_len, Decrypted_dkg_poly);
if (status != SGX_SUCCESS) {
*err_status = -1;
snprintf(err_string, BUF_LEN,"sgx_unseal_data - encrypted_poly failed with status %d", status);
return;
}
}
...@@ -214,6 +214,28 @@ enclave { ...@@ -214,6 +214,28 @@ enclave {
[out, count = 1024] char* key ); [out, count = 1024] char* key );
public void gen_dkg_secret_aes (
[user_check] int *err_status,
[out, count = 1024] char* err_string,
[out, count = 3050] uint8_t* encrypted_dkg_secret,
[user_check] uint32_t * enc_len,
size_t _t);
public void decrypt_dkg_secret_aes (
[user_check] int *err_status,
[out, count = 1024] char* err_string,
[in, count = 3050] uint8_t* encrypted_dkg_secret,
[out, count = 2490] uint8_t* decrypted_dkg_secret,
[user_check] uint32_t* dec_len);
public void set_encrypted_dkg_poly_aes( [user_check] int *err_status,
[out, count = 1024] char* err_string,
[in, count = 3050] uint8_t* encrypted_poly,
[user_check] uint64_t* enc_len);
}; };
......
...@@ -176,7 +176,7 @@ ...@@ -176,7 +176,7 @@
"returns": { "returns": {
"status": 0, "status": 0,
"errorMessage": "12345", "errorMessage": "12345",
"BLSPublicKeyShare": [] "blsPublicKeyShare": []
} }
}, },
...@@ -192,7 +192,7 @@ ...@@ -192,7 +192,7 @@
"status": 0, "status": 0,
"errorMessage": "12345", "errorMessage": "12345",
"share*G2": "123", "share*G2": "123",
"DHKey": "123" "dhKey": "123"
} }
}, },
......
...@@ -789,7 +789,7 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") { ...@@ -789,7 +789,7 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
secretShares[i] = c.getSecretShare(poly_names[i], pubEthKeys, t, n); secretShares[i] = c.getSecretShare(poly_names[i], pubEthKeys, t, n);
for ( uint8_t k = 0; k < t; k++ ) { for ( uint8_t k = 0; k < t; k++ ) {
for (uint8_t j = 0; j < 4; j++) { for (uint8_t j = 0; j < 4; j++) {
string pubShare = VerifVects[i]["Verification Vector"][k][j].asString(); string pubShare = VerifVects[i]["verificationVector"][k][j].asString();
pubShares[i] += ConvertDecToHex(pubShare); pubShares[i] += ConvertDecToHex(pubShare);
} }
} }
...@@ -799,7 +799,7 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") { ...@@ -799,7 +799,7 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
Json::Value complaintResponse = c.complaintResponse(poly_names[1], 0); Json::Value complaintResponse = c.complaintResponse(poly_names[1], 0);
cerr << "share * G2 is " << complaintResponse["share*G2"].asString(); cerr << "share * G2 is " << complaintResponse["share*G2"].asString();
cerr << "DHKey is " << complaintResponse["DHKey"].asString(); cerr << "DHKey is " << complaintResponse["dhKey"].asString();
int k = 0; int k = 0;
...@@ -856,7 +856,7 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") { ...@@ -856,7 +856,7 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
vector<string> pubKey_vect; vector<string> pubKey_vect;
for ( uint8_t j = 0; j < 4; j++){ for ( uint8_t j = 0; j < 4; j++){
pubKey_vect.push_back(pubBLSKeys[i]["BLSPublicKeyShare"][j].asString()); pubKey_vect.push_back(pubBLSKeys[i]["blsPublicKeyShare"][j].asString());
} }
BLSPublicKeyShare pubKey(make_shared<vector<string>>(pubKey_vect), t, n); BLSPublicKeyShare pubKey(make_shared<vector<string>>(pubKey_vect), t, n);
REQUIRE( pubKey.VerifySigWithHelper(hash_arr, make_shared<BLSSigShare>(sig) , t, n)); REQUIRE( pubKey.VerifySigWithHelper(hash_arr, make_shared<BLSSigShare>(sig) , t, n));
...@@ -1022,7 +1022,7 @@ void SendRPCRequest(){ ...@@ -1022,7 +1022,7 @@ void SendRPCRequest(){
secretShares[i] = c.getSecretShare(poly_names[i], pubEthKeys, t, n); secretShares[i] = c.getSecretShare(poly_names[i], pubEthKeys, t, n);
for ( uint8_t k = 0; k < t; k++ ) { for ( uint8_t k = 0; k < t; k++ ) {
for (uint8_t j = 0; j < 4; j++) { for (uint8_t j = 0; j < 4; j++) {
string pubShare = VerifVects[i]["Verification Vector"][k][j].asString(); string pubShare = VerifVects[i]["verificationVector"][k][j].asString();
pubShares[i] += ConvertDecToHex(pubShare); pubShares[i] += ConvertDecToHex(pubShare);
} }
} }
...@@ -1072,7 +1072,7 @@ TEST_CASE("ManySimultaneousThreads", "[many_threads_test]") { ...@@ -1072,7 +1072,7 @@ TEST_CASE("ManySimultaneousThreads", "[many_threads_test]") {
TEST_CASE("ecdsa API test", "[ecdsa_api_test]") { TEST_CASE("ecdsa API test", "[ecdsa_api_test]") {
DEBUG_PRINT = 1; DEBUG_PRINT = 1;
is_sgx_https = 0; is_sgx_https = 0;
is_aes = 0; is_aes = 1;
cerr << "ecdsa_api_test started" << endl; cerr << "ecdsa_api_test started" << endl;
init_all(false, false); init_all(false, false);
...@@ -1219,7 +1219,41 @@ TEST_CASE("isPolyExists test", "[is_poly_test]") { ...@@ -1219,7 +1219,41 @@ TEST_CASE("isPolyExists test", "[is_poly_test]") {
cout << polyDoesNotExist << endl; cout << polyDoesNotExist << endl;
REQUIRE(!polyDoesNotExist["IsExist"].asBool()); REQUIRE(!polyDoesNotExist["IsExist"].asBool());
}
TEST_CASE("AES_DKG test", "[aes_dkg]") {
is_sgx_https = 0;
DEBUG_PRINT = 1;
is_aes = 1;
std::cerr << "test started" << std::endl;
init_all(false, false);
cerr << "Server inited" << endl;
HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2);
cerr << "Client inited" << endl;
reset_db();
int n = 4, t = 4;
Json::Value EthKeys[n];
Json::Value VerifVects[n];
Json::Value pubEthKeys;
Json::Value secretShares[n];
Json::Value pubBLSKeys[n];
Json::Value BLSSigShares[n];
std::vector<std::string> pubShares(n);
std::vector<std::string> poly_names(n);
for (uint8_t i = 0; i < n; i++) {
EthKeys[i] = c.generateECDSAKey();
std::string polyName =
"POLY:SCHAIN_ID:1:NODE_ID:" + std::to_string(i) + ":DKG_ID:0";
cout << c.generateDKGPoly(polyName, t);
// poly_names[i] = polyName;
// VerifVects[i] = c.getVerificationVector(polyName, t, n);
// cout << "VV " << i << " " << VerifVects[i] << std::endl;
// pubEthKeys.append(EthKeys[i]["PublicKey"]);
}
} }
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