forked from lthn/blockchain
multiple fixes over sig refactoring
This commit is contained in:
parent
fa4b8ab130
commit
e94e5c0a97
10 changed files with 16 additions and 13 deletions
|
|
@ -4344,7 +4344,7 @@ bool blockchain_storage::check_tx_inputs(const transaction& tx, const crypto::ha
|
|||
TIME_MEASURE_START_PD(tx_check_inputs_attachment_check);
|
||||
if (!m_is_in_checkpoint_zone)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(tx.signatures.s.size() == sig_index, false, "tx signatures count differs from inputs");
|
||||
CHECK_AND_ASSERT_MES(tx.signatures.size() == sig_index, false, "tx signatures count differs from inputs");
|
||||
if (!(get_tx_flags(tx) & TX_FLAG_SIGNATURE_MODE_SEPARATE))
|
||||
{
|
||||
bool r = validate_attachment_info(tx.extra, tx.attachment, false);
|
||||
|
|
@ -4649,7 +4649,7 @@ bool blockchain_storage::check_ms_input(const transaction& tx, size_t in_index,
|
|||
VARIANT_SWITCH_END();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
#undef LOC_CHK
|
||||
|
|
|
|||
|
|
@ -1693,7 +1693,7 @@ namespace currency
|
|||
LOC_CHK(ms_input_index < tx.signatures.size(), "transaction does not have signatures vector entry for ms input #" << ms_input_index);
|
||||
|
||||
LOC_CHK(tx.signatures[ms_input_index].type() == typeid(NLSAG_sig), "Wrong type of signature");
|
||||
auto& sigs = boost::get<NLSAG_sig>(tx.signatures[ms_input_index]);
|
||||
auto& sigs = boost::get<NLSAG_sig>(tx.signatures[ms_input_index]).s;
|
||||
LOC_CHK(!sigs.empty(), "empty signatures container");
|
||||
|
||||
bool extra_signature_expected = (get_tx_flags(tx) & TX_FLAG_SIGNATURE_MODE_SEPARATE) && ms_input_index == tx.vin.size() - 1;
|
||||
|
|
|
|||
|
|
@ -667,6 +667,7 @@ namespace currency
|
|||
size_t operator()(const txin_to_key& txin) const { return txin.key_offsets.size(); }
|
||||
size_t operator()(const txin_multisig& txin) const { return txin.sigs_count; }
|
||||
size_t operator()(const txin_htlc& txin) const { return 1; }
|
||||
size_t operator()(const tx_in_zarcanum& txin) const { throw std::runtime_error("Not implemented yet"); return 0; } //@#@
|
||||
};
|
||||
|
||||
return boost::apply_visitor(txin_signature_size_visitor(), tx_in);
|
||||
|
|
|
|||
|
|
@ -237,6 +237,7 @@ namespace currency
|
|||
++sig_count; // count in one more signature for the last input in a complete separately signed tx
|
||||
tx_blob_size += tools::get_varint_packed_size(sig_count); // size of transaction::signatures[i]
|
||||
tx_blob_size += sizeof(crypto::signature) * sig_count; // size of signatures' data itself
|
||||
tx_blob_size += sizeof(binary_archive<true>::variant_tag_type); //tools::get_varint_packed_size(variant_serialization_traits<binary_archive<true>, currency::NLSAG_sig>::get_tag()); // sizeof variant tag
|
||||
}
|
||||
|
||||
// 2. attachments (try to find extra_attachment_info in tx prefix and count it in if succeed)
|
||||
|
|
|
|||
|
|
@ -237,8 +237,9 @@ bool wallet2::validate_escrow_release(const transaction& tx, bool release_type_n
|
|||
LOC_CHK(tx.signatures.size() == 1, "invalid singatures size: " << tx.signatures.size()); // only 1 input means only 1 signature vector
|
||||
|
||||
VARIANT_SWITCH_BEGIN(tx.signatures[0]);
|
||||
VARIANT_CASE_CONST(NLSAG_sig, signature)
|
||||
VARIANT_CASE_CONST(NLSAG_sig, signature_NLSAG)
|
||||
{
|
||||
auto& signature = signature_NLSAG.s;
|
||||
// As we don't have b_keys we can't be sure which signature is B's and which is reserved for A (should be a null-placeholder, if present).
|
||||
// Having a_keys, we determine index of A key in multisig output keys array.
|
||||
// Thus it's possible to determine the order of signatures (A, B or B, A), and, eventually, validate B signature.
|
||||
|
|
@ -420,9 +421,9 @@ bool wallet2::validate_escrow_cancel_release(const currency::transaction& tx, co
|
|||
// (5/5) signatures
|
||||
LOC_CHK(tx.signatures.size() == 1, "invalid singatures size: " << tx.signatures.size()); // only 1 input means only 1 signature vector
|
||||
VARIANT_SWITCH_BEGIN(tx.signatures[0]);
|
||||
VARIANT_CASE_CONST(NLSAG_sig, signatures)
|
||||
VARIANT_CASE_CONST(NLSAG_sig, signature_NLSAG)
|
||||
{
|
||||
|
||||
auto& signature = signature_NLSAG.s;
|
||||
LOC_CHK(signature.size() == 2, "invalid signature[0] size: " << signature.size()); // it's expected to contain A-party signature and null-sig placeholder
|
||||
LOC_CHK(source_ms_out.keys.size() == 2, "internal error: invalid source ms output keys array, size: " << source_ms_out.keys.size());
|
||||
|
||||
|
|
|
|||
|
|
@ -846,7 +846,7 @@ bool construct_broken_tx(const currency::account_keys& sender_account_keys, cons
|
|||
ss_ring_s << o.second << ENDL;
|
||||
}
|
||||
|
||||
tx.signatures.push_back(currency::NLSAG_sig(std::vector<crypto::signature>()));
|
||||
tx.signatures.push_back(currency::NLSAG_sig());
|
||||
std::vector<crypto::signature>& sigs = boost::get<currency::NLSAG_sig>(tx.signatures.back()).s;
|
||||
sigs.resize(src_entr.outputs.size());
|
||||
crypto::generate_ring_signature(tx_prefix_hash, boost::get<currency::txin_to_key>(tx.vin[i]).k_image, keys_ptrs, in_contexts[i].in_ephemeral.sec, src_entr.real_output, sigs.data());
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ inline bool resign_tx(const currency::account_keys& sender_keys, const std::vect
|
|||
return false;
|
||||
crypto::derive_secret_key(recv_derivation, se.real_output_in_tx_index, sender_keys.spend_secret_key, in_ephemeral_sec);
|
||||
|
||||
tx.signatures.push_back(currency::NLSAG_sig(std::vector<crypto::signature>()));
|
||||
tx.signatures.push_back(currency::NLSAG_sig());
|
||||
std::vector<crypto::signature>& sigs = boost::get<currency::NLSAG_sig>(tx.signatures.back()).s;
|
||||
|
||||
if (se.is_multisig())
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ inline bool build_custom_escrow_template(const std::vector<test_event_entry>& ev
|
|||
if (custom_config_mask & eccf_template_no_a_sigs)
|
||||
{
|
||||
escrow_template_tx.signatures.clear();
|
||||
escrow_template_tx.signatures.push_back(currency::NLSAG_sig(std::vector<crypto::signature>()));
|
||||
escrow_template_tx.signatures.push_back(currency::NLSAG_sig());
|
||||
}
|
||||
|
||||
append_vector_by_another_vector(used_sources, sources);
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ struct tx_builder
|
|||
keys_ptrs.push_back(&o.second);
|
||||
}
|
||||
|
||||
m_tx.signatures.push_back(currency::NLSAG_sig(std::vector<crypto::signature>()));
|
||||
m_tx.signatures.push_back(currency::NLSAG_sig());
|
||||
std::vector<crypto::signature>& sigs = boost::get<currency::NLSAG_sig>(m_tx.signatures.back()).s;
|
||||
sigs.resize(src_entr.outputs.size());
|
||||
generate_ring_signature(m_tx_prefix_hash, boost::get<currency::txin_to_key>(m_tx.vin[i]).k_image, keys_ptrs, m_in_contexts[i].sec, src_entr.real_output, sigs.data());
|
||||
|
|
|
|||
|
|
@ -660,7 +660,7 @@ bool gen_tx_signatures_are_invalid::generate(std::vector<test_event_entry>& even
|
|||
|
||||
// Tx with nmix = 0 have a few inputs, and too many signatures (2/2)
|
||||
broken_tx = tx_0;
|
||||
broken_tx.signatures.push_back(currency::NLSAG_sig(std::vector<crypto::signature>()));
|
||||
broken_tx.signatures.push_back(currency::NLSAG_sig());
|
||||
boost::get<currency::NLSAG_sig>(broken_tx.signatures.back()).s.push_back(invalid_signature);
|
||||
check_broken_tx(events, broken_tx, prev_block, miner_account, generator);
|
||||
|
||||
|
|
@ -677,7 +677,7 @@ bool gen_tx_signatures_are_invalid::generate(std::vector<test_event_entry>& even
|
|||
|
||||
// Tx with nmix = 1 have not enough signatures (2/2)
|
||||
broken_tx = tx_1;
|
||||
broken_tx.signatures.back().resize(boost::get<currency::NLSAG_sig>(broken_tx.signatures.back()).s.size() - 1);
|
||||
boost::get<currency::NLSAG_sig>(broken_tx.signatures.back()).s.resize(boost::get<currency::NLSAG_sig>(broken_tx.signatures.back()).s.size() - 1);
|
||||
check_broken_tx(events, broken_tx, prev_block, miner_account, generator);
|
||||
|
||||
// Tx with nmix = 1 have too many signatures (1/2)
|
||||
|
|
@ -687,7 +687,7 @@ bool gen_tx_signatures_are_invalid::generate(std::vector<test_event_entry>& even
|
|||
|
||||
// Tx with nmix = 1 have too many signatures (2/2)
|
||||
broken_tx = tx_1;
|
||||
broken_tx.signatures.push_back(currency::NLSAG_sig(std::vector<crypto::signature>()));
|
||||
broken_tx.signatures.push_back(currency::NLSAG_sig());
|
||||
boost::get<currency::NLSAG_sig>(broken_tx.signatures.back()).s.push_back(invalid_signature);
|
||||
check_broken_tx(events, broken_tx, prev_block, miner_account, generator);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue