fixed genRctSimpleCarrot params; added carrot_and_legacy_account to wallet2
This commit is contained in:
+15
-14
@@ -37,6 +37,7 @@ extern "C"
|
||||
{
|
||||
#include "crypto/keccak.h"
|
||||
}
|
||||
#include "cryptonote_basic/account.h"
|
||||
#include "cryptonote_config.h"
|
||||
#include "ringct/rctOps.h"
|
||||
|
||||
@@ -50,7 +51,7 @@ DISABLE_VS_WARNINGS(4244 4345)
|
||||
namespace carrot
|
||||
{
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
CarrotDestinationV1 carrot_and_legacy_keys::cryptonote_address(const payment_id_t payment_id,
|
||||
CarrotDestinationV1 carrot_and_legacy_account::cryptonote_address(const payment_id_t payment_id,
|
||||
const AddressDeriveType derive_type) const
|
||||
{
|
||||
CarrotDestinationV1 addr;
|
||||
@@ -74,7 +75,7 @@ CarrotDestinationV1 carrot_and_legacy_keys::cryptonote_address(const payment_id_
|
||||
return addr;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
CarrotDestinationV1 carrot_and_legacy_keys::subaddress(const subaddress_index_extended &subaddress_index) const
|
||||
CarrotDestinationV1 carrot_and_legacy_account::subaddress(const subaddress_index_extended &subaddress_index) const
|
||||
{
|
||||
if (!subaddress_index.index.is_subaddress())
|
||||
return cryptonote_address(null_payment_id, subaddress_index.derive_type);
|
||||
@@ -109,18 +110,18 @@ CarrotDestinationV1 carrot_and_legacy_keys::subaddress(const subaddress_index_ex
|
||||
return addr;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
std::unordered_map<crypto::public_key, cryptonote::subaddress_index> carrot_and_legacy_keys::subaddress_map_cn() const
|
||||
std::unordered_map<crypto::public_key, cryptonote::subaddress_index> carrot_and_legacy_account::subaddress_map_cn() const
|
||||
{
|
||||
std::unordered_map<crypto::public_key, cryptonote::subaddress_index> res;
|
||||
for (const auto &p : subaddress_map)
|
||||
if (p.second.derive_type == AddressDeriveType::PreCarrot)
|
||||
res.emplace(p.first, cryptonote::subaddress_index{p.second.index.major, p.second.index.minor});
|
||||
CHECK_AND_ASSERT_THROW_MES(!res.empty(),
|
||||
"carrot_and_legacy_keys::subaddress_map_cn: subaddress map does not contain pre-carrot subaddresses");
|
||||
"carrot_and_legacy_account::subaddress_map_cn: subaddress map does not contain pre-carrot subaddresses");
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
void carrot_and_legacy_keys::opening_for_subaddress(const subaddress_index_extended &subaddress_index,
|
||||
void carrot_and_legacy_account::opening_for_subaddress(const subaddress_index_extended &subaddress_index,
|
||||
crypto::secret_key &address_privkey_g_out,
|
||||
crypto::secret_key &address_privkey_t_out,
|
||||
crypto::public_key &address_spend_pubkey_out) const
|
||||
@@ -182,11 +183,11 @@ void carrot_and_legacy_keys::opening_for_subaddress(const subaddress_index_exten
|
||||
rct::sk2rct(address_privkey_t_out),
|
||||
rct::pk2rct(crypto::get_T()));
|
||||
CHECK_AND_ASSERT_THROW_MES(rct::rct2pk(recomputed_address_spend_pubkey) == addr.address_spend_pubkey,
|
||||
"mock carrot or legacy keys: opening for subaddress: failed sanity check");
|
||||
"carrot and legacy account: opening for subaddress: failed sanity check");
|
||||
address_spend_pubkey_out = addr.address_spend_pubkey;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
bool carrot_and_legacy_keys::try_searching_for_opening_for_subaddress(const crypto::public_key &address_spend_pubkey,
|
||||
bool carrot_and_legacy_account::try_searching_for_opening_for_subaddress(const crypto::public_key &address_spend_pubkey,
|
||||
crypto::secret_key &address_privkey_g_out,
|
||||
crypto::secret_key &address_privkey_t_out) const
|
||||
{
|
||||
@@ -202,7 +203,7 @@ bool carrot_and_legacy_keys::try_searching_for_opening_for_subaddress(const cryp
|
||||
|
||||
return address_spend_pubkey == recomputed_address_spend_pubkey;
|
||||
}
|
||||
bool carrot_and_legacy_keys::try_searching_for_opening_for_onetime_address(const crypto::public_key &address_spend_pubkey,
|
||||
bool carrot_and_legacy_account::try_searching_for_opening_for_onetime_address(const crypto::public_key &address_spend_pubkey,
|
||||
const crypto::secret_key &sender_extension_g,
|
||||
const crypto::secret_key &sender_extension_t,
|
||||
crypto::secret_key &x_out,
|
||||
@@ -225,7 +226,7 @@ bool carrot_and_legacy_keys::try_searching_for_opening_for_onetime_address(const
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
bool carrot_and_legacy_keys::can_open_fcmp_onetime_address(const crypto::public_key &address_spend_pubkey,
|
||||
bool carrot_and_legacy_account::can_open_fcmp_onetime_address(const crypto::public_key &address_spend_pubkey,
|
||||
const crypto::secret_key &sender_extension_g,
|
||||
const crypto::secret_key &sender_extension_t,
|
||||
const crypto::public_key &onetime_address) const
|
||||
@@ -249,7 +250,7 @@ bool carrot_and_legacy_keys::can_open_fcmp_onetime_address(const crypto::public_
|
||||
return 0 == memcmp(&recomputed_onetime_address, &onetime_address, sizeof(rct::key));
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
crypto::key_image carrot_and_legacy_keys::derive_key_image(const crypto::public_key &address_spend_pubkey,
|
||||
crypto::key_image carrot_and_legacy_account::derive_key_image(const crypto::public_key &address_spend_pubkey,
|
||||
const crypto::secret_key &sender_extension_g,
|
||||
const crypto::secret_key &sender_extension_t,
|
||||
const crypto::public_key &onetime_address) const
|
||||
@@ -259,7 +260,7 @@ crypto::key_image carrot_and_legacy_keys::derive_key_image(const crypto::public_
|
||||
sender_extension_g,
|
||||
sender_extension_t,
|
||||
onetime_address),
|
||||
"mock carrot and legacy keys: derive key image: cannot open onetime address");
|
||||
"carrot and legacy account: derive key image: cannot open onetime address");
|
||||
|
||||
crypto::secret_key x, y;
|
||||
try_searching_for_opening_for_onetime_address(address_spend_pubkey,
|
||||
@@ -273,7 +274,7 @@ crypto::key_image carrot_and_legacy_keys::derive_key_image(const crypto::public_
|
||||
return L;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
void carrot_and_legacy_keys::generate_subaddress_map()
|
||||
void carrot_and_legacy_account::generate_subaddress_map()
|
||||
{
|
||||
const std::vector<AddressDeriveType> derive_types{AddressDeriveType::Carrot, AddressDeriveType::PreCarrot};
|
||||
|
||||
@@ -291,7 +292,7 @@ void carrot_and_legacy_keys::generate_subaddress_map()
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
void carrot_and_legacy_keys::generate(const AddressDeriveType default_derive_type)
|
||||
void carrot_and_legacy_account::generate(const AddressDeriveType default_derive_type)
|
||||
{
|
||||
legacy_acb.generate();
|
||||
|
||||
@@ -310,7 +311,7 @@ void carrot_and_legacy_keys::generate(const AddressDeriveType default_derive_typ
|
||||
generate_subaddress_map();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
AddressDeriveType carrot_and_legacy_keys::resolve_derive_type(const AddressDeriveType derive_type) const
|
||||
AddressDeriveType carrot_and_legacy_account::resolve_derive_type(const AddressDeriveType derive_type) const
|
||||
{
|
||||
return derive_type == AddressDeriveType::Auto ? default_derive_type : derive_type;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ static constexpr std::uint32_t MAX_SUBADDRESS_MINOR_INDEX = 20;
|
||||
|
||||
namespace carrot
|
||||
{
|
||||
struct carrot_and_legacy_keys
|
||||
struct carrot_and_legacy_account
|
||||
{
|
||||
cryptonote::account_base legacy_acb;
|
||||
|
||||
@@ -64,16 +64,16 @@ namespace carrot
|
||||
|
||||
AddressDeriveType default_derive_type;
|
||||
|
||||
carrot_and_legacy_keys(): k_view_incoming_dev(legacy_acb.get_keys().m_view_secret_key),
|
||||
carrot_and_legacy_account(): k_view_incoming_dev(legacy_acb.get_keys().m_view_secret_key),
|
||||
s_view_balance_dev(s_view_balance),
|
||||
s_generate_address_dev(s_generate_address)
|
||||
{}
|
||||
|
||||
carrot_and_legacy_keys(const carrot_and_legacy_keys &k) = delete;
|
||||
carrot_and_legacy_keys(carrot_and_legacy_keys&&) = delete;
|
||||
carrot_and_legacy_account(const carrot_and_legacy_account &k) = delete;
|
||||
carrot_and_legacy_account(carrot_and_legacy_account&&) = delete;
|
||||
|
||||
carrot_and_legacy_keys& operator=(const carrot_and_legacy_keys&) = delete;
|
||||
carrot_and_legacy_keys& operator=(carrot_and_legacy_keys&&) = delete;
|
||||
carrot_and_legacy_account& operator=(const carrot_and_legacy_account&) = delete;
|
||||
carrot_and_legacy_account& operator=(carrot_and_legacy_account&&) = delete;
|
||||
|
||||
CarrotDestinationV1 cryptonote_address(const payment_id_t payment_id = null_payment_id,
|
||||
const AddressDeriveType derive_type = AddressDeriveType::Auto) const;
|
||||
|
||||
+23
-28
@@ -1500,27 +1500,27 @@ namespace rct {
|
||||
//RCT simple
|
||||
//for post-rct only
|
||||
rctSig genRctSimpleCarrot(
|
||||
const key &message,
|
||||
const carrot_ctkeyV & inSk,
|
||||
const keyV & destinations,
|
||||
const cryptonote::transaction_type tx_type,
|
||||
const std::string& in_asset_type,
|
||||
const std::vector<std::string> & destination_asset_types,
|
||||
const std::vector<xmr_amount> &inamounts,
|
||||
const std::vector<xmr_amount> &outamounts,
|
||||
xmr_amount txnFee,
|
||||
const ctkeyM & mixRing,
|
||||
const keyV &amount_keys,
|
||||
const std::vector<unsigned int> & index,
|
||||
ctkeyV &outSk,
|
||||
const RCTConfig &rct_config,
|
||||
hw::device &hwdev,
|
||||
const rct::salvium_data_t &salvium_data,
|
||||
const key &x_change,
|
||||
const key &y_change,
|
||||
const size_t change_index,
|
||||
const key &key_yF
|
||||
)
|
||||
const key & message,
|
||||
const carrot_ctkeyV & inSk,
|
||||
const keyV & destinations,
|
||||
const cryptonote::transaction_type tx_type,
|
||||
const std::string& in_asset_type,
|
||||
const std::vector<std::string> & destination_asset_types,
|
||||
const std::vector<xmr_amount> & inamounts,
|
||||
const std::vector<xmr_amount> & outamounts,
|
||||
xmr_amount txnFee,
|
||||
const ctkeyM & mixRing,
|
||||
const keyV &amount_keys,
|
||||
const std::vector<unsigned int> & index,
|
||||
ctkeyV &outSk,
|
||||
const RCTConfig &rct_config,
|
||||
hw::device &hwdev,
|
||||
const rct::salvium_data_t &salvium_data,
|
||||
const key &x_change,
|
||||
const key &y_change,
|
||||
const size_t change_index,
|
||||
const key &key_yF
|
||||
)
|
||||
{
|
||||
CHECK_AND_ASSERT_THROW_MES(rct_config.range_proof_type == RangeProofPaddedBulletproof, "Borromean range proofs no longer supported");
|
||||
CHECK_AND_ASSERT_THROW_MES(destination_asset_types.size() == destinations.size(), "Different number of amount_keys/destinations");
|
||||
@@ -1601,14 +1601,9 @@ namespace rct {
|
||||
// TODO: unused ??
|
||||
// key txnFeeKey = scalarmultH(d2h(rv.txnFee));
|
||||
rv.mixRing = mixRing;
|
||||
keyV &pseudoOuts = is_rct_bulletproof_plus(rv.type) ? rv.p.pseudoOuts : rv.pseudoOuts;
|
||||
keyV &pseudoOuts = rv.p.pseudoOuts;
|
||||
pseudoOuts.resize(inamounts.size());
|
||||
if (is_rct_tclsag(rv.type))
|
||||
rv.p.TCLSAGs.resize(inamounts.size());
|
||||
else if (is_rct_clsag(rv.type))
|
||||
rv.p.CLSAGs.resize(inamounts.size());
|
||||
else
|
||||
rv.p.MGs.resize(inamounts.size());
|
||||
rv.p.TCLSAGs.resize(inamounts.size());
|
||||
key sumpouts = zero(); //sum pseudoOut masks
|
||||
keyV a(inamounts.size());
|
||||
bool audit = (tx_type == cryptonote::transaction_type::AUDIT && rv.type == RCTTypeSalviumZero && salvium_data.salvium_data_type == rct::SalviumZeroAudit);
|
||||
|
||||
@@ -141,16 +141,17 @@ namespace rct {
|
||||
rctSig genRctSimpleCarrot(
|
||||
const key & message,
|
||||
const carrot_ctkeyV & inSk,
|
||||
const ctkeyV & inPk,
|
||||
const keyV & destinations,
|
||||
const cryptonote::transaction_type tx_type,
|
||||
const std::string& in_asset_type,
|
||||
const std::vector<std::string> & destination_asset_types,
|
||||
const std::vector<xmr_amount> & inamounts,
|
||||
const std::vector<xmr_amount> & outamounts,
|
||||
const keyV &amount_keys,
|
||||
xmr_amount txnFee,
|
||||
unsigned int mixin,
|
||||
const ctkeyM & mixRing,
|
||||
const keyV &amount_keys,
|
||||
const std::vector<unsigned int> & index,
|
||||
ctkeyV &outSk,
|
||||
const RCTConfig &rct_config,
|
||||
hw::device &hwdev,
|
||||
const rct::salvium_data_t &salvium_data,
|
||||
|
||||
@@ -883,7 +883,7 @@ cryptonote::transaction finalize_all_proofs_from_transfer_details(
|
||||
);
|
||||
|
||||
crypto::secret_key x, y;
|
||||
bool r = w.get_account().try_searching_for_opening_for_onetime_address(
|
||||
bool r = w.get_carrot_account().try_searching_for_opening_for_onetime_address(
|
||||
sources[i].address_spend_pubkey,
|
||||
sender_extension_g_out,
|
||||
sender_extension_t_out,
|
||||
@@ -969,6 +969,8 @@ cryptonote::transaction finalize_all_proofs_from_transfer_details(
|
||||
crypto::hash tx_prefix_hash;
|
||||
get_transaction_prefix_hash(tx, tx_prefix_hash, hwdev);
|
||||
rct::ctkeyV outSk;
|
||||
rct::salvium_data_t salvium_data;
|
||||
salvium_data.salvium_data_type = rct::SalviumOne;
|
||||
tx.rct_signatures = rct::genRctSimpleCarrot(
|
||||
rct::hash2rct(tx_prefix_hash),
|
||||
inSk,
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <random>
|
||||
|
||||
#include "include_base_utils.h"
|
||||
#include "carrot_impl/account.h"
|
||||
#include "carrot_impl/carrot_offchain_serialization.h"
|
||||
#include "cryptonote_basic/account.h"
|
||||
#include "cryptonote_basic/account_boost_serialization.h"
|
||||
@@ -1121,6 +1122,9 @@ private:
|
||||
cryptonote::account_base& get_account(){return m_account;}
|
||||
const cryptonote::account_base& get_account()const{return m_account;}
|
||||
|
||||
carrot::carrot_and_legacy_account& get_carrot_account(){return m_carrot_account;}
|
||||
const carrot::carrot_and_legacy_account& get_carrot_account()const{return m_carrot_account;}
|
||||
|
||||
bool is_key_encryption_enabled() const;
|
||||
void encrypt_keys(const crypto::chacha_key &key);
|
||||
void encrypt_keys(const epee::wipeable_string &password);
|
||||
@@ -2092,6 +2096,7 @@ private:
|
||||
bool should_expand(const cryptonote::subaddress_index &index) const;
|
||||
bool spends_one_of_ours(const cryptonote::transaction &tx) const;
|
||||
|
||||
carrot::carrot_and_legacy_account m_carrot_account;
|
||||
cryptonote::account_base m_account;
|
||||
boost::optional<epee::net_utils::http::login> m_daemon_login;
|
||||
std::string m_daemon_address;
|
||||
|
||||
Reference in New Issue
Block a user