aboutsummaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2019-03-21 14:44:03 +0200
committerRiccardo Spagni <ric@spagni.net>2019-03-21 14:44:04 +0200
commit48e3a341f8bb601895c94e7b637475f8911ae530 (patch)
tree393b21c46c390e9510923da70ce3b934b7b87adc /src/device
parentMerge pull request #5208 (diff)
parenttests/trezor: HF9 and HF10 tests (diff)
downloadmonero-48e3a341f8bb601895c94e7b637475f8911ae530.tar.xz
Merge pull request #5211
c9b13fbb tests/trezor: HF9 and HF10 tests (Dusan Klinec) a1fd1d49 device/trezor: HF10 support added, wallet::API (Dusan Klinec) d74d26f2 crypto: hmac_keccak added (Dusan Klinec)
Diffstat (limited to 'src/device')
-rw-r--r--src/device/device.hpp21
-rw-r--r--src/device/device_cold.hpp96
2 files changed, 113 insertions, 4 deletions
diff --git a/src/device/device.hpp b/src/device/device.hpp
index 7f1a60c9f..65b38361b 100644
--- a/src/device/device.hpp
+++ b/src/device/device.hpp
@@ -70,6 +70,7 @@ namespace cryptonote
struct account_keys;
struct subaddress_index;
struct tx_destination_entry;
+ struct keypair;
}
namespace hw {
@@ -81,11 +82,18 @@ namespace hw {
return false;
}
+ class device_progress {
+ public:
+ virtual double progress() const { return 0; }
+ virtual bool indeterminate() const { return false; }
+ };
+
class i_device_callback {
public:
- virtual void on_button_request() {}
- virtual void on_pin_request(epee::wipeable_string & pin) {}
- virtual void on_passphrase_request(bool on_device, epee::wipeable_string & passphrase) {}
+ virtual void on_button_request(uint64_t code=0) {}
+ virtual boost::optional<epee::wipeable_string> on_pin_request() { return boost::none; }
+ virtual boost::optional<epee::wipeable_string> on_passphrase_request(bool on_device) { return boost::none; }
+ virtual void on_progress(const device_progress& event) {}
virtual ~i_device_callback() = default;
};
@@ -141,6 +149,9 @@ namespace hw {
virtual void set_callback(i_device_callback * callback) {};
virtual void set_derivation_path(const std::string &derivation_path) {};
+ virtual void set_pin(const epee::wipeable_string & pin) {}
+ virtual void set_passphrase(const epee::wipeable_string & passphrase) {}
+
/* ======================================================================= */
/* LOCKER */
/* ======================================================================= */
@@ -229,7 +240,9 @@ namespace hw {
virtual bool has_ki_cold_sync(void) const { return false; }
virtual bool has_tx_cold_sign(void) const { return false; }
-
+ virtual bool has_ki_live_refresh(void) const { return true; }
+ virtual bool compute_key_image(const cryptonote::account_keys& ack, const crypto::public_key& out_key, const crypto::key_derivation& recv_derivation, size_t real_output_index, const cryptonote::subaddress_index& received_index, cryptonote::keypair& in_ephemeral, crypto::key_image& ki) { return false; }
+ virtual void computing_key_images(bool started) {};
virtual void set_network_type(cryptonote::network_type network_type) { }
protected:
diff --git a/src/device/device_cold.hpp b/src/device/device_cold.hpp
index 8b8cdf6d2..31b1504ab 100644
--- a/src/device/device_cold.hpp
+++ b/src/device/device_cold.hpp
@@ -31,6 +31,7 @@
#define MONERO_DEVICE_COLD_H
#include "wallet/wallet2.h"
+#include <boost/optional/optional.hpp>
#include <boost/function.hpp>
@@ -44,6 +45,8 @@ namespace hw {
public:
std::vector<std::string> tx_device_aux; // device generated aux data
std::vector<cryptonote::address_parse_info> tx_recipients; // as entered by user
+ boost::optional<int> bp_version; // BP version to use
+ boost::optional<unsigned> client_version; // Signing client version to use (testing)
};
class device_cold {
@@ -51,6 +54,53 @@ namespace hw {
using exported_key_image = std::vector<std::pair<crypto::key_image, crypto::signature>>;
+ class op_progress : public hw::device_progress {
+ public:
+ op_progress():m_progress(0), m_indeterminate(false) {};
+ explicit op_progress(double progress, bool indeterminate=false): m_progress(progress), m_indeterminate(indeterminate){}
+
+ double progress() const override { return m_progress; }
+ bool indeterminate() const override { return m_indeterminate; }
+ protected:
+ double m_progress;
+ bool m_indeterminate;
+ };
+
+ class tx_progress : public op_progress {
+ public:
+ tx_progress():
+ m_cur_tx(0), m_max_tx(1),
+ m_cur_step(0), m_max_step(1),
+ m_cur_substep(0), m_max_substep(1){};
+
+ tx_progress(size_t cur_tx, size_t max_tx, size_t cur_step, size_t max_step, size_t cur_substep, size_t max_substep):
+ m_cur_tx(cur_tx), m_max_tx(max_tx),
+ m_cur_step(cur_tx), m_max_step(max_tx),
+ m_cur_substep(cur_tx), m_max_substep(max_tx){}
+
+ double progress() const override {
+ return std::max(1.0, (double)m_cur_tx / m_max_tx
+ + (double)m_cur_step / (m_max_tx * m_max_step)
+ + (double)m_cur_substep / (m_max_tx * m_max_step * m_max_substep));
+ }
+ bool indeterminate() const override { return false; }
+
+ protected:
+ size_t m_cur_tx;
+ size_t m_max_tx;
+ size_t m_cur_step;
+ size_t m_max_step;
+ size_t m_cur_substep;
+ size_t m_max_substep;
+ };
+
+ typedef struct {
+ std::string salt1;
+ std::string salt2;
+ std::string tx_enc_keys;
+ std::string tx_prefix_hash;
+ } tx_key_data_t;
+
/**
* Key image sync with the cold protocol.
*/
@@ -65,6 +115,52 @@ namespace hw {
const ::tools::wallet2::unsigned_tx_set & unsigned_tx,
::tools::wallet2::signed_tx_set & signed_tx,
tx_aux_data & aux_data) =0;
+
+ /**
+ * Get tx key support check.
+ */
+ virtual bool is_get_tx_key_supported() const { return false; }
+
+ /**
+ * Loads TX aux data required for tx key.
+ */
+ virtual void load_tx_key_data(tx_key_data_t & res, const std::string & tx_aux_data) =0;
+
+ /**
+ * Decrypts TX keys.
+ */
+ virtual void get_tx_key(
+ std::vector<::crypto::secret_key> & tx_keys,
+ const tx_key_data_t & tx_aux_data,
+ const ::crypto::secret_key & view_key_priv) =0;
+
+ /**
+ * Live refresh support check
+ */
+ virtual bool is_live_refresh_supported() const { return false; };
+
+ /**
+ * Starts live refresh process with the device
+ */
+ virtual void live_refresh_start() =0;
+
+ /**
+ * One live refresh step
+ */
+ virtual void live_refresh(
+ const ::crypto::secret_key & view_key_priv,
+ const crypto::public_key& out_key,
+ const crypto::key_derivation& recv_derivation,
+ size_t real_output_index,
+ const cryptonote::subaddress_index& received_index,
+ cryptonote::keypair& in_ephemeral,
+ crypto::key_image& ki
+ ) =0;
+
+ /**
+ * Live refresh process termination
+ */
+ virtual void live_refresh_finish() =0;
};
}