aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstoffu <stoffu@protonmail.ch>2018-03-05 17:02:17 +0900
committerstoffu <stoffu@protonmail.ch>2018-03-14 21:00:16 +0900
commit8705beaf51c12d7eab5f56f615ec529a2a8efc27 (patch)
treedc783650bd3ffe9b7baef0ae9ab4435dc1dc69a8
parentdevice: untangle cyclic depenency (diff)
downloadmonero-8705beaf51c12d7eab5f56f615ec529a2a8efc27.tar.xz
keypair::generate: always require hw::device to avoid possible mistake
-rw-r--r--src/cryptonote_basic/cryptonote_basic.h6
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.cpp2
-rw-r--r--src/device/device_default.cpp2
-rw-r--r--tests/core_tests/chaingen.cpp2
-rw-r--r--tests/core_tests/tx_validation.cpp4
-rw-r--r--tests/performance_tests/generate_keypair.h2
6 files changed, 6 insertions, 12 deletions
diff --git a/src/cryptonote_basic/cryptonote_basic.h b/src/cryptonote_basic/cryptonote_basic.h
index 12124ebf5..d4558ef7b 100644
--- a/src/cryptonote_basic/cryptonote_basic.h
+++ b/src/cryptonote_basic/cryptonote_basic.h
@@ -429,12 +429,6 @@ namespace cryptonote
crypto::public_key pub;
crypto::secret_key sec;
- static inline keypair generate()
- {
- keypair k;
- generate_keys(k.pub, k.sec);
- return k;
- }
static inline keypair generate(hw::device &hwdev)
{
keypair k;
diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp
index cbacc7893..db4ab9e11 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.cpp
+++ b/src/cryptonote_core/cryptonote_tx_utils.cpp
@@ -78,7 +78,7 @@ namespace cryptonote
tx.vout.clear();
tx.extra.clear();
- keypair txkey = keypair::generate();
+ keypair txkey = keypair::generate(hw::get_device("default"));
add_tx_pub_key_to_extra(tx, txkey.pub);
if(!extra_nonce.empty())
if(!add_extra_nonce_to_tx_extra(tx.extra, extra_nonce))
diff --git a/src/device/device_default.cpp b/src/device/device_default.cpp
index 6d60c8cc1..d63dafe9e 100644
--- a/src/device/device_default.cpp
+++ b/src/device/device_default.cpp
@@ -251,7 +251,7 @@ namespace hw {
/* ======================================================================= */
bool device_default::open_tx(crypto::secret_key &tx_key) {
- cryptonote::keypair txkey = cryptonote::keypair::generate();
+ cryptonote::keypair txkey = cryptonote::keypair::generate(*this);
tx_key = txkey.sec;
return true;
}
diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp
index 5e1525e3e..41256a4f1 100644
--- a/tests/core_tests/chaingen.cpp
+++ b/tests/core_tests/chaingen.cpp
@@ -521,7 +521,7 @@ bool construct_miner_tx_manually(size_t height, uint64_t already_generated_coins
keypair* p_txkey/* = 0*/)
{
keypair txkey;
- txkey = keypair::generate();
+ txkey = keypair::generate(hw::get_device("default"));
add_tx_pub_key_to_extra(tx, txkey.pub);
if (0 != p_txkey)
diff --git a/tests/core_tests/tx_validation.cpp b/tests/core_tests/tx_validation.cpp
index d6d5236aa..f0a385ee5 100644
--- a/tests/core_tests/tx_validation.cpp
+++ b/tests/core_tests/tx_validation.cpp
@@ -49,7 +49,7 @@ namespace
m_tx.version = version;
m_tx.unlock_time = unlock_time;
- m_tx_key = keypair::generate();
+ m_tx_key = keypair::generate(hw::get_device("default"));
add_tx_pub_key_to_extra(m_tx, m_tx_key.pub);
}
@@ -518,7 +518,7 @@ bool gen_tx_key_image_not_derive_from_tx_key::generate(std::vector<test_event_en
builder.step2_fill_inputs(miner_account.get_keys(), sources);
txin_to_key& in_to_key = boost::get<txin_to_key>(builder.m_tx.vin.front());
- keypair kp = keypair::generate();
+ keypair kp = keypair::generate(hw::get_device("default"));
key_image another_ki;
crypto::generate_key_image(kp.pub, kp.sec, another_ki);
in_to_key.k_image = another_ki;
diff --git a/tests/performance_tests/generate_keypair.h b/tests/performance_tests/generate_keypair.h
index f97f4c213..91c830166 100644
--- a/tests/performance_tests/generate_keypair.h
+++ b/tests/performance_tests/generate_keypair.h
@@ -45,7 +45,7 @@ public:
bool test()
{
- cryptonote::keypair::generate();
+ cryptonote::keypair::generate(hw::get_device("default"));
return true;
}
};