1
0
Fork 0
forked from lthn/blockchain

asset ownership proov validation replaced with prefix signed with schnorr signature

This commit is contained in:
cryptozoidberg 2024-02-13 15:51:58 +04:00
parent 66ffef4080
commit 3d379033c5
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
3 changed files with 22 additions and 3 deletions

View file

@ -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)

View file

@ -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<const transaction_prefix&>(tx));

View file

@ -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