From 3d379033c54f2bf7d35e72c13d2e45238d2fa882 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 13 Feb 2024 15:51:58 +0400 Subject: [PATCH] asset ownership proov validation replaced with prefix signed with schnorr signature --- src/currency_core/blockchain_storage.cpp | 6 ++++-- src/currency_core/currency_format_utils.cpp | 17 +++++++++++++++++ src/currency_core/currency_format_utils.h | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index ea0d350d..954f2fe5 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -4088,13 +4088,15 @@ bool blockchain_storage::validate_ado_ownership(asset_op_verification_context& a { // asset_id = AUTO_VAL_INIT(asset_id); // CHECK_AND_ASSERT_MES(validate_asset_operation_balance_proof(tx, tx_id, ado, asset_id), false, "asset operation validation failed!"); - CHECK_AND_ASSERT_MES(avc.ado.opt_proof.has_value(), false, "Ownership validation failed - missing signature"); + asset_operation_ownership_proof aoop = AUTO_VAL_INIT(aoop); + bool r = get_type_in_variant_container(avc.tx.proofs, aoop); + CHECK_AND_ASSERT_MES(r, false, "Ownership validation failed - missing signature"); CHECK_AND_ASSERT_MES(avc.asset_op_history->size() != 0, false, "asset with id " << avc.asset_id << " has invalid history size() == 0"); crypto::public_key owner_key = avc.asset_op_history->back().descriptor.owner; - return crypto::check_signature(get_signature_hash_for_asset_operation(avc.ado), owner_key, *avc.ado.opt_proof); + return crypto::verify_schnorr_sig(tx_id, owner_key, aoop.gss); } //------------------------------------------------------------------ bool blockchain_storage::put_asset_info(const transaction& tx, const crypto::hash& tx_id, const asset_descriptor_operation& ado) diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 170aeacc..112f1de4 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -2693,6 +2693,23 @@ namespace currency aop.opt_amount_commitment_g_proof = aop_g_sig; tx.proofs.emplace_back(std::move(aop)); } + if(ftp.need_to_generate_ado_proof) + { + asset_operation_ownership_proof aoop = AUTO_VAL_INIT(aoop); + + if (ftp.pthirdparty_sign_handler) + { + //ask third party to generate proof + r = ftp.pthirdparty_sign_handler->sign(tx_prefix_hash, ftp.ado_current_asset_owner, aoop.gss); + CHECK_AND_ASSERT_MES(r, false, "Failed to sign ado by thirdparty"); + } + else + { + //generate signature by wallet account + + } + tx.proofs.emplace_back(aoop); + } } //size_t prefix_size = get_object_blobsize(static_cast(tx)); diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 7bdcaa8c..7d2c761b 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -141,7 +141,7 @@ namespace currency struct thirdparty_sign_handler { - virtual bool sign(const crypto::hash& h, const crypto::public_key& owner_public_key, crypto::signature& sig); + virtual bool sign(const crypto::hash& h, const crypto::public_key& owner_public_key, crypto::generic_schnorr_sig& sig); }; struct finalize_tx_param