diff --git a/src/conf.cpp b/src/conf.cpp index 89d5a1e3..7ffd85c9 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -48,7 +48,7 @@ int rekey() if (load_config() != 0) return -1; - crypto::generate_signing_keys(cfg.pubkey, cfg.seckey, cfg.keytype); + crypto::generate_signing_keys(cfg.pubkey, cfg.seckey); if (binpair_to_hex() != 0) return -1; @@ -81,7 +81,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, cfg.keytype); + crypto::generate_signing_keys(cfg.pubkey, cfg.seckey); if (binpair_to_hex() != 0) return -1; @@ -169,7 +169,6 @@ int load_config() cfg.pubkeyhex = d["pubkeyhex"].GetString(); cfg.seckeyhex = d["seckeyhex"].GetString(); - cfg.keytype = d["keytype"].GetString(); cfg.binary = d["binary"].GetString(); cfg.binargs = d["binargs"].GetString(); cfg.listenip = d["listenip"].GetString(); @@ -210,7 +209,6 @@ int save_config() d.AddMember("version", rapidjson::StringRef(util::HP_VERSION), allocator); d.AddMember("pubkeyhex", rapidjson::StringRef(cfg.pubkeyhex.data()), allocator); d.AddMember("seckeyhex", rapidjson::StringRef(cfg.seckeyhex.data()), allocator); - d.AddMember("keytype", rapidjson::StringRef(cfg.keytype.data()), allocator); d.AddMember("binary", rapidjson::StringRef(cfg.binary.data()), allocator); d.AddMember("binargs", rapidjson::StringRef(cfg.binargs.data()), allocator); d.AddMember("listenip", rapidjson::StringRef(cfg.listenip.data()), allocator); @@ -386,13 +384,12 @@ int is_schema_valid(rapidjson::Document &d) const char *cfg_schema = "{" "\"type\": \"object\"," - "\"required\": [ \"version\", \"pubkeyhex\", \"seckeyhex\", \"keytype\", \"binary\", \"binargs\", \"listenip\"" + "\"required\": [ \"version\", \"pubkeyhex\", \"seckeyhex\", \"binary\", \"binargs\", \"listenip\"" ", \"peers\", \"unl\", \"peerport\", \"roundtime\", \"pubport\", \"pubmaxsize\", \"pubmaxcpm\" ]," "\"properties\": {" "\"version\": { \"type\": \"string\" }," "\"pubkeyhex\": { \"type\": \"string\" }," "\"seckeyhex\": { \"type\": \"string\" }," - "\"keytype\": { \"type\": \"string\" }," "\"binary\": { \"type\": \"string\" }," "\"binargs\": { \"type\": \"string\" }," "\"listenip\": { \"type\": \"string\" }," diff --git a/src/conf.hpp b/src/conf.hpp index d5430310..0c8cfb56 100644 --- a/src/conf.hpp +++ b/src/conf.hpp @@ -35,7 +35,6 @@ struct contract_config std::string pubkeyhex; // Contract hex public key std::string seckeyhex; // Contract hex secret key - std::string keytype; // Key generation algorithm used by libsodium std::string binary; // Full path to the contract binary std::string binargs; // CLI arguments to pass to the contract binary std::string listenip; // The IPs to listen on for incoming connections diff --git a/src/crypto.cpp b/src/crypto.cpp index 9ba30912..9e75a04f 100644 --- a/src/crypto.cpp +++ b/src/crypto.cpp @@ -21,10 +21,10 @@ int init() return 0; } -/** +/**l * Generates a signing key pair using libsodium and assigns them to the provided strings. */ -void generate_signing_keys(std::string &pubkey, std::string &seckey, std::string &keytype) +void generate_signing_keys(std::string &pubkey, std::string &seckey) { // Generate key pair using libsodium default algorithm. // Currently using ed25519. So append prefix byte to represent that. @@ -36,10 +36,8 @@ void generate_signing_keys(std::string &pubkey, std::string &seckey, std::string seckey[0] = KEYPFX_ed25519; crypto_sign_keypair( - reinterpret_cast(pubkey.data() + 1), - reinterpret_cast(seckey.data() + 1)); - - keytype = crypto_sign_primitive(); + reinterpret_cast(pubkey.data() + 1), // +1 to skip the prefix byte. + reinterpret_cast(seckey.data() + 1)); // +1 to skip the prefix byte. } /** diff --git a/src/crypto.hpp b/src/crypto.hpp index d1591f28..e86324c3 100644 --- a/src/crypto.hpp +++ b/src/crypto.hpp @@ -19,7 +19,7 @@ static size_t PFXD_SECKEY_BYTES = crypto_sign_SECRETKEYBYTES + 1; int init(); -void generate_signing_keys(std::string &pubkey, std::string &seckey, std::string &keytype); +void generate_signing_keys(std::string &pubkey, std::string &seckey); std::string sign(std::string_view msg, std::string_view seckey);