38 #include <boost/thread/mutex.hpp> 39 #include <boost/thread/recursive_mutex.hpp> 46 #define MINIMAL_APP_VERSION_MAJOR 1 47 #define MINIMAL_APP_VERSION_MINOR 0 48 #define MINIMAL_APP_VERSION_MICRO 0 50 #define VERSION(M,m,u) ((M)<<16|(m)<<8|(u)) 51 #define VERSION_MAJOR(v) (((v)>>16)&0xFF) 52 #define VERSION_MINOR(v) (((v)>>8)&0xFF) 53 #define VERSION_MICRO(v) (((v)>>0)&0xFF) 55 #define MINIMAL_APP_VERSION VERSION(MINIMAL_APP_VERSION_MAJOR, MINIMAL_APP_VERSION_MINOR, MINIMAL_APP_VERSION_MICRO) 59 #ifdef WITH_DEVICE_LEDGER 62 bool apdu_verbose =
true;
65 void set_apdu_verbose(
bool verbose);
72 bool is_change_address;
77 ABPkeys(
const rct::key&
A,
const rct::key& B,
const bool is_subaddr,
bool is_subaddress,
bool is_change_address,
size_t index,
const rct::key& P,
const rct::key& AK);
78 ABPkeys(
const ABPkeys& keys) ;
79 ABPkeys() {index=0;is_subaddress=
false;is_change_address=
false;additional_key=
false;}
85 std::vector<ABPkeys> ABP;
87 bool find(
const rct::key& P, ABPkeys& keys)
const;
88 void add(
const ABPkeys& keys);
104 std::vector<SecHMAC> hmacs;
112 #define BUFFER_SEND_SIZE 262 113 #define BUFFER_RECV_SIZE 262 118 mutable boost::recursive_mutex device_locker;
119 mutable boost::mutex command_locker;
122 hw::io::device_io_hid hw_device;
123 unsigned int length_send;
124 unsigned char buffer_send[BUFFER_SEND_SIZE];
125 unsigned int length_recv;
126 unsigned char buffer_recv[BUFFER_RECV_SIZE];
131 unsigned int exchange(
unsigned int ok=0x9000,
unsigned int mask=0xFFFF);
132 unsigned int exchange_wait_on_input(
unsigned int ok=0x9000,
unsigned int mask=0xFFFF);
133 void reset_buffer(
void);
134 int set_command_header(
unsigned char ins,
unsigned char p1 = 0x00,
unsigned char p2 = 0x00);
135 int set_command_header_noopt(
unsigned char ins,
unsigned char p1 = 0x00,
unsigned char p2 = 0x00);
136 void send_simple(
unsigned char ins,
unsigned char p1 = 0x00);
137 void send_secret(
const unsigned char sec[32],
int &offset);
138 void receive_secret(
unsigned char sec[32],
int &offset);
147 const bool need_additional,
const size_t real_output_index,
157 #ifdef DEBUG_HWDEVICE 158 device *controle_device;
165 device_ledger(
const device_ledger &device) = delete ;
166 device_ledger&
operator=(
const device_ledger &device) =
delete;
168 explicit operator bool()
const override {
return this->connected(); }
178 bool init(
void)
override;
179 bool release()
override;
180 bool connect(
void)
override;
181 bool disconnect()
override;
182 bool connected(
void)
const;
184 bool set_mode(device_mode mode)
override;
186 device_type get_type()
const override {
return device_type::LEDGER;};
187 device_protocol_t device_protocol()
const override {
return PROTOCOL_PROXY; };
192 void lock(
void)
override;
193 void unlock(
void)
override;
194 bool try_lock(
void)
override;
250 const bool &need_additional_txkeys,
const std::vector<crypto::secret_key> &additional_tx_keys,
251 std::vector<crypto::public_key> &additional_tx_public_keys,
252 std::vector<rct::key> &amount_keys,
261 bool close_tx(
void)
override;
265 const std::vector<const crypto::public_key *> &pubsvector,
274 #ifdef DEBUG_HWDEVICE 279 #endif //WITH_DEVICE_LEDGER
void derivation_to_scalar(const key_derivation &derivation, size_t output_index, ec_scalar &res)
void derive_secret_key(const key_derivation &derivation, std::size_t output_index, const secret_key &base, secret_key &derived_key)
void scalarmultKey(key &aP, const key &P, const key &a)
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
void register_all(std::map< std::string, std::unique_ptr< device >> ®istry)
void generate_input_signature(const hash prefix_hash, const uint32_t input_index, const secret_key sec_view, const secret_key sec_spend, signature &sig)
void ecdhEncode(ecdhTuple &unmasked, const key &sharedSec, bool v2)
struct hash_func hashes[]
key genCommitmentMask(const key &sk)
bool generate_key_derivation(const public_key &key1, const secret_key &key2, key_derivation &derivation)
void generate_tx_proof(const hash &prefix_hash, const public_key &R, const public_key &A, const boost::optional< public_key > &B, const public_key &D, const secret_key &r, signature &sig)
void generate_key_image(const public_key &pub, const secret_key &sec, key_image &image)
cryptonote::simple_wallet sw
bool derive_subaddress_public_key(const public_key &out_key, const key_derivation &derivation, std::size_t output_index, public_key &result)
void generate_ring_signature(const hash &prefix_hash, const key_image &image, const public_key *const *pubs, std::size_t pubs_count, const secret_key &sec, std::size_t sec_index, signature *sig)
std::vector< ctkey > ctkeyV
unsigned __int64 uint64_t
secret_key generate_keys(public_key &pub, secret_key &sec, const secret_key &recovery_key=secret_key(), bool recover=false)
void ecdhDecode(ecdhTuple &masked, const key &sharedSec, bool v2)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
void scalarmultBase(key &aG, const key &a)
void get_transaction_prefix_hash(const transaction_prefix &tx, crypto::hash &h)
void hash_to_scalar(const void *data, std::size_t length, crypto::ec_scalar &res)
bool derive_public_key(const key_derivation &derivation, std::size_t output_index, const public_key &base, public_key &derived_key)
connection< TProtocol > & operator=(const connection< TProtocol > &obj)
bool generate_output_ephemeral_keys(const size_t tx_version, const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key, const cryptonote::tx_destination_entry &dst_entr, const boost::optional< cryptonote::account_public_address > &change_addr, const size_t output_index, const bool &need_additional_txkeys, const std::vector< crypto::secret_key > &additional_tx_keys, std::vector< crypto::public_key > &additional_tx_public_keys, std::vector< rct::key > &amount_keys, crypto::public_key &out_eph_public_key)
bool secret_key_to_public_key(const secret_key &sec, public_key &pub)
void verbose(enum verbosity_value level, const char *format,...) ATTR_FORMAT(printf