Electroneum
Loading...
Searching...
No Matches
hw::core::device_default Class Reference

#include <device_default.hpp>

Inheritance diagram for hw::core::device_default:
Collaboration diagram for hw::core::device_default:

Public Member Functions

 device_default ()
 ~device_default ()
 device_default (const device_default &device)=delete
device_defaultoperator= (const device_default &device)=delete
 operator bool () const override
bool set_name (const std::string &name) override
const std::string get_name () const override
bool init (void) override
bool release () override
bool connect (void) override
bool disconnect () override
bool set_mode (device_mode mode) override
device_type get_type () const override
void lock (void) override
void unlock (void) override
bool try_lock (void) override
bool get_public_address (cryptonote::account_public_address &pubkey) override
bool get_secret_keys (crypto::secret_key &viewkey, crypto::secret_key &spendkey) override
bool generate_chacha_key (const cryptonote::account_keys &keys, crypto::chacha_key &key, uint64_t kdf_rounds) override
bool derive_subaddress_public_key (const crypto::public_key &pub, const crypto::key_derivation &derivation, const std::size_t output_index, crypto::public_key &derived_pub) override
crypto::public_key get_subaddress_spend_public_key (const cryptonote::account_keys &keys, const cryptonote::subaddress_index &index) override
std::vector< crypto::public_keyget_subaddress_spend_public_keys (const cryptonote::account_keys &keys, uint32_t account, uint32_t begin, uint32_t end) override
cryptonote::account_public_address get_subaddress (const cryptonote::account_keys &keys, const cryptonote::subaddress_index &index) override
crypto::secret_key get_subaddress_secret_key (const crypto::secret_key &sec, const cryptonote::subaddress_index &index) override
crypto::secret_key get_subaddress_private_spendkey (const cryptonote::account_keys &keys, const cryptonote::subaddress_index &subaddr_index) override
crypto::secret_key get_subaddress_private_viewkey (const crypto::secret_key &main_wallet_sec_view, crypto::secret_key &subaddress_sec_spend) override
bool verify_keys (const crypto::secret_key &secret_key, const crypto::public_key &public_key) override
bool scalarmultKey (rct::key &aP, const rct::key &P, const rct::key &a) override
bool scalarmultBase (rct::key &aG, const rct::key &a) override
bool sc_secret_add (crypto::secret_key &r, const crypto::secret_key &a, const crypto::secret_key &b) override
crypto::secret_key generate_keys (crypto::public_key &pub, crypto::secret_key &sec, const crypto::secret_key &recovery_key=crypto::secret_key(), bool recover=false) override
bool generate_key_derivation (const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_derivation &derivation) override
bool conceal_derivation (crypto::key_derivation &derivation, const crypto::public_key &tx_pub_key, const std::vector< crypto::public_key > &additional_tx_pub_keys, const crypto::key_derivation &main_derivation, const std::vector< crypto::key_derivation > &additional_derivations) override
bool derivation_to_scalar (const crypto::key_derivation &derivation, const size_t output_index, crypto::ec_scalar &res) override
bool derive_secret_key (const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::secret_key &sec, crypto::secret_key &derived_sec) override
bool derive_public_key (const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::public_key &pub, crypto::public_key &derived_pub) override
bool secret_key_to_public_key (const crypto::secret_key &sec, crypto::public_key &pub) override
bool generate_key_image (const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_image &image) override
void generate_tx_proof (const crypto::hash &prefix_hash, const crypto::public_key &R, const crypto::public_key &A, const boost::optional< crypto::public_key > &B, const crypto::public_key &D, const crypto::secret_key &r, crypto::signature &sig) override
bool open_tx (crypto::secret_key &tx_key) override
bool encrypt_payment_id (crypto::hash8 &payment_id, const crypto::public_key &public_key, const crypto::secret_key &secret_key) override
rct::key genCommitmentMask (const rct::key &amount_key) override
bool ecdhEncode (rct::ecdhTuple &unmasked, const rct::key &sharedSec, bool short_amount) override
bool ecdhDecode (rct::ecdhTuple &masked, const rct::key &sharedSec, bool short_amount) override
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) override
bool mlsag_prehash (const std::string &blob, size_t inputs_size, size_t outputs_size, const rct::keyV &hashes, const rct::ctkeyV &outPk, rct::key &prehash) override
bool mlsag_prepare (const rct::key &H, const rct::key &xx, rct::key &a, rct::key &aG, rct::key &aHP, rct::key &rvII) override
bool mlsag_prepare (rct::key &a, rct::key &aG) override
bool mlsag_hash (const rct::keyV &long_message, rct::key &c) override
bool mlsag_sign (const rct::key &c, const rct::keyV &xx, const rct::keyV &alpha, const size_t rows, const size_t dsRows, rct::keyV &ss) override
bool close_tx (void) override
bool get_transaction_prefix_hash (const cryptonote::transaction_prefix &tx, crypto::hash &tx_prefix_hash) override
bool generate_ring_signature (const crypto::hash &prefix_hash, const crypto::key_image &image, const std::vector< const crypto::public_key * > &pubs, const crypto::secret_key &sec, std::size_t sec_index, crypto::signature *sig) override
bool generate_input_signature (const crypto::hash &prefix_hash, const uint32_t input_index, const crypto::secret_key sec_view, const crypto::secret_key sec_spend, crypto::signature &signature) override
bool hash_to_scalar (boost::shared_ptr< crypto::rs_comm > buf, size_t length, crypto::ec_scalar &res) override
Public Member Functions inherited from hw::device
 device ()
 device (const device &hwdev)
virtual ~device ()
virtual device_mode get_mode () const
virtual device_protocol_t device_protocol () const
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)
rct::key scalarmultKey (const rct::key &P, const rct::key &a)
rct::key scalarmultBase (const rct::key &a)
bool decrypt_payment_id (crypto::hash8 &payment_id, const crypto::public_key &public_key, const crypto::secret_key &secret_key)
virtual bool has_ki_cold_sync (void) const
virtual bool has_tx_cold_sign (void) const
virtual bool has_ki_live_refresh (void) const
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)
virtual void computing_key_images (bool started)
virtual void set_network_type (cryptonote::network_type network_type)

Additional Inherited Members

Public Types inherited from hw::device
enum  device_mode { NONE , TRANSACTION_CREATE_REAL , TRANSACTION_CREATE_FAKE , TRANSACTION_PARSE }
enum  device_type { SOFTWARE = 0 , LEDGER = 1 , TREZOR = 2 }
enum  device_protocol_t { PROTOCOL_DEFAULT , PROTOCOL_PROXY , PROTOCOL_COLD }
Protected Attributes inherited from hw::device
std::string name
device_mode mode

Detailed Description

Definition at line 40 of file device_default.hpp.

Constructor & Destructor Documentation

◆ device_default() [1/2]

hw::core::device_default::device_default ( )

Definition at line 47 of file device_default.cpp.

47{ }
Here is the caller graph for this function:

◆ ~device_default()

hw::core::device_default::~device_default ( )

Definition at line 49 of file device_default.cpp.

49{ }

◆ device_default() [2/2]

hw::core::device_default::device_default ( const device_default & device)
delete
Here is the call graph for this function:

Member Function Documentation

◆ close_tx()

bool hw::core::device_default::close_tx ( void )
overridevirtual

Implements hw::device.

Definition at line 422 of file device_default.cpp.

422 {
423 return true;
424 }
Here is the caller graph for this function:

◆ conceal_derivation()

bool hw::core::device_default::conceal_derivation ( crypto::key_derivation & derivation,
const crypto::public_key & tx_pub_key,
const std::vector< crypto::public_key > & additional_tx_pub_keys,
const crypto::key_derivation & main_derivation,
const std::vector< crypto::key_derivation > & additional_derivations )
overridevirtual

Implements hw::device.

Definition at line 287 of file device_default.cpp.

287 {
288 return true;
289 }

◆ connect()

bool hw::core::device_default::connect ( void )
overridevirtual

Implements hw::device.

Definition at line 79 of file device_default.cpp.

79 {
80 return true;
81 }

◆ derivation_to_scalar()

bool hw::core::device_default::derivation_to_scalar ( const crypto::key_derivation & derivation,
const size_t output_index,
crypto::ec_scalar & res )
overridevirtual

Implements hw::device.

Definition at line 264 of file device_default.cpp.

264 {
265 crypto::derivation_to_scalar(derivation,output_index, res);
266 return true;
267 }
const char * res
void derivation_to_scalar(const key_derivation &derivation, size_t output_index, ec_scalar &res)
Definition crypto.h:279
Here is the caller graph for this function:

◆ derive_public_key()

bool hw::core::device_default::derive_public_key ( const crypto::key_derivation & derivation,
const std::size_t output_index,
const crypto::public_key & pub,
crypto::public_key & derived_pub )
overridevirtual

Implements hw::device.

Definition at line 274 of file device_default.cpp.

274 {
275 return crypto::derive_public_key(derivation, output_index, base, derived_key);
276 }
bool derive_public_key(const key_derivation &derivation, std::size_t output_index, const public_key &base, public_key &derived_key)
Definition crypto.h:275
Here is the caller graph for this function:

◆ derive_secret_key()

bool hw::core::device_default::derive_secret_key ( const crypto::key_derivation & derivation,
const std::size_t output_index,
const crypto::secret_key & sec,
crypto::secret_key & derived_sec )
overridevirtual

Implements hw::device.

Definition at line 269 of file device_default.cpp.

269 {
270 crypto::derive_secret_key(derivation, output_index, base, derived_key);
271 return true;
272 }
void derive_secret_key(const key_derivation &derivation, std::size_t output_index, const secret_key &base, secret_key &derived_key)
Definition crypto.h:282
Here is the caller graph for this function:

◆ derive_subaddress_public_key()

bool hw::core::device_default::derive_subaddress_public_key ( const crypto::public_key & pub,
const crypto::key_derivation & derivation,
const std::size_t output_index,
crypto::public_key & derived_pub )
overridevirtual

Implements hw::device.

Definition at line 124 of file device_default.cpp.

124 {
125 return crypto::derive_subaddress_public_key(out_key, derivation, output_index,derived_key);
126 }
bool derive_subaddress_public_key(const public_key &out_key, const key_derivation &derivation, std::size_t output_index, public_key &result)
Definition crypto.h:286
Here is the call graph for this function:

◆ disconnect()

bool hw::core::device_default::disconnect ( void )
overridevirtual

Implements hw::device.

Definition at line 82 of file device_default.cpp.

82 {
83 return true;
84 }

◆ ecdhDecode()

bool hw::core::device_default::ecdhDecode ( rct::ecdhTuple & masked,
const rct::key & sharedSec,
bool short_amount )
overridevirtual

Implements hw::device.

Definition at line 384 of file device_default.cpp.

384 {
385 rct::ecdhDecode(masked, sharedSec, short_amount);
386 return true;
387 }
void ecdhDecode(ecdhTuple &masked, const key &sharedSec, bool v2)
Definition rctOps.cpp:712
Here is the caller graph for this function:

◆ ecdhEncode()

bool hw::core::device_default::ecdhEncode ( rct::ecdhTuple & unmasked,
const rct::key & sharedSec,
bool short_amount )
overridevirtual

Implements hw::device.

Definition at line 379 of file device_default.cpp.

379 {
380 rct::ecdhEncode(unmasked, sharedSec, short_amount);
381 return true;
382 }
void ecdhEncode(ecdhTuple &unmasked, const key &sharedSec, bool v2)
Definition rctOps.cpp:697
Here is the caller graph for this function:

◆ encrypt_payment_id()

bool hw::core::device_default::encrypt_payment_id ( crypto::hash8 & payment_id,
const crypto::public_key & public_key,
const crypto::secret_key & secret_key )
overridevirtual

Implements hw::device.

Definition at line 357 of file device_default.cpp.

357 {
358 crypto::key_derivation derivation;
360 char data[33]; /* A hash, and an extra byte */
361
362 if (!generate_key_derivation(public_key, secret_key, derivation))
363 return false;
364
365 memcpy(data, &derivation, 32);
366 data[32] = ENCRYPTED_PAYMENT_ID_TAIL;
367 cn_fast_hash(data, 33, hash);
368
369 for (size_t b = 0; b < 8; ++b)
370 payment_id.data[b] ^= hash.data[b];
371
372 return true;
373 }
bool generate_key_derivation(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_derivation &derivation) override
#define ENCRYPTED_PAYMENT_ID_TAIL
void * memcpy(void *a, const void *b, size_t c)
void cn_fast_hash(const void *data, size_t length, char *hash)
POD_CLASS key_derivation
Definition crypto.h:101
POD_CLASS hash
Definition hash.h:50

◆ genCommitmentMask()

rct::key hw::core::device_default::genCommitmentMask ( const rct::key & amount_key)
overridevirtual

Implements hw::device.

Definition at line 375 of file device_default.cpp.

375 {
376 return rct::genCommitmentMask(amount_key);
377 }
key genCommitmentMask(const key &sk)
Definition rctOps.cpp:687

◆ generate_chacha_key()

bool hw::core::device_default::generate_chacha_key ( const cryptonote::account_keys & keys,
crypto::chacha_key & key,
uint64_t kdf_rounds )
overridevirtual

Implements hw::device.

Definition at line 104 of file device_default.cpp.

104 {
105 const crypto::secret_key &view_key = keys.m_view_secret_key;
106 const crypto::secret_key &spend_key = keys.m_spend_secret_key;
107 epee::mlocked<tools::scrubbed_arr<char, sizeof(view_key) + sizeof(spend_key) + 1>> data;
108 memcpy(data.data(), &view_key, sizeof(view_key));
109 memcpy(data.data() + sizeof(view_key), &spend_key, sizeof(spend_key));
110 data[sizeof(data) - 1] = CHACHA8_KEY_TAIL;
111 crypto::generate_chacha_key(data.data(), sizeof(data), key, kdf_rounds);
112 return true;
113 }
#define CHACHA8_KEY_TAIL
const char * key
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition crypto.h:82
crypto::secret_key m_view_secret_key
Definition account.h:45
crypto::secret_key m_spend_secret_key
Definition account.h:44
Here is the call graph for this function:

◆ generate_input_signature()

bool hw::core::device_default::generate_input_signature ( const crypto::hash & prefix_hash,
const uint32_t input_index,
const crypto::secret_key sec_view,
const crypto::secret_key sec_spend,
crypto::signature & signature )
overridevirtual

Implements hw::device.

Definition at line 450 of file device_default.cpp.

450 {
451 crypto::generate_input_signature(prefix_hash, input_index, sec_view, sec_spend, signature);
452 return true;
453 }
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)
Definition crypto.h:299

◆ generate_key_derivation()

bool hw::core::device_default::generate_key_derivation ( const crypto::public_key & pub,
const crypto::secret_key & sec,
crypto::key_derivation & derivation )
overridevirtual

Implements hw::device.

Definition at line 260 of file device_default.cpp.

260 {
261 return crypto::generate_key_derivation(key1, key2, derivation);
262 }
bool generate_key_derivation(const public_key &key1, const secret_key &key2, key_derivation &derivation)
Definition crypto.h:272
Here is the caller graph for this function:

◆ generate_key_image()

bool hw::core::device_default::generate_key_image ( const crypto::public_key & pub,
const crypto::secret_key & sec,
crypto::key_image & image )
overridevirtual

Implements hw::device.

Definition at line 282 of file device_default.cpp.

282 {
283 crypto::generate_key_image(pub, sec,image);
284 return true;
285 }
void generate_key_image(const public_key &pub, const secret_key &sec, key_image &image)
Definition crypto.h:324
Here is the caller graph for this function:

◆ generate_keys()

crypto::secret_key hw::core::device_default::generate_keys ( crypto::public_key & pub,
crypto::secret_key & sec,
const crypto::secret_key & recovery_key = crypto::secret_key(),
bool recover = false )
overridevirtual

Implements hw::device.

Definition at line 256 of file device_default.cpp.

256 {
257 return crypto::generate_keys(pub, sec, recovery_key, recover);
258 }
secret_key generate_keys(public_key &pub, secret_key &sec, const secret_key &recovery_key=secret_key(), bool recover=false)
Definition crypto.h:250

◆ generate_output_ephemeral_keys()

bool hw::core::device_default::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 )
overridevirtual

Implements hw::device.

Definition at line 306 of file device_default.cpp.

311 {
312
313 crypto::key_derivation derivation;
314
315 // make additional tx pubkey if necessary
316 cryptonote::keypair additional_txkey;
317 if (need_additional_txkeys)
318 {
319 additional_txkey.sec = additional_tx_keys[output_index];
320 if (dst_entr.is_subaddress)
321 additional_txkey.pub = rct::rct2pk(rct::scalarmultKey(rct::pk2rct(dst_entr.addr.m_spend_public_key), rct::sk2rct(additional_txkey.sec)));
322 else
323 additional_txkey.pub = rct::rct2pk(rct::scalarmultBase(rct::sk2rct(additional_txkey.sec)));
324 }
325
326 bool r;
327 if (change_addr && dst_entr.addr == *change_addr)
328 {
329 // sending change to yourself; derivation = a*R
330 r = generate_key_derivation(txkey_pub, sender_account_keys.m_view_secret_key, derivation);
331 CHECK_AND_ASSERT_MES(r, false, "at creation outs: failed to generate_key_derivation(" << txkey_pub << ", " << sender_account_keys.m_view_secret_key << ")");
332 }
333 else
334 {
335 // sending to the recipient; derivation = r*A (or s*C in the subaddress scheme)
336 r = generate_key_derivation(dst_entr.addr.m_view_public_key, dst_entr.is_subaddress && need_additional_txkeys ? additional_txkey.sec : tx_key, derivation);
337 CHECK_AND_ASSERT_MES(r, false, "at creation outs: failed to generate_key_derivation(" << dst_entr.addr.m_view_public_key << ", " << (dst_entr.is_subaddress && need_additional_txkeys ? additional_txkey.sec : tx_key) << ")");
338 }
339
340 if (need_additional_txkeys)
341 {
342 additional_tx_public_keys.push_back(additional_txkey.pub);
343 }
344
345 if (tx_version > 1)
346 {
347 crypto::secret_key scalar1;
348 derivation_to_scalar(derivation, output_index, scalar1);
349 amount_keys.push_back(rct::sk2rct(scalar1));
350 }
351 r = derive_public_key(derivation, output_index, dst_entr.addr.m_spend_public_key, out_eph_public_key);
352 CHECK_AND_ASSERT_MES(r, false, "at creation outs: failed to derive_public_key(" << derivation << ", " << output_index << ", "<< dst_entr.addr.m_spend_public_key << ")");
353
354 return r;
355 }
bool derive_public_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::public_key &pub, crypto::public_key &derived_pub) override
bool derivation_to_scalar(const crypto::key_derivation &derivation, const size_t output_index, crypto::ec_scalar &res) override
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
void scalarmultBase(key &aG, const key &a)
Definition rctOps.cpp:350
void scalarmultKey(key &aP, const key &P, const key &a)
Definition rctOps.cpp:368
crypto::secret_key sec
crypto::public_key pub
bool is_subaddress
account_public_address addr

◆ generate_ring_signature()

bool hw::core::device_default::generate_ring_signature ( const crypto::hash & prefix_hash,
const crypto::key_image & image,
const std::vector< const crypto::public_key * > & pubs,
const crypto::secret_key & sec,
std::size_t sec_index,
crypto::signature * sig )
overridevirtual

Implements hw::device.

Definition at line 442 of file device_default.cpp.

445 {
446 crypto::generate_ring_signature(prefix_hash, image, pubs.data(), pubs.size(), sec, sec_index, sig);
447 return true;
448 }
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)
Definition crypto.h:327

◆ generate_tx_proof()

void hw::core::device_default::generate_tx_proof ( const crypto::hash & prefix_hash,
const crypto::public_key & R,
const crypto::public_key & A,
const boost::optional< crypto::public_key > & B,
const crypto::public_key & D,
const crypto::secret_key & r,
crypto::signature & sig )
overridevirtual

Implements hw::device.

Definition at line 294 of file device_default.cpp.

296 {
297 crypto::generate_tx_proof(prefix_hash, R, A, B, D, r, sig);
298 }
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)
Definition crypto.h:311

◆ get_name()

const std::string hw::core::device_default::get_name ( ) const
overridevirtual

Implements hw::device.

Definition at line 68 of file device_default.cpp.

68 {
69 return this->name;
70 }
std::string name
Definition device.hpp:89
Here is the caller graph for this function:

◆ get_public_address()

bool hw::core::device_default::get_public_address ( cryptonote::account_public_address & pubkey)
overridevirtual

Implements hw::device.

Definition at line 114 of file device_default.cpp.

114 {
115 dfns();
116 }
#define dfns()
Definition device.hpp:65

◆ get_secret_keys()

bool hw::core::device_default::get_secret_keys ( crypto::secret_key & viewkey,
crypto::secret_key & spendkey )
overridevirtual

Implements hw::device.

Definition at line 117 of file device_default.cpp.

117 {
118 dfns();
119 }

◆ get_subaddress()

cryptonote::account_public_address hw::core::device_default::get_subaddress ( const cryptonote::account_keys & keys,
const cryptonote::subaddress_index & index )
overridevirtual

Implements hw::device.

Definition at line 182 of file device_default.cpp.

182 {
183 if (index.is_zero())
184 return keys.m_account_address;
185
187
188 // C = a*D
189 crypto::public_key C = rct::rct2pk(rct::scalarmultKey(rct::pk2rct(D), rct::sk2rct(keys.m_view_secret_key)));
190
191 // result: (C, D)
192 cryptonote::account_public_address address;
193 address.m_view_public_key = C;
194 address.m_spend_public_key = D;
195 return address;
196 }
crypto::public_key get_subaddress_spend_public_key(const cryptonote::account_keys &keys, const cryptonote::subaddress_index &index) override
POD_CLASS public_key
Definition crypto.h:79
account_public_address m_account_address
Definition account.h:43
const char * address
Definition multisig.cpp:37

◆ get_subaddress_private_spendkey()

crypto::secret_key hw::core::device_default::get_subaddress_private_spendkey ( const cryptonote::account_keys & keys,
const cryptonote::subaddress_index & subaddr_index )
overridevirtual

Implements hw::device.

Definition at line 215 of file device_default.cpp.

215 {
216 crypto::secret_key subaddr_secret_key = get_subaddress_secret_key(keys.m_view_secret_key, subaddr_index);
217 crypto::secret_key subaddr_private_spendkey;
218 sc_secret_add(subaddr_private_spendkey, subaddr_secret_key, keys.m_spend_secret_key);
219 return subaddr_private_spendkey;
220 }
bool sc_secret_add(crypto::secret_key &r, const crypto::secret_key &a, const crypto::secret_key &b) override
crypto::secret_key get_subaddress_secret_key(const crypto::secret_key &sec, const cryptonote::subaddress_index &index) override

◆ get_subaddress_private_viewkey()

crypto::secret_key hw::core::device_default::get_subaddress_private_viewkey ( const crypto::secret_key & main_wallet_sec_view,
crypto::secret_key & subaddress_sec_spend )
overridevirtual

Implements hw::device.

Definition at line 225 of file device_default.cpp.

225 {
226 crypto::secret_key subaddr_private_viewkey;
227 sc_mul(&subaddr_private_viewkey, &main_wallet_sec_view, &subaddress_sec_spend);
228 return subaddr_private_viewkey;
229 }
void sc_mul(unsigned char *, const unsigned char *, const unsigned char *)

◆ get_subaddress_secret_key()

crypto::secret_key hw::core::device_default::get_subaddress_secret_key ( const crypto::secret_key & sec,
const cryptonote::subaddress_index & index )
overridevirtual

Implements hw::device.

Definition at line 198 of file device_default.cpp.

198 {
199 const char prefix[] = "SubAddr";
200 char data[sizeof(prefix) + sizeof(crypto::secret_key) + 2 * sizeof(uint32_t)];
201 memcpy(data, prefix, sizeof(prefix));
202 memcpy(data + sizeof(prefix), &a, sizeof(crypto::secret_key));
203 uint32_t idx = SWAP32LE(index.major);
204 memcpy(data + sizeof(prefix) + sizeof(crypto::secret_key), &idx, sizeof(uint32_t));
205 idx = SWAP32LE(index.minor);
206 memcpy(data + sizeof(prefix) + sizeof(crypto::secret_key) + sizeof(uint32_t), &idx, sizeof(uint32_t));
208 crypto::hash_to_scalar(data, sizeof(data), m);
209 return m;
210 }
#define SWAP32LE
Definition int-util.h:224
void hash_to_scalar(const void *data, size_t length, ec_scalar &res)
Definition crypto.cpp:126
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1124
unsigned int uint32_t
Definition stdint.h:126
Here is the caller graph for this function:

◆ get_subaddress_spend_public_key()

crypto::public_key hw::core::device_default::get_subaddress_spend_public_key ( const cryptonote::account_keys & keys,
const cryptonote::subaddress_index & index )
overridevirtual

Implements hw::device.

Definition at line 128 of file device_default.cpp.

128 {
129 if (index.is_zero())
131
132 // m = Hs(a || index_major || index_minor)
134
135 // M = m*G
138
139 // D = B + M
140 crypto::public_key D = rct::rct2pk(rct::addKeys(rct::pk2rct(keys.m_account_address.m_spend_public_key), rct::pk2rct(M)));
141 return D;
142 }
bool secret_key_to_public_key(const secret_key &sec, public_key &pub)
Definition crypto.h:262
void addKeys(key &AB, const key &A, const key &B)
Definition rctOps.cpp:420
Here is the call graph for this function:

◆ get_subaddress_spend_public_keys()

std::vector< crypto::public_key > hw::core::device_default::get_subaddress_spend_public_keys ( const cryptonote::account_keys & keys,
uint32_t account,
uint32_t begin,
uint32_t end )
overridevirtual

Implements hw::device.

Definition at line 144 of file device_default.cpp.

144 {
145 CHECK_AND_ASSERT_THROW_MES(begin <= end, "begin > end");
146
147 std::vector<crypto::public_key> pkeys;
148 pkeys.reserve(end - begin);
149 cryptonote::subaddress_index index = {account, begin};
150
151 ge_p3 p3;
152 ge_cached cached;
153 CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&p3, (const unsigned char*)keys.m_account_address.m_spend_public_key.data) == 0,
154 "ge_frombytes_vartime failed to convert spend public key");
155 ge_p3_to_cached(&cached, &p3);
156
157 for (uint32_t idx = begin; idx < end; ++idx)
158 {
159 index.minor = idx;
160 if (index.is_zero())
161 {
162 pkeys.push_back(keys.m_account_address.m_spend_public_key);
163 continue;
164 }
165 crypto::secret_key m = get_subaddress_secret_key(keys.m_view_secret_key, index);
166
167 // M = m*G
168 ge_scalarmult_base(&p3, (const unsigned char*)m.data);
169
170 // D = B + M
171 crypto::public_key D;
172 ge_p1p1 p1p1;
173 ge_add(&p1p1, &p3, &cached);
174 ge_p1p1_to_p3(&p3, &p1p1);
175 ge_p3_tobytes((unsigned char*)D.data, &p3);
176
177 pkeys.push_back(D);
178 }
179 return pkeys;
180 }
int ge_frombytes_vartime(ge_p3 *, const unsigned char *)
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
Here is the call graph for this function:

◆ get_transaction_prefix_hash()

bool hw::core::device_default::get_transaction_prefix_hash ( const cryptonote::transaction_prefix & tx,
crypto::hash & tx_prefix_hash )
overridevirtual

Implements hw::device.

Definition at line 431 of file device_default.cpp.

431 {
432
433 std::ostringstream s;
434 binary_archive<true> a(s);
435 ::serialization::serialize(a, const_cast<cryptonote::transaction_prefix&>(tx));
436
437 crypto::cn_fast_hash(s.str().data(), s.str().size(), tx_prefix_hash);
438
439 return true;
440 }
void cn_fast_hash(const void *data, size_t length, char *hash)
bool serialize(Archive &ar, T &v)

◆ get_type()

device_type hw::core::device_default::get_type ( ) const
inlineoverridevirtual

Implements hw::device.

Definition at line 64 of file device_default.hpp.

64{return device_type::SOFTWARE;};

◆ hash_to_scalar()

bool hw::core::device_default::hash_to_scalar ( boost::shared_ptr< crypto::rs_comm > buf,
size_t length,
crypto::ec_scalar & res )
overridevirtual

Implements hw::device.

Definition at line 426 of file device_default.cpp.

426 {
427 crypto::hash_to_scalar(buf.get(), length, res);
428 return true;
429 }
const char * buf

◆ init()

bool hw::core::device_default::init ( void )
overridevirtual

Implements hw::device.

Definition at line 72 of file device_default.cpp.

72 {
73 return true;
74 }

◆ lock()

void hw::core::device_default::lock ( void )
overridevirtual

Implements hw::device.

Definition at line 94 of file device_default.cpp.

94{ }

◆ mlsag_hash()

bool hw::core::device_default::mlsag_hash ( const rct::keyV & long_message,
rct::key & c )
overridevirtual

Implements hw::device.

Definition at line 406 of file device_default.cpp.

406 {
407 c_old = rct::hash_to_scalar(toHash);
408 return true;
409 }
void hash_to_scalar(key &hash, const void *data, const std::size_t l)
Definition rctOps.cpp:536

◆ mlsag_prehash()

bool hw::core::device_default::mlsag_prehash ( const std::string & blob,
size_t inputs_size,
size_t outputs_size,
const rct::keyV & hashes,
const rct::ctkeyV & outPk,
rct::key & prehash )
overridevirtual

Implements hw::device.

Definition at line 400 of file device_default.cpp.

400 {
401 prehash = rct::cn_fast_hash(hashes);
402 return true;
403 }
void cn_fast_hash(key &hash, const void *data, const std::size_t l)
Definition rctOps.cpp:532
struct hash_func hashes[]

◆ mlsag_prepare() [1/2]

bool hw::core::device_default::mlsag_prepare ( const rct::key & H,
const rct::key & xx,
rct::key & a,
rct::key & aG,
rct::key & aHP,
rct::key & rvII )
overridevirtual

Implements hw::device.

Definition at line 389 of file device_default.cpp.

390 {
391 rct::skpkGen(a, aG);
392 rct::scalarmultKey(aHP, H, a);
393 rct::scalarmultKey(II, H, xx);
394 return true;
395 }
tuple< key, key > skpkGen()
Definition rctOps.cpp:290

◆ mlsag_prepare() [2/2]

bool hw::core::device_default::mlsag_prepare ( rct::key & a,
rct::key & aG )
overridevirtual

Implements hw::device.

Definition at line 396 of file device_default.cpp.

396 {
397 rct::skpkGen(a, aG);
398 return true;
399 }

◆ mlsag_sign()

bool hw::core::device_default::mlsag_sign ( const rct::key & c,
const rct::keyV & xx,
const rct::keyV & alpha,
const size_t rows,
const size_t dsRows,
rct::keyV & ss )
overridevirtual

Implements hw::device.

Definition at line 411 of file device_default.cpp.

411 {
412 CHECK_AND_ASSERT_THROW_MES(dsRows<=rows, "dsRows greater than rows");
413 CHECK_AND_ASSERT_THROW_MES(xx.size() == rows, "xx size does not match rows");
414 CHECK_AND_ASSERT_THROW_MES(alpha.size() == rows, "alpha size does not match rows");
415 CHECK_AND_ASSERT_THROW_MES(ss.size() == rows, "ss size does not match rows");
416 for (size_t j = 0; j < rows; j++) {
417 sc_mulsub(ss[j].bytes, c.bytes, xx[j].bytes, alpha[j].bytes);
418 }
419 return true;
420 }
void sc_mulsub(unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *)
int rows
Definition crypto.h:86
unsigned char bytes[32]
Definition rctTypes.h:86

◆ open_tx()

bool hw::core::device_default::open_tx ( crypto::secret_key & tx_key)
overridevirtual

Implements hw::device.

Definition at line 300 of file device_default.cpp.

300 {
301 cryptonote::keypair txkey = cryptonote::keypair::generate(*this);
302 tx_key = txkey.sec;
303 return true;
304 }
static keypair generate(hw::device &hwdev)
Here is the caller graph for this function:

◆ operator bool()

hw::core::device_default::operator bool ( ) const
inlineexplicitoverridevirtual

Implements hw::device.

Definition at line 48 of file device_default.hpp.

48{ return false; };

◆ operator=()

device_default & hw::core::device_default::operator= ( const device_default & device)
delete
Here is the call graph for this function:

◆ release()

bool hw::core::device_default::release ( )
overridevirtual

Implements hw::device.

Definition at line 75 of file device_default.cpp.

75 {
76 return true;
77 }

◆ sc_secret_add()

bool hw::core::device_default::sc_secret_add ( crypto::secret_key & r,
const crypto::secret_key & a,
const crypto::secret_key & b )
overridevirtual

Implements hw::device.

Definition at line 251 of file device_default.cpp.

251 {
252 sc_add(&r, &a, &b);
253 return true;
254 }
void sc_add(unsigned char *, const unsigned char *, const unsigned char *)
Here is the caller graph for this function:

◆ scalarmultBase()

bool hw::core::device_default::scalarmultBase ( rct::key & aG,
const rct::key & a )
overridevirtual

Implements hw::device.

Definition at line 246 of file device_default.cpp.

246 {
248 return true;
249 }
Here is the caller graph for this function:

◆ scalarmultKey()

bool hw::core::device_default::scalarmultKey ( rct::key & aP,
const rct::key & P,
const rct::key & a )
overridevirtual

Implements hw::device.

Definition at line 241 of file device_default.cpp.

241 {
242 rct::scalarmultKey(aP, P,a);
243 return true;
244 }
Here is the caller graph for this function:

◆ secret_key_to_public_key()

bool hw::core::device_default::secret_key_to_public_key ( const crypto::secret_key & sec,
crypto::public_key & pub )
overridevirtual

Implements hw::device.

Definition at line 278 of file device_default.cpp.

278 {
279 return crypto::secret_key_to_public_key(sec,pub);
280 }
Here is the caller graph for this function:

◆ set_mode()

bool hw::core::device_default::set_mode ( device_mode mode)
overridevirtual

Reimplemented from hw::device.

Definition at line 86 of file device_default.cpp.

86 {
87 return device::set_mode(mode);
88 }
virtual bool set_mode(device_mode mode)
Definition device.hpp:130
device_mode mode
Definition device.hpp:251
Here is the call graph for this function:

◆ set_name()

bool hw::core::device_default::set_name ( const std::string & name)
overridevirtual

Implements hw::device.

Definition at line 64 of file device_default.cpp.

64 {
65 this->name = name;
66 return true;
67 }
Here is the caller graph for this function:

◆ try_lock()

bool hw::core::device_default::try_lock ( void )
overridevirtual

Implements hw::device.

Definition at line 96 of file device_default.cpp.

96{ return true; }

◆ unlock()

void hw::core::device_default::unlock ( void )
overridevirtual

Implements hw::device.

Definition at line 98 of file device_default.cpp.

98{ }

◆ verify_keys()

bool hw::core::device_default::verify_keys ( const crypto::secret_key & secret_key,
const crypto::public_key & public_key )
overridevirtual

Implements hw::device.

Definition at line 235 of file device_default.cpp.

235 {
236 crypto::public_key calculated_pub;
237 bool r = crypto::secret_key_to_public_key(secret_key, calculated_pub);
238 return r && public_key == calculated_pub;
239 }

The documentation for this class was generated from the following files:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/device/device_default.hpp
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/device/device_default.cpp