Added key type to the config file (#17)

Added key type to the config
This commit is contained in:
Ravidu Lashan
2019-10-10 15:33:42 +05:30
committed by GitHub
parent 11489de7a1
commit 070994277d
4 changed files with 8 additions and 4 deletions

View File

@@ -51,7 +51,7 @@ int rekey()
if (load_config() != 0)
return -1;
crypto::generate_signing_keys(cfg.pubkey, cfg.seckey);
crypto::generate_signing_keys(cfg.pubkey, cfg.seckey, cfg.keytype);
if (binpair_to_b64() != 0)
return -1;
@@ -84,7 +84,7 @@ int create_contract()
//We populate the in-memory struct with default settings and then save it to the file.
crypto::generate_signing_keys(cfg.pubkey, cfg.seckey);
crypto::generate_signing_keys(cfg.pubkey, cfg.seckey, cfg.keytype);
if (binpair_to_b64() != 0)
return -1;
@@ -172,6 +172,7 @@ int load_config()
cfg.pubkeyb64 = d["pubkeyb64"].GetString();
cfg.seckeyb64 = d["seckeyb64"].GetString();
cfg.keytype = d["keytype"].GetString();
cfg.binary = d["binary"].GetString();
cfg.binargs = d["binargs"].GetString();
cfg.listenip = d["listenip"].GetString();
@@ -212,6 +213,7 @@ int save_config()
d.AddMember("version", StringRef(util::hp_version), allocator);
d.AddMember("pubkeyb64", StringRef(cfg.pubkeyb64.data()), allocator);
d.AddMember("seckeyb64", StringRef(cfg.seckeyb64.data()), allocator);
d.AddMember("keytype", StringRef(cfg.keytype.data()), allocator);
d.AddMember("binary", StringRef(cfg.binary.data()), allocator);
d.AddMember("binargs", StringRef(cfg.binargs.data()), allocator);
d.AddMember("listenip", StringRef(cfg.listenip.data()), allocator);

View File

@@ -38,6 +38,7 @@ struct contract_config
string pubkeyb64; // Contract base64 public key
string seckeyb64; // Contract base64 secret key
string keytype; // Key generation algorithm used by libsodium
string binary; // Full path to the contract binary
string binargs; // CLI arguments to pass to the contract binary
string listenip; // The IPs to listen on for incoming connections

View File

@@ -27,7 +27,7 @@ int init()
/**
* Generates a signing key pair using libsodium and assigns them to the provided strings.
*/
void generate_signing_keys(string &pubkey, string &seckey)
void generate_signing_keys(string &pubkey, string &seckey, string &keytype)
{
//Generate key pair using libsodium default algorithm. (Currently using ed25519)
@@ -37,6 +37,7 @@ void generate_signing_keys(string &pubkey, string &seckey)
pubkey = string((char *)pubkeychars, crypto_sign_PUBLICKEYBYTES);
seckey = string((char *)seckeychars, crypto_sign_SECRETKEYBYTES);
keytype = crypto_sign_primitive();
}
/**

View File

@@ -12,7 +12,7 @@ namespace crypto
int init();
void generate_signing_keys(string &pubkey, string &seckey);
void generate_signing_keys(string &pubkey, string &seckey, string &keytype);
string sign(const string &msg, const string &seckey);