SKALE-2830 small improvements

parent 7fa76e24
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
#include "third_party/spdlog/spdlog.h" #include "third_party/spdlog/spdlog.h"
#include "common.h" #include "common.h"
#define DKG_MAX_SEALED_LEN 3100
vector<string> splitString(const char *coeffs, const char symbol) { vector<string> splitString(const char *coeffs, const char symbol) {
string str(coeffs); string str(coeffs);
string delim; string delim;
...@@ -95,8 +93,7 @@ string gen_dkg_poly(int _t) { ...@@ -95,8 +93,7 @@ string gen_dkg_poly(int _t) {
throw SGXException(-666, errMsg.data()); throw SGXException(-666, errMsg.data());
} }
uint64_t length = DKG_MAX_SEALED_LEN; uint64_t length = enc_len;;
length = enc_len;
vector<char> hexEncrPoly(2 * length + 1, 0); vector<char> hexEncrPoly(2 * length + 1, 0);
CHECK_STATE(encrypted_dkg_secret.size() >= length); CHECK_STATE(encrypted_dkg_secret.size() >= length);
......
...@@ -37,5 +37,5 @@ RUN apt update && \ ...@@ -37,5 +37,5 @@ RUN apt update && \
cd .. && rm -rf dynamic-application-loader-host-interface-072d233296c15d0dcd1fb4570694d0244729f87b && \ cd .. && rm -rf dynamic-application-loader-host-interface-072d233296c15d0dcd1fb4570694d0244729f87b && \
cd /usr/src/sdk && \ cd /usr/src/sdk && \
./autoconf.bash && \ ./autoconf.bash && \
./configure && \ ./configure && \
bash -c "make -j$(nproc)" bash -c "make -j$(nproc)"
...@@ -89,7 +89,7 @@ string getECDSAPubKey(const char *_encryptedKeyHex) { ...@@ -89,7 +89,7 @@ string getECDSAPubKey(const char *_encryptedKeyHex) {
vector<char> errMsg(BUF_LEN, 0); vector<char> errMsg(BUF_LEN, 0);
vector<char> pubKeyX(BUF_LEN, 0); vector<char> pubKeyX(BUF_LEN, 0);
vector<char> pubKeyY(BUF_LEN, 0); vector<char> pubKeyY(BUF_LEN, 0);
vector <uint8_t> encrPrKey(BUF_LEN, 0); vector<uint8_t> encrPrKey(BUF_LEN, 0);
int errStatus = 0; int errStatus = 0;
uint64_t enc_len = 0; uint64_t enc_len = 0;
...@@ -102,6 +102,7 @@ string getECDSAPubKey(const char *_encryptedKeyHex) { ...@@ -102,6 +102,7 @@ string getECDSAPubKey(const char *_encryptedKeyHex) {
errMsg.data(), encrPrKey.data(), enc_len, pubKeyX.data(), pubKeyY.data()); errMsg.data(), encrPrKey.data(), enc_len, pubKeyX.data(), pubKeyY.data());
if (errStatus != 0) { if (errStatus != 0) {
spdlog::error("failed to get ECDSA public key {}", status);
throw SGXException(-666, errMsg.data()); throw SGXException(-666, errMsg.data());
} }
...@@ -109,8 +110,7 @@ string getECDSAPubKey(const char *_encryptedKeyHex) { ...@@ -109,8 +110,7 @@ string getECDSAPubKey(const char *_encryptedKeyHex) {
spdlog::error("failed to get ECDSA public key {}", status); spdlog::error("failed to get ECDSA public key {}", status);
throw SGXException(666, "failed to get ECDSA public key"); throw SGXException(666, "failed to get ECDSA public key");
} }
string pubKey = string(pubKeyX.data()) + string(pubKeyY.data());//concatPubKeyWith0x(pub_key_x, pub_key_y);// string pubKey = string(pubKeyX.data()) + string(pubKeyY.data());
if (pubKey.size() != 128) { if (pubKey.size() != 128) {
spdlog::error("Incorrect pub key size", status); spdlog::error("Incorrect pub key size", status);
......
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
void initUserSpace() { void initUserSpace() {
libff::inhibit_profiling_counters = true; libff::inhibit_profiling_counters = true;
libff::inhibit_profiling_info = true;
libff::init_alt_bn128_params(); libff::init_alt_bn128_params();
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#define ADD_ENTROPY_SIZE 32 #define ADD_ENTROPY_SIZE 32
#define DKG_BUFER_LENGTH 2490//3060 #define DKG_BUFER_LENGTH 2496//3060
#define DKG_MAX_SEALED_LEN 3100 #define DKG_MAX_SEALED_LEN 3100
#define SECRET_SHARE_NUM_BYTES 96 #define SECRET_SHARE_NUM_BYTES 96
......
...@@ -93,8 +93,7 @@ void signature_sign(signature sig, mpz_t message, mpz_t private_key, domain_para ...@@ -93,8 +93,7 @@ void signature_sign(signature sig, mpz_t message, mpz_t private_key, domain_para
//message must not have a bit length longer than that of n //message must not have a bit length longer than that of n
//see: Guide to Elliptic Curve Cryptography, section 4.4.1. //see: Guide to Elliptic Curve Cryptography, section 4.4.1.
for (int i = 0; i < 1; i++ ) { {
assert(mpz_sizeinbase(message, 2) <= mpz_sizeinbase(curve->n, 2)); assert(mpz_sizeinbase(message, 2) <= mpz_sizeinbase(curve->n, 2));
point Q = point_init(); point Q = point_init();
...@@ -119,8 +118,6 @@ void signature_sign(signature sig, mpz_t message, mpz_t private_key, domain_para ...@@ -119,8 +118,6 @@ void signature_sign(signature sig, mpz_t message, mpz_t private_key, domain_para
get_global_random(rand_char, 32); get_global_random(rand_char, 32);
gmp_randstate_t r_state;
signature_sign_start: signature_sign_start:
...@@ -130,10 +127,6 @@ void signature_sign(signature sig, mpz_t message, mpz_t private_key, domain_para ...@@ -130,10 +127,6 @@ void signature_sign(signature sig, mpz_t message, mpz_t private_key, domain_para
mpz_mod(k, seed, curve->p); mpz_mod(k, seed, curve->p);
//mpz_set_str(k, "49a0d7b786ec9cde0d0721d72804befd06571c974b191efb42ecf322ba9ddd9a", 16);
// mpz_set_str(k, "DC87789C4C1A09C97FF4DE72C0D0351F261F10A2B9009C80AEE70DDEC77201A0", 16);
//mpz_set_str(k,"29932781130098090011281004827843485745127563886526054275935615017309884975795",10);
//Calculate x //Calculate x
point_multiplication(Q, k, curve->G, curve); point_multiplication(Q, k, curve->G, curve);
mpz_set(x, Q->x); mpz_set(x, Q->x);
...@@ -195,7 +188,6 @@ void signature_sign(signature sig, mpz_t message, mpz_t private_key, domain_para ...@@ -195,7 +188,6 @@ void signature_sign(signature sig, mpz_t message, mpz_t private_key, domain_para
mpz_clear(seed); mpz_clear(seed);
mpz_clear(n_div_2); mpz_clear(n_div_2);
mpz_clear(s_mul_2); mpz_clear(s_mul_2);
} }
} }
......
This diff is collapsed.
...@@ -111,13 +111,10 @@ TEST_CASE_METHOD(TestFixture, "ECDSA keygen and signature test", "[ecdsa-key-sig ...@@ -111,13 +111,10 @@ TEST_CASE_METHOD(TestFixture, "ECDSA keygen and signature test", "[ecdsa-key-sig
vector<char> signatureS(BUF_LEN, 0); vector<char> signatureS(BUF_LEN, 0);
uint8_t signatureV = 0; uint8_t signatureV = 0;
status = trustedEcdsaSign(eid, &errStatus, errMsg.data(), encrPrivKey.data(), encLen,
(unsigned char *) hex.data(),
signatureR.data(),
status = trustedEcdsaSign(eid, &errStatus, errMsg.data(), encrPrivKey.data(), encLen, signatureS.data(), &signatureV, 16);
(unsigned char *) hex.data(),
signatureR.data(),
signatureS.data(), &signatureV, 16);
REQUIRE(status == SGX_SUCCESS); REQUIRE(status == SGX_SUCCESS);
...@@ -138,7 +135,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA AES keygen and signature test", "[ecdsa-aes ...@@ -138,7 +135,6 @@ TEST_CASE_METHOD(TestFixture, "ECDSA AES keygen and signature test", "[ecdsa-aes
REQUIRE(status == SGX_SUCCESS); REQUIRE(status == SGX_SUCCESS);
REQUIRE(errStatus == SGX_SUCCESS); REQUIRE(errStatus == SGX_SUCCESS);
string hex = SAMPLE_HEX_HASH; string hex = SAMPLE_HEX_HASH;
vector<char> signatureR(BUF_LEN, 0); vector<char> signatureR(BUF_LEN, 0);
vector<char> signatureS(BUF_LEN, 0); vector<char> signatureS(BUF_LEN, 0);
......
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