Electroneum
Toggle main menu visibility
Loading...
Searching...
No Matches
device_cold.hpp
Go to the documentation of this file.
1
// Copyright (c) 2017-2019, The Monero Project
2
//
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without modification, are
6
// permitted provided that the following conditions are met:
7
//
8
// 1. Redistributions of source code must retain the above copyright notice, this list of
9
// conditions and the following disclaimer.
10
//
11
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
// of conditions and the following disclaimer in the documentation and/or other
13
// materials provided with the distribution.
14
//
15
// 3. Neither the name of the copyright holder nor the names of its contributors may be
16
// used to endorse or promote products derived from this software without specific
17
// prior written permission.
18
//
19
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
//
29
30
#ifndef ELECTRONEUM_DEVICE_COLD_H
31
#define ELECTRONEUM_DEVICE_COLD_H
32
33
#include "
wallet/wallet2.h
"
34
#include <boost/optional/optional.hpp>
35
#include <boost/function.hpp>
36
37
38
namespace
hw
{
39
40
typedef
struct
wallet_shim
{
41
boost::function<
crypto::public_key
(
const
tools::wallet2::transfer_details
&td)>
get_tx_pub_key_from_received_outs
;
42
}
wallet_shim
;
43
44
class
tx_aux_data
{
45
public
:
46
std::vector<std::string>
tx_device_aux
;
// device generated aux data
47
std::vector<cryptonote::address_parse_info>
tx_recipients
;
// as entered by user
48
boost::optional<int>
bp_version
;
// BP version to use
49
boost::optional<unsigned>
client_version
;
// Signing client version to use (testing)
50
};
51
52
class
device_cold
{
53
public
:
54
55
using
exported_key_image
= std::vector<std::pair<crypto::key_image, crypto::signature>>;
56
57
class
op_progress
:
public
hw::device_progress
{
58
public
:
59
op_progress
():
m_progress
(0),
m_indeterminate
(
false
) {};
60
explicit
op_progress
(
double
progress
,
bool
indeterminate
=
false
):
m_progress
(
progress
),
m_indeterminate
(
indeterminate
){}
61
62
double
progress
()
const override
{
return
m_progress
; }
63
bool
indeterminate
()
const override
{
return
m_indeterminate
; }
64
protected
:
65
double
m_progress
;
66
bool
m_indeterminate
;
67
};
68
69
class
tx_progress
:
public
op_progress
{
70
public
:
71
tx_progress
():
72
m_cur_tx
(0),
m_max_tx
(1),
73
m_cur_step
(0),
m_max_step
(1),
74
m_cur_substep
(0),
m_max_substep
(1){};
75
76
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):
77
m_cur_tx
(cur_tx),
m_max_tx
(max_tx),
78
m_cur_step
(cur_tx),
m_max_step
(max_tx),
79
m_cur_substep
(cur_tx),
m_max_substep
(max_tx){}
80
81
double
progress
()
const override
{
82
return
std::max(1.0, (
double
)
m_cur_tx
/
m_max_tx
83
+ (
double
)
m_cur_step
/ (
m_max_tx
*
m_max_step
)
84
+ (
double
)
m_cur_substep
/ (
m_max_tx
*
m_max_step
*
m_max_substep
));
85
}
86
bool
indeterminate
()
const override
{
return
false
; }
87
88
protected
:
89
size_t
m_cur_tx
;
90
size_t
m_max_tx
;
91
size_t
m_cur_step
;
92
size_t
m_max_step
;
93
size_t
m_cur_substep
;
94
size_t
m_max_substep
;
95
};
96
97
typedef
struct
{
98
std::string
salt1
;
99
std::string
salt2
;
100
std::string
tx_enc_keys
;
101
std::string
tx_prefix_hash
;
102
}
tx_key_data_t
;
103
107
virtual
void
ki_sync
(
wallet_shim
* wallet,
108
const
std::vector<::tools::wallet2::transfer_details> & transfers,
109
exported_key_image
& ski) =0;
110
114
virtual
void
tx_sign
(
wallet_shim
* wallet,
115
const ::tools::wallet2::unsigned_tx_set & unsigned_tx,
116
::tools::wallet2::signed_tx_set
& signed_tx,
117
tx_aux_data
& aux_data) =0;
118
122
virtual
bool
is_get_tx_key_supported
()
const
{
return
false
; }
123
127
virtual
void
load_tx_key_data
(
tx_key_data_t
&
res
,
const
std::string &
tx_aux_data
) =0;
128
132
virtual
void
get_tx_key
(
133
std::vector<::crypto::secret_key> & tx_keys,
134
const
tx_key_data_t
&
tx_aux_data
,
135
const ::crypto::secret_key & view_key_priv) =0;
136
140
virtual
bool
is_live_refresh_supported
()
const
{
return
false
; };
141
145
virtual
void
live_refresh_start
() =0;
146
150
virtual
void
live_refresh
(
151
const ::crypto::secret_key & view_key_priv,
152
const
crypto::public_key
& out_key,
153
const
crypto::key_derivation
& recv_derivation,
154
size_t
real_output_index,
155
const
cryptonote::subaddress_index
& received_index,
156
cryptonote::keypair
& in_ephemeral,
157
crypto::key_image
& ki
158
) =0;
159
163
virtual
void
live_refresh_finish
() =0;
164
};
165
}
166
167
#endif
//ELECTRONEUM_DEVICE_COLD_H
hw::device_cold::op_progress::progress
double progress() const override
Definition
device_cold.hpp:62
hw::device_cold::op_progress::op_progress
op_progress(double progress, bool indeterminate=false)
Definition
device_cold.hpp:60
hw::device_cold::op_progress::indeterminate
bool indeterminate() const override
Definition
device_cold.hpp:63
hw::device_cold::op_progress::m_indeterminate
bool m_indeterminate
Definition
device_cold.hpp:66
hw::device_cold::op_progress::m_progress
double m_progress
Definition
device_cold.hpp:65
hw::device_cold::op_progress::op_progress
op_progress()
Definition
device_cold.hpp:59
hw::device_cold::tx_progress::tx_progress
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)
Definition
device_cold.hpp:76
hw::device_cold::tx_progress::m_max_tx
size_t m_max_tx
Definition
device_cold.hpp:90
hw::device_cold::tx_progress::indeterminate
bool indeterminate() const override
Definition
device_cold.hpp:86
hw::device_cold::tx_progress::m_max_substep
size_t m_max_substep
Definition
device_cold.hpp:94
hw::device_cold::tx_progress::m_cur_substep
size_t m_cur_substep
Definition
device_cold.hpp:93
hw::device_cold::tx_progress::m_max_step
size_t m_max_step
Definition
device_cold.hpp:92
hw::device_cold::tx_progress::tx_progress
tx_progress()
Definition
device_cold.hpp:71
hw::device_cold::tx_progress::progress
double progress() const override
Definition
device_cold.hpp:81
hw::device_cold::tx_progress::m_cur_step
size_t m_cur_step
Definition
device_cold.hpp:91
hw::device_cold::tx_progress::m_cur_tx
size_t m_cur_tx
Definition
device_cold.hpp:89
hw::device_cold
Definition
device_cold.hpp:52
hw::device_cold::live_refresh_start
virtual void live_refresh_start()=0
hw::device_cold::tx_sign
virtual void tx_sign(wallet_shim *wallet, const ::tools::wallet2::unsigned_tx_set &unsigned_tx, ::tools::wallet2::signed_tx_set &signed_tx, tx_aux_data &aux_data)=0
hw::device_cold::exported_key_image
std::vector< std::pair< crypto::key_image, crypto::signature > > exported_key_image
Definition
device_cold.hpp:55
hw::device_cold::live_refresh
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
hw::device_cold::is_get_tx_key_supported
virtual bool is_get_tx_key_supported() const
Definition
device_cold.hpp:122
hw::device_cold::ki_sync
virtual void ki_sync(wallet_shim *wallet, const std::vector<::tools::wallet2::transfer_details > &transfers, exported_key_image &ski)=0
hw::device_cold::load_tx_key_data
virtual void load_tx_key_data(tx_key_data_t &res, const std::string &tx_aux_data)=0
hw::device_cold::live_refresh_finish
virtual void live_refresh_finish()=0
hw::device_cold::is_live_refresh_supported
virtual bool is_live_refresh_supported() const
Definition
device_cold.hpp:140
hw::device_cold::get_tx_key
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
hw::device_progress
Definition
device.hpp:71
hw::tx_aux_data
Definition
device_cold.hpp:44
hw::tx_aux_data::tx_device_aux
std::vector< std::string > tx_device_aux
Definition
device_cold.hpp:46
hw::tx_aux_data::client_version
boost::optional< unsigned > client_version
Definition
device_cold.hpp:49
hw::tx_aux_data::bp_version
boost::optional< int > bp_version
Definition
device_cold.hpp:48
hw::tx_aux_data::tx_recipients
std::vector< cryptonote::address_parse_info > tx_recipients
Definition
device_cold.hpp:47
res
const char * res
Definition
hmac_keccak.cpp:41
crypto::key_derivation
POD_CLASS key_derivation
Definition
crypto.h:101
crypto::public_key
POD_CLASS public_key
Definition
crypto.h:79
crypto::key_image
POD_CLASS key_image
Definition
crypto.h:105
hw
Definition
device.cpp:38
hw::wallet_shim
struct hw::wallet_shim wallet_shim
false
#define false
cryptonote::keypair
Definition
cryptonote_basic.h:509
cryptonote::subaddress_index
Definition
subaddress_index.h:39
hw::device_cold::tx_key_data_t
Definition
device_cold.hpp:97
hw::device_cold::tx_key_data_t::salt1
std::string salt1
Definition
device_cold.hpp:98
hw::device_cold::tx_key_data_t::tx_prefix_hash
std::string tx_prefix_hash
Definition
device_cold.hpp:101
hw::device_cold::tx_key_data_t::tx_enc_keys
std::string tx_enc_keys
Definition
device_cold.hpp:100
hw::device_cold::tx_key_data_t::salt2
std::string salt2
Definition
device_cold.hpp:99
hw::wallet_shim
Definition
device_cold.hpp:40
hw::wallet_shim::get_tx_pub_key_from_received_outs
boost::function< crypto::public_key(const tools::wallet2::transfer_details &td)> get_tx_pub_key_from_received_outs
Definition
device_cold.hpp:41
tools::wallet2::signed_tx_set
Definition
wallet2.h:504
tools::wallet2::transfer_details
Definition
wallet2.h:302
wallet2.h
src
device
device_cold.hpp
Generated on
for Electroneum by
1.17.0