[go: up one dir, main page]

CN119906711A - A transaction verification method and system based on blockchain - Google Patents

A transaction verification method and system based on blockchain Download PDF

Info

Publication number
CN119906711A
CN119906711A CN202411989819.5A CN202411989819A CN119906711A CN 119906711 A CN119906711 A CN 119906711A CN 202411989819 A CN202411989819 A CN 202411989819A CN 119906711 A CN119906711 A CN 119906711A
Authority
CN
China
Prior art keywords
transaction
blockchain
verification
transactions
nodes
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411989819.5A
Other languages
Chinese (zh)
Inventor
谭俊豪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing Normal University
Original Assignee
Chongqing Normal University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chongqing Normal University filed Critical Chongqing Normal University
Priority to CN202411989819.5A priority Critical patent/CN119906711A/en
Publication of CN119906711A publication Critical patent/CN119906711A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1059Inter-group management mechanisms, e.g. splitting, merging or interconnection of groups
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

本发明公开了一种基于区块链的交易验证方法及系统,涉及区块链技术领域。首先由交易发起方构建、签名并广播交易,节点接收后放交易池,经格式、语法与数字签名验证,通过则进入后续流程;接着检查发送方余额,基于UTXO模型和账户模型操作并对比交易成本,同时进行双花检查,异常交易做相应处理;在不同共识机制下,相应节点按规则构建新区块,全网节点再验证新区块及所含交易,验证通过则新区块添入主链使交易生效;最后确认交易有效添加新区块时更新账本状态,并提供接口方便查询交易详情与历史记录。该方法保障交易安全准确,提升区块链系统可靠性与可追溯性。

The present invention discloses a transaction verification method and system based on blockchain, and relates to the field of blockchain technology. First, the transaction initiator constructs, signs and broadcasts the transaction, and the node receives it and puts it into the transaction pool. After the format, syntax and digital signature are verified, the subsequent process is entered if it passes; then the sender's balance is checked, and the transaction cost is compared based on the UTXO model and the account model, and double-spending checks are performed at the same time, and abnormal transactions are handled accordingly; under different consensus mechanisms, the corresponding nodes construct new blocks according to the rules, and the nodes of the entire network verify the new blocks and the transactions contained therein. If the verification passes, the new blocks are added to the main chain to make the transaction effective; finally, when the transaction is confirmed to be valid, the account book status is updated, and an interface is provided to facilitate the query of transaction details and historical records. This method ensures the safety and accuracy of transactions and improves the reliability and traceability of the blockchain system.

Description

Transaction verification method and system based on blockchain
Technical Field
The invention relates to the technical field of blockchains, in particular to a transaction verification method and system based on a blockchain.
Background
With the development of internet economy, electronic payment is becoming popular, and online transaction scale is rapidly expanding. However, conventional centralized accounts books are susceptible to single point failures and there may be a risk of personnel handling records inside, which makes it difficult to meet the ever-increasing security and trust requirements. In recent years, the rising distributed accounting, namely blockchain, is taken as a decentralised database structure, ensures the security of a system through cryptography and realizes reliable transaction processing under a multi-party consensus mechanism, and is widely focused by various circles and is primarily explored and applied in a plurality of industries.
With the continuous expansion of blockchain technology application in numerous fields such as digital currency, supply chain finance, etc., the security and verification efficiency of blockchain transactions are becoming a critical issue. Traditional transaction verification methods often depend on a centralized institution (such as a transaction processing system of a bank), and have the defects of single-point fault risk, high trust cost, easy data tampering and the like. The existing blockchain transaction verification method and system have the problems of complex verification flow, low consensus efficiency, insufficient suitability for special transaction rules and the like when facing mass transactions, and influence the popularization and use experience of the blockchain technology in actual application scenes. Therefore, there is an urgent need for a more optimal, efficient and flexible blockchain-based transaction verification method and system.
Disclosure of Invention
Aiming at the defects existing in the prior art, the invention aims to provide a transaction verification method and system based on a blockchain.
In order to achieve the above purpose, the present invention provides the following technical solutions:
In a first aspect, a blockchain-based transaction verification method includes the steps of:
step 1, after a transaction initiator constructs a transaction and digital signature at a local client, broadcasting the transaction to a blockchain network node through a P2P network protocol;
Step 2, the block chain network node receives the broadcast transaction and stores the broadcast transaction in a local transaction pool, the broadcast transaction is verified by format, grammar and digital signature, the broadcast transaction is discarded after verification failure, and the broadcast transaction enters a subsequent flow after verification;
step 3, checking the account balance of the sender and performing double-flower check, wherein the transaction judgment is illegal or marked abnormally when the balance is insufficient or double flowers exist;
Step 4, constructing new blocks by corresponding nodes according to rules under different consensus mechanisms, verifying the new blocks and the contained transactions by the nodes of the whole network, and enabling the transactions to be effective by adding the new blocks into a main chain;
And 5, updating the account book state after confirming that the transaction effectively adds a new block, and providing an interface for conveniently inquiring transaction details and historical records.
Preferably, the step 1 includes:
the transaction initiator constructs a transaction containing the blockchain address of the sender, the blockchain address of the receiver, the transaction amount, a unique transaction identifier and optional additional information at the local client;
The initiator uses the corresponding private key to carry out digital signature on the transaction content, and processes the generated digital signature to obtain a transaction data packet;
And transmitting the digitally signed transaction data packet to a node in a blockchain network and broadcasting the transaction data packet through a P2P network protocol.
Preferably, the step 2 includes:
Nodes in the blockchain network receive the broadcasted transaction information and temporarily store the transaction information into a local transaction pool;
checking the format and grammar of the transaction to ensure that the transaction accords with the structure specified by a blockchain protocol and the type and length requirements of each field;
And verifying whether the digital signature on the transaction is correct or not by using the public key of the sender, discarding the transaction if the verification fails, and entering a subsequent verification process if the verification passes.
Preferably, the step3 includes:
Checking whether the account balance of the sender is enough to pay the transaction amount and the commission, and if the account balance is insufficient, judging that the transaction is illegal and removing;
A double-flower check is performed, whether UTXOs involved in transactions are referenced in other transactions to be confirmed or not is checked by a blockchain based on an account model, and the same funds are ensured not to participate in multiple concurrent transactions at the same time by a corresponding mechanism, so that the transactions with double-flower possibility are not further processed and marked as abnormal.
Preferably, the step4 includes:
In a blockchain adopting a workload proof consensus mechanism, a miner node selects legal transaction from a transaction pool to construct a new block, and a random number meeting a difficulty target is searched to enable a hash value of a block header to meet a condition;
After receiving the new block, the full network node again performs format and grammar check, digital signature verification and transaction validity check on all transactions contained in the new block, and verifies whether the new block meets the requirements of a common recognition mechanism or not, if so, the new block is added to a blockchain main chain, and the transactions in the new block are finally confirmed to be effective.
Preferably, the step 5 includes:
after confirming that the transaction is effective and adding the new block, updating the locally maintained account book state according to the transaction content;
a corresponding interface or tool is provided that allows users, authorities to query specific transaction details and history according to transaction identifiers, blockchain addresses.
The transaction verification system based on the blockchain comprises a transaction broadcasting module, a transaction verification module, an account and double-flower checking module, a block construction and verification module and an account book management and inquiry module;
The transaction broadcasting module is used for broadcasting the transaction to the blockchain network node through the P2P network protocol after the transaction initiator constructs the transaction and digitally signs the transaction at the local client;
The transaction verification module is used for verifying format grammar and digital signature of the transaction, and determining whether to discard the transaction or enable the transaction to enter a subsequent flow according to a verification result;
The account and double-flower checking module is used for checking the balance of the account of the sender and carrying out double-flower checking, and judging and marking the transaction with the possible double flowers or insufficient balance;
the block construction and verification module coordinates corresponding nodes to construct a new block according to different consensus mechanisms, organizes the whole network nodes to verify the new block and the contained transaction, and adds the new block into a main chain after the verification is passed;
and the account book management and query module updates the account book state after the transaction confirms that the new block is effectively added, and provides an interface to facilitate the query of transaction details and history records.
Compared with the prior art, the invention has the following beneficial effects:
1. In the invention, after the transaction is broadcasted from the initiator, the transaction is subjected to a plurality of strict verification processes such as format grammar checking, digital signature verification, account balance checking of the sender, double-flower checking and the like in sequence, and each link is subjected to corresponding treatment (such as discarding or marking abnormality) under the condition of unsatisfactory conditions, so that the possibility that the error transaction and illegal transaction enter a block chain main chain is greatly reduced, the accuracy of the finally confirmed effective transaction is improved, the legal compliance and the business logic compliance of each transaction recorded on the block chain are ensured, and the reliability of the whole transaction system is enhanced.
2. In the invention, two consensus mechanisms of PoW and PoS are adopted, and the different consensus mechanisms have advantages and application scenes, so that the PoW mechanism ensures fairness and decentralization degree of new block generation through power competition, is suitable for scenes with extremely high safety requirements and certain tolerance to resource consumption, and the PoS mechanism determines accounting rights according to rights held by nodes, is relatively more energy-saving, can ensure the safety and stability of a network to a certain extent, and is suitable for application scenes which pay attention to resource utilization efficiency. The system can select a proper consensus mechanism according to specific requirements, so that the blockchain network can stably and reliably run under different service scenes to continuously provide services for users.
3. In the invention, after confirming that the transaction is effective and adding the block, the state of the locally maintained account book can be updated in time, and a corresponding interface is provided for facilitating users, supervision authorities and the like to inquire specific transaction details and history records according to the transaction identifier, the blockchain address and other information. The system has the advantages that each transaction has clear records on the blockchain, can be traced and checked at any time just like a traditional account book, can conveniently acquire required transaction information no matter whether a common user checks own transaction conditions or a supervision organization carries out auditing, investigation and other works, ensures transparency and traceability of the blockchain transaction, is beneficial to enhancing trust of each party to the blockchain system, and meets the requirements of compliance supervision.
4. In the invention, the whole blockchain network is based on the distributed account book technology, transaction information is difficult to tamper once being verified and added to a main chain, all nodes keep the same account book copy, and account book content is public and transparent (although privacy-related parts such as private keys and the like are secret, key information of the transaction itself is searchable). The characteristics enable all parties participating in the transaction and external supervisors to trust the authenticity and the integrity of the transaction records, promote the application and popularization of the blockchain in more fields (such as supply chain finance, traceability systems and the like), and lay a foundation for constructing a trust ecological system based on the blockchain.
Drawings
FIG. 1 is a flow chart of a block chain based transaction verification method according to the present invention;
fig. 2 is a flow chart of a transaction verification system based on blockchain according to the present invention.
Detailed Description
The embodiment further describes a transaction verification method and a transaction verification system based on the blockchain.
Referring to fig. 1, a blockchain-based transaction verification method includes the steps of:
step 1, after a transaction initiator constructs a transaction and digital signature at a local client, broadcasting the transaction to a blockchain network node through a P2P network protocol;
Step 2, the block chain network node receives the broadcast transaction and stores the broadcast transaction in a local transaction pool, the broadcast transaction is verified by format, grammar and digital signature, the broadcast transaction is discarded after verification failure, and the broadcast transaction enters a subsequent flow after verification;
step 3, checking the account balance of the sender and performing double-flower check, wherein the transaction judgment is illegal or marked abnormally when the balance is insufficient or double flowers exist;
Step 4, constructing new blocks by corresponding nodes according to rules under different consensus mechanisms, verifying the new blocks and the contained transactions by the nodes of the whole network, and enabling the transactions to be effective by adding the new blocks into a main chain;
And 5, updating the account book state after confirming that the transaction effectively adds a new block, and providing an interface for conveniently inquiring transaction details and historical records.
The step 1 comprises the following steps:
the transaction initiator constructs a transaction containing the blockchain address of the sender, the blockchain address of the receiver, the transaction amount, a unique transaction identifier and optional additional information at the local client;
the unique transaction identifier is generated, and in the field of blockchain, an SHA-256 hash algorithm is often adopted to operate, wherein the SHA-256 can process input data with any length and then output the processed input data to be fixed into a hash value with 256 bits (32 bytes), and the hash value is usually displayed in a hexadecimal character string form;
The transaction key information is selected as input data, including the address of a sender, the address of a receiver, the transaction amount and a time stamp, and the information is spliced together in sequence to form a data string which is used as input to be sent into an SHA-256 hash algorithm for hash operation;
Firstly, filling input data to enable the length of the input data to meet a specific multiple of algorithm requirements (SHA-256 requires that the remainder of the input data after the length is modulo 512 bits is 448 bits, and if the input data is insufficient, the input data is complemented by a specific filling rule);
Setting an initial hash value (also called an intermediate state value, there are 8 initial intermediate state values of 32 bits in SHA-256, which are fixed constants for starting the entire operation);
For each divided 512-bit data block, performing operation on the current data block and the current intermediate state value by a series of complex logic functions (including nonlinear functions formed by combining logic operations such as AND, OR, NOT, XOR and the like and arithmetic operations such as displacement, addition and the like, wherein Ch (x, y, z) = (x & y) (-x) and z) are part of function examples, and not expanding all functions in detail;
After the iterative compression operation, the final obtained 8 intermediate state values of 32 bits are combined to be 256-bit hash values, and the 256-bit hash values are converted into hexadecimal character strings, so that the transaction identifier which is wanted by people is obtained.
The initiator uses the corresponding private key to carry out digital signature on the transaction content, and processes the generated digital signature to obtain a transaction data packet;
based on an ECDSA algorithm, carrying out digital signature by adopting secp k1 elliptic curve digital signature algorithm, and generating a group of temporary public key and private key pairs;
Before the actual signature operation is performed, the whole transaction content needs to be hashed, and a hash value with a fixed length is generated by adopting an SHA-256 hash algorithm, for example, assuming that a data string of the transaction content after being tidied is TransactionData, the hash value obtained by carrying out the hash operation by adopting the SHA-256 algorithm is recorded as HashValue, namely HashValue =SHA-256 (TransactionData);
The obtained private key may exist in the form of character string or byte array, etc., but in the mathematical operation of ECDSA algorithm, it needs to be converted into integer form meeting the requirements of elliptic curve cryptography operation;
The digital signature operation process comprises the steps of firstly, selecting a random number k, performing point multiplication operation through a base point of an elliptic curve to obtain a point P on the elliptic curve, wherein the abscissa value of the point P is the value of r, namely P=k×G, wherein G is the base point of the elliptic curve, and the point multiplication operation is represented by the G;
Then, according to the private key d, the random number k, the hash value HashValue and the r value obtained above, s values are obtained through formula calculation, wherein s=k (1) (HashValue +d (r)) mod n, k (1) represents the multiplication inverse element of k under the mode n, n is the order of elliptic curve, and mod represents the modulo operation;
the final digital signature is an ordered pair consisting of two integers, r and s, and is marked as (r, s);
the generated digital signature (r, s) is appended to the original transaction information in accordance with the format and requirements specified by the blockchain system to form a complete transaction data packet with the digital signature.
And transmitting the digitally signed transaction data packet to a node in a blockchain network and broadcasting the transaction data packet through a P2P network protocol.
The step2 includes:
Nodes in the blockchain network receive the broadcasted transaction information and temporarily store the transaction information into a local transaction pool;
checking the format and grammar of the transaction to ensure that the transaction accords with the structure specified by a blockchain protocol and the type and length requirements of each field;
the format and grammar checking of the transaction includes checking structural integrity, verifying field type requirements, verifying field length limitations;
The checking structure integrity completely comprises the structural parts of transaction version number, input list, output list and locking time, and the arrangement sequence of the parts strictly meets the requirements.
The verification of each field type requirement comprises transaction version number type checking, input list and sub-field type checking, output list and sub-field type checking and locking time type checking;
The transaction version number type is checked, and the transaction version number is specified as an integer type, and specifically can be in different formats (block chain-dependent) such as 32-bit unsigned integers;
The input list and the sub-field type check comprise a preamble transaction hash type check and an output index type, wherein the preamble transaction hash type is generally a byte array type, the byte length needs to meet the standard length generated by a specific hash algorithm (for example, the hash value generated by adopting an SHA-256 hash algorithm should be 32 bytes), whether the input list and the sub-field type check are stored in the form of a byte array or not and whether the actual length is consistent with the specified length or not is checked, the output index type is an integer type and is used for positioning a specific position in the preamble transaction output, whether the output index can be used as an integer to participate in operation or not is checked, whether the definition range (for example, the value range is between 0 and a certain positive integer) of the integer type of the block chain is met or not is checked, if the definition range is not met, errors occur when the specific output corresponding to the fund source is searched later, and the transaction grammar is incorrect;
The output list and subfield type check comprises a receiver blockchain address type check and a transfer amount type check, wherein the receiver blockchain address type check needs to be a character string type conforming to a blockchain specific coding rule, and when checking, whether the format of the character string is correct, whether the characters are in compliance, whether the length is in a specified range and the like is checked according to the address generation rule of the corresponding blockchain;
The lock time type check, if there is a lock time field, should be generally of integer type and have a value range and meaning (for example, representing a certain time stamp or time interval, etc.) specified by the corresponding blockchain protocol, check whether it accords with the characteristics of an integer and is within the specified value range, if the type is not right or out of range, it does not accord with the requirement of transaction grammar, because the limitation condition on the effective time of the transaction cannot be correctly reflected.
The length limit of each field comprises transaction identifier length verification and blockchain address length verification, wherein the transaction identifier length verification is generated by carrying out hash operation on transaction key information, whether the actual transaction identifier length is strictly equal to the specified byte number or not is checked, if the actual transaction identifier length is inconsistent, the blockchain address length verification is carried out, the addresses of different blockchains have respective specified length ranges, whether the lengths of the addresses of a receiver and a sender are consistent or not is verified according to corresponding standards, for example, the specified address length of a blockchain is minimum to be L_min and maximum to be L_max, the actual address length is marked as 1_address, the transaction identifier is judged by comparing the size relation of 1_address with L_min and L_max, and if the actual transaction identifier length is inconsistent or 1_address is inconsistent, the address length of the blockchain is judged to be inconsistent, and further the address which is inconsistent with the address which is not consistent with the length requirement is further indicated to be unable to be identified and processed in the blockchain network.
Verifying whether the digital signature on the transaction is correct or not by using the public key of the sender, discarding the transaction if the verification fails, and entering a subsequent verification process if the verification passes;
obtaining a sender public key, and marking the sender public key as a publicKey;
the node needs to accurately extract the corresponding representation forms of r and s from the transaction data according to the specific field positions specified by the blockchain protocol;
the verification logic based on the ECDSA algorithm specifically comprises the following steps:
Firstly, extracting all complete contents except a digital signature in transaction information, and then carrying out hash operation on the contents by using an SHA-256 hash algorithm to obtain a hash value with a fixed length, wherein the hash value is recorded as HashValue;
According to the mathematical principle of ECDSA algorithm, using the obtained public key publicKey of sender, the r and s values in the extracted digital signature and HashValue obtained by calculation to make verification operation,
The public key (public key) is converted into a corresponding point coordinate representation (assumed to be (x_public, y_public)) on an elliptic curve, then, the coordinate of a point Q is calculated according to an ECDSA algorithm, the base point of the elliptic curve is set as G, the order of the elliptic curve is n, the multiplication inverse element of s under the mode n is calculated first and is marked as s_index, the calculation principle is that an integer is found so that s is s_index identical to 1 (modn) (namely, the remainder of the product of s and s_index divided by n is 1, which is the definition of the mode multiplication inverse element is taken in the numerical theory), and then, the values of the abscissa Q_x and the ordinate Q_y of the point Q are calculated according to the following calculation formula:
Q_x=(s_inverse*HashValue*G.x+r*x_public)modn
Q_y=(s_inverse*HashValue*G.y+r*y_public)modn
Wherein, G.x and G.y respectively represent the abscissa and the ordinate of the base point G, and x_public and y_public are the point coordinates corresponding to the public key;
Finally, the key of verification is to determine whether the abscissa of the point Q (i.e., q_x) is equal to the r value in the digital signature after being converted into a suitable integer form, where the verification logic can be simply expressed as if q_x=r (where the values on both sides are required to be compared under the same integer representation and operation rule to ensure the accuracy of the comparison), it is explained that the digital signature verification passes, which means that the transaction is indeed initiated by the sender having the corresponding private key and the transaction content is not tampered with during the transmission process, otherwise, if q_x+.r, the digital signature verification fails, the node directly discards the transaction and does not further process it, because the validity and authenticity of the transaction cannot be guaranteed.
The step 3 includes:
Checking whether the account balance of the sender is enough to pay the transaction amount and the commission, and if the account balance is insufficient, judging that the transaction is illegal and removing;
A transmitter is determined by adopting a UTXO set firstly based on a blockchain of a UTXO (non-spent transaction output) model, and then the available balance is calculated and compared with the transaction amount and the commission;
The method adopts UTXO set to determine the sender, specifically comprises the following steps:
Traversing the blockchain historical transaction records, namely, the nodes need to access locally stored blockchain data, sequentially check each transaction information according to the sequence of transactions, and screen out the transaction records related to the sender blockchain address;
The method comprises the steps of screening the non-spent transaction output, namely checking a transaction output part of each found transaction related to a sender, wherein each transaction can have a plurality of outputs, each output has a corresponding state identifier, selecting the transaction output with the state identifier of 'non-spent', namely the UTXO currently available to the sender, and finding 'money bags' which are not used by the sender in a plurality of past transactions.
The calculation of the available balance is specifically as follows:
Extracting the amount of each UTXO, namely extracting a field value representing the amount from each record in the available UTXO set screened in the previous step, wherein the amount of each UTXO is a specific digital currency amount, the amounts of different UTXOs possibly differ, and the different UTXOs together form funds which can be governed by a sender;
Accumulating the sum to obtain the Total available Balance, namely accumulating and summing the sum of all available UTXOs to obtain the current Total available Balance of the sender, and assuming that the available UTXO Set is UTXO_set= { UTXO 1,UTXO2,…,UTXOn }, each UTXO i has a corresponding sum amount i, then the Total available Balance total_balance is calculated as follows: For example, the sender has 3 available UTXOs, and the amount is 5 digital currency units, 3 digital currency units, and 2 digital currency units, respectively, and the total available balance is 5+3+2=10 digital currency units by accumulation.
The comparison with the transaction amount and the commission fee is specifically as follows:
Acquiring the Transaction Cost, namely acquiring the Amount to be paid by the Transaction (namely, transaction Amount, which is set as transaction_amount) and the Transaction handling Fee (which is set as Fee), and adding the two to obtain the Total Cost of the Transaction, namely, total_cost=transaction_amountFee;
The balance comparison judgment is carried out, namely the calculated Total available balance (total_balance) of the sender is compared with the Total Cost (total_cost) of the transaction, if the total_balance is more than or equal to total_cost, the fact that the money of the sender is enough to pay the transaction can enter a subsequent verification flow is indicated, otherwise, if the total_balance is less than total_cost and means that the transaction cannot be completed, the transaction is judged to be an illegal transaction, the node can remove the transaction from a local transaction pool, the transaction is prevented from being transmitted and participating in subsequent processing in a blockchain network, for example, if the Total available balance is 7 digital currency units and the Total Cost of the transaction is 9 digital currency units, the transaction is judged to be illegal and the transaction is removed.
The blockchain based on the account model firstly inquires the account balance record of the sender and then compares the account balance record with the transaction amount and the commission fee;
The sender Account balance record is queried, namely, the node searches the balance according to the address, namely, the node rapidly locates and acquires the corresponding Account balance value (set as Account_balance) by taking the blockchain address of the sender as an index (similar to searching the bank Account balance by an Account number) in a locally maintained Account balance data storage (possibly based on a database management system or a specific key value pair storage structure and the like).
The comparison with the transaction amount and the commission fee is specifically as follows:
The Transaction Cost is obtained by firstly obtaining the Amount (transaction_amountto) to be paid by the Transaction and the set Transaction commission (Fee), and calculating the Total Cost total_cost=transaction_amountFee of the Transaction, for example, the Transaction Amount is 30 digital currency units, the commission is 2 digital currency units, and then the Total cost_cost=30+2=32 digital currency units;
The balance comparison and judgment is carried out, wherein the acquired Account balance (Account_balance) of the sender is compared with the Total Cost (total_cost) of the transaction, if the Account balance is more than or equal to the total_cost, the fact that the money in the Account of the sender can pay the transaction is indicated, the transaction is legal, the subsequent verification process can be continued, if the Account balance is less than the total_cost, the fact that the transaction is illegal is judged, the node can remove the transaction from the transaction pool, for example, if the Account balance is 25 digital currency units and the Total Cost of the transaction is 32 digital currency units, the transaction is judged to be illegal and the transaction is removed.
Performing double-flower checking, checking whether UTXOs involved in transactions are referenced in other transactions to be confirmed or not according to a blockchain based on the UTXO, ensuring that the same funds cannot participate in multiple concurrent transactions at the same time through a corresponding mechanism according to the blockchain based on an account model, and enabling the transactions with double-flower possibility to be not further processed and marked as abnormal;
The blockchain based on the UTXO model firstly collects input UTXO information of the transaction to be verified, then checks the quotation condition of the UTXO in the transaction to be confirmed, and if the transaction passes the double-flower check, updates the local UTXO quotation state record;
In UTXO model, the input of the Transaction points to the UTXO generated by some previous transactions, each input contains two key information, namely the Hash value (Transaction Hash) of the previous Transaction and the Output Index (Output Index) in the previous Transaction, for example, one Transaction input may be expressed as (TxHash, 0), meaning that it points to the 0 th Output in the previous Transaction with the Hash value of TxHash;
the node extracts utxoid information (i.e., a combination of the transaction hash value and the output index) related to all inputs of the transaction to be validated, forms a list, and prepares to subsequently check whether the UTXOs have been referenced in other transactions to be validated.
The node maintains a local data structure (which may be in the form of a mapping table, a database table, etc. in a memory) for recording the usage of all input UTXOs of the transactions to be confirmed in the current network, wherein the key of the data structure may be set as the identification of the UTXO (i.e. the combination string of the hash value of the transaction and the output index, such as "TxHash123 _0"), the value is a boolean type, and indicates whether the UTXO has been referenced by a certain transaction to be confirmed (e.g. True indicates that the UTXO has been referenced, false indicates that the UTXO has not been referenced);
for each UTXO identification of the transaction to be validated collected in the previous step, the node queries in a locally maintained data structure.
And at the moment, the node needs to update a UTXO reference state record data structure maintained locally, marks the reference states corresponding to all UTXO identifiers related to the transaction as referenced (namely set as True), and indicates that the UTXOs are participating in the current transaction to be verified, so that the problem that the subsequent other transactions repeatedly reference the UTXOs to cause double flowers is avoided.
Firstly extracting a serial number of a transaction to be verified based on a blockchain of an account model, then inquiring a maximum serial number of the confirmed transaction of the same account, and finally checking a serial number sequence and double-flower conditions;
The method comprises the steps of extracting a serial Number of a transaction to be verified, extracting a serial Number field value of the transaction from received transaction data to be verified by a node, wherein in a blockchain based on an account model and adopting a serial Number mechanism, each transaction is attached with a serial Number, usually an integer, and the serial Number of a new transaction is required to be larger than the maximum serial Number in confirmed transactions of the same account, so that the transaction Sequence is ensured and the double-flower problem is avoided.
The node screens all Confirmed transaction records of the account in a locally stored transaction record data structure (such as a database table, a transaction list in a memory and the like) according to the address of a sender account of the transaction to be verified, and then searches the maximum value of a serial Number field from the Confirmed transaction records, wherein the maximum value is the maximum serial Number (set as Max_confirmed_sequence_number) of the Confirmed transaction of the account.
The Sequence Number Sequence and double-flower condition are checked, the Sequence Number (set as sequence_number) of the transaction to be verified is compared with the maximum Confirmed Sequence Number (Max_confirmed_sequence_number) obtained by inquiry, and under normal conditions, the sequence_number > Max_confirmed_sequence_number should be satisfied, which means that the transaction is a new transaction initiated in Sequence;
Meanwhile, the node also checks the account balance change condition related to the transaction (for example, checks whether the locally recorded account balance has been deducted for the same amount in other unacknowledged transactions, if the repeated deduction condition exists, it may suggest that a double-flower attempt exists), if the sequence_number < = max_confirmed_sequence_number occurs and an abnormal condition such as repeated deduction exists in the account balance is found, it means that a double-flower problem may exist, and the node marks the transaction to be verified as abnormal and does not process the transaction.
The step 4 includes:
In a block chain adopting a work load proof (PoW) consensus mechanism, a miner node selects legal transaction from a transaction pool to construct a new block, a random number meeting a difficulty target is searched to enable a hash value of a block head to meet a condition, and under the work load proof (PoS) consensus mechanism, a verification node meeting corresponding conditions is responsible for selecting the transaction to construct the new block and meets the requirement of a consensus rule.
After receiving the new block, the full network node again performs format and grammar check, digital signature verification and transaction validity check on all transactions contained in the new block, and verifies whether the new block meets the requirements of a common recognition mechanism or not, if so, the new block is added to a blockchain main chain, and the transactions in the new block are finally confirmed to be effective.
The searching of the random number (mining process) meeting the difficulty target is specifically as follows:
Carrying out primary hash operation, namely taking assembled new block header information (all field values except random numbers are determined) as input by miners, and carrying out hash operation by using an SHA-256 hash algorithm to obtain an initial block header hash value;
Comparing the obtained hash value with the difficulty target set by the current network, taking a bit coin as an example, representing the difficulty target as a specific numerical value, judging whether the hash value meets the requirement by comparing the size relation between the hash value converted into the numerical value and the difficulty target numerical value, the number of the continuous 0 in the binary representation of the hash value and other conditions, and if the hash value does not meet the difficulty target (for example, the first several digits of the hash value are 0, but the corresponding position in front of the actually calculated hash value is not 0), continuously adjusting the random number;
The random number is regulated and hash operation is repeated, namely the value of the random number is increased by 1 each time (other reasonable increasing strategies can be adopted), then the hash operation is carried out on the block head information containing the new random number again to obtain a new hash value again, the comparison with a difficulty target is continued, the process is repeated continuously, and due to the randomness and the irreversibility of the hash operation, miners need to try a large number of different random number values until a random number is found, so that the calculated block head hash value meets the difficulty target set by a network.
The step 5 includes:
after confirming that the transaction is effective and adding the new block, updating the locally maintained account book state according to the transaction content;
a corresponding interface or tool is provided that allows users, authorities to query specific transaction details and history according to transaction identifiers, blockchain addresses.
Referring to fig. 2, a blockchain-based transaction verification system includes a transaction broadcasting module, a transaction verification module, an account and double-flower checking module, a block construction and verification module, and an account book management and inquiry module;
The transaction broadcasting module is used for broadcasting the transaction to the blockchain network node through the P2P network protocol after the transaction initiator constructs the transaction and digitally signs the transaction at the local client;
The transaction verification module is used for verifying format grammar and digital signature of the transaction, and determining whether to discard the transaction or enable the transaction to enter a subsequent flow according to a verification result;
The account and double-flower checking module is used for checking the balance of the account of the sender and carrying out double-flower checking, and judging and marking the transaction with the possible double flowers or insufficient balance;
the block construction and verification module coordinates corresponding nodes to construct a new block according to different consensus mechanisms, organizes the whole network nodes to verify the new block and the contained transaction, and adds the new block into a main chain after the verification is passed;
and the account book management and query module updates the account book state after the transaction confirms that the new block is effectively added, and provides an interface to facilitate the query of transaction details and history records.
The above description is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above examples, and all technical solutions belonging to the concept of the present invention belong to the protection scope of the present invention. It should be noted that modifications and adaptations to the present invention may occur to one skilled in the art without departing from the principles of the present invention and are intended to be within the scope of the present invention.

Claims (7)

1.一种基于区块链的交易验证方法,其特征在于,包括以下步骤:1. A transaction verification method based on blockchain, characterized in that it includes the following steps: 步骤1,交易发起方在本地客户端构建交易并数字签名后,通过P2P网络协议向区块链网络节点广播该交易;Step 1: After the transaction initiator constructs and digitally signs the transaction on the local client, it broadcasts the transaction to the blockchain network nodes through the P2P network protocol; 步骤2,区块链网络节点接收广播交易存于本地交易池,经格式、语法以及数字签名验证,验证失败丢弃,验证通过则进入后续流程;Step 2: The blockchain network node receives the broadcast transaction and stores it in the local transaction pool. After format, syntax and digital signature verification, it will be discarded if verification fails, and will enter the subsequent process if verification passes; 步骤3,检查发送方账户余额及进行双花检查,余额不足或存在双花可能的交易判定非法或标记异常;Step 3: Check the sender's account balance and perform double-spending checks. Transactions with insufficient balance or possible double-spending are deemed illegal or marked as abnormal. 步骤4,在不同共识机制下由相应节点按规则构建新区块,全网节点验证新区块及所含交易,通过则将新区块添入主链使交易生效;Step 4: Under different consensus mechanisms, the corresponding nodes build new blocks according to the rules, and all network nodes verify the new blocks and the transactions contained therein. If they pass, the new blocks will be added to the main chain to make the transactions effective; 步骤5,确认交易有效添加新区块后更新账本状态,并提供接口方便查询交易详情及历史记录。Step 5: After confirming that the transaction is valid and adding a new block, the ledger status is updated and an interface is provided to facilitate querying transaction details and historical records. 2.根据权利要求1所述的一种基于区块链的交易验证方法,其特征在于,所述步骤1,包括:2. According to a blockchain-based transaction verification method according to claim 1, it is characterized in that the step 1 comprises: 交易发起方在本地客户端构建包含发送方的区块链地址、接收方的区块链地址、交易金额、唯一的交易标识符以及可选的附加信息的交易;The transaction initiator constructs a transaction on the local client that includes the sender's blockchain address, the receiver's blockchain address, the transaction amount, a unique transaction identifier, and optional additional information; 所述发起方使用对应的私钥对所述交易内容进行数字签名,并将生成的数字签名进行处理得到交易数据包;The initiator uses the corresponding private key to digitally sign the transaction content, and processes the generated digital signature to obtain a transaction data packet; 将所述数字签名后的交易数据包发送给区块链网络中的节点并通过P2P网络协议进行广播。The digitally signed transaction data packet is sent to the nodes in the blockchain network and broadcasted via the P2P network protocol. 3.根据权利要求2所述的一种基于区块链的交易验证方法,其特征在于,所述步骤2,包括:3. According to a blockchain-based transaction verification method according to claim 2, it is characterized in that the step 2 comprises: 区块链网络中的节点接收所述广播的交易信息并暂存到本地交易池;The nodes in the blockchain network receive the broadcasted transaction information and temporarily store it in the local transaction pool; 对所述交易进行格式和语法检查,确保其符合区块链协议规定的结构以及各字段的类型、长度要求;Check the format and syntax of the transaction to ensure that it complies with the structure and type and length requirements of each field specified in the blockchain protocol; 使用所述发送方的公钥验证所述交易上的数字签名是否正确,若验证失败则丢弃所述交易,验证通过则进入后续验证流程。The sender's public key is used to verify whether the digital signature on the transaction is correct. If the verification fails, the transaction is discarded. If the verification passes, the subsequent verification process is entered. 4.根据权利要求3所述的一种基于区块链的交易验证方法,其特征在于,所述步骤3,包括:4. According to a blockchain-based transaction verification method according to claim 3, it is characterized in that the step 3 comprises: 检查所述发送方的账户余额是否足够支付本次交易金额及手续费,若余额不足则判定所述交易非法并移除;Check whether the sender's account balance is sufficient to pay the transaction amount and handling fee. If the balance is insufficient, the transaction is deemed illegal and removed; 进行双花检查,对于基于UTXO的区块链检查交易中涉及的UTXO是否已在其他待确认的交易中被引用,对于基于账户模型的区块链通过相应机制确保同一笔资金不会同时参与多个并发交易,存在双花可能的交易将不被进一步处理并标记为异常。Double-spending checks are performed. For UTXO-based blockchains, the UTXO involved in the transaction is checked to see if it has been referenced in other transactions to be confirmed. For account-based blockchains, corresponding mechanisms are used to ensure that the same funds will not be involved in multiple concurrent transactions at the same time. Transactions with the possibility of double spending will not be further processed and will be marked as abnormal. 5.根据权利要求4所述的一种基于区块链的交易验证方法,其特征在于,所述步骤4,包括:5. According to a blockchain-based transaction verification method according to claim 4, it is characterized in that the step 4 comprises: 在采用工作量证明共识机制的区块链中,矿工节点从交易池中选取合法交易构建新区块,通过寻找符合难度目标的随机数使得区块头的哈希值满足条件;在权益证明共识机制下,由符合相应条件的验证节点负责挑选交易构建新区块,并遵循共识规则要求;In a blockchain that uses the proof-of-work consensus mechanism, miner nodes select legitimate transactions from the transaction pool to build new blocks, and make the hash value of the block header meet the conditions by finding a random number that meets the difficulty target; under the proof-of-stake consensus mechanism, validator nodes that meet the corresponding conditions are responsible for selecting transactions to build new blocks and follow the consensus rules. 全网节点收到新区块后,对所述新区块内包含的所有交易再次进行格式和语法检查、数字签名验证以及交易合法性检查,同时验证所述新区块本身是否符合共识机制要求,若通过验证则将所述新区块添加到区块链主链上,所述新区块内交易得到最终确认生效。After receiving the new block, all nodes in the network will once again perform format and syntax checks, digital signature verification, and transaction legitimacy checks on all transactions contained in the new block, and verify whether the new block itself meets the requirements of the consensus mechanism. If it passes the verification, the new block will be added to the blockchain main chain, and the transactions in the new block will be finally confirmed and take effect. 6.根据权利要求5所述的一种基于区块链的交易验证方法,其特征在于,所述步骤5,包括:6. A transaction verification method based on blockchain according to claim 5, characterized in that step 5 comprises: 在确认所述交易有效并添加所述新区块后,根据所述交易内容更新本地维护的账本状态;After confirming that the transaction is valid and adding the new block, updating the locally maintained ledger state according to the transaction content; 提供相应接口或工具,允许用户、监管机构根据交易标识符、区块链地址查询具体交易详情及历史记录。Provide corresponding interfaces or tools to allow users and regulators to query specific transaction details and historical records based on transaction identifiers and blockchain addresses. 7.一种基于区块链的交易验证系统,其特征在于,应用于权利要求1-6任一项所述的一种基于区块链的交易验证方法,包括交易广播模块、交易验证模块、账户与双花检查模块、区块构建与验证模块以及账本管理与查询模块;7. A blockchain-based transaction verification system, characterized in that it is applied to a blockchain-based transaction verification method as described in any one of claims 1 to 6, comprising a transaction broadcast module, a transaction verification module, an account and double-spending check module, a block construction and verification module, and an account book management and query module; 交易广播模块,交易发起方在本地客户端构建交易并数字签名后,通过P2P网络协议向区块链网络节点广播该交易;Transaction broadcast module: After the transaction initiator constructs the transaction and digitally signs it on the local client, it broadcasts the transaction to the blockchain network nodes through the P2P network protocol; 交易验证模块,对交易进行格式语法及数字签名验证,根据验证结果决定是否丢弃交易或让其进入后续流程;The transaction verification module verifies the format syntax and digital signature of the transaction, and decides whether to discard the transaction or allow it to enter the subsequent process based on the verification results; 账户与双花检查模块,检查发送方账户余额及进行双花检查,对余额不足或存在双花可能的交易进行判定和标记;The account and double-spending check module checks the sender's account balance and performs double-spending checks, and determines and marks transactions with insufficient balance or possible double-spending. 区块构建与验证模块,根据不同共识机制,协调相应节点构建新区块,并组织全网节点对新区块及所含交易进行验证,在验证通过后将新区块添入主链;The block construction and verification module coordinates the corresponding nodes to build new blocks according to different consensus mechanisms, and organizes all network nodes to verify the new blocks and the transactions contained therein, and adds the new blocks to the main chain after the verification is passed; 账本管理与查询模块,在交易确认有效添加新区块后更新账本状态,并提供接口方便查询交易详情及历史记录。The ledger management and query module updates the ledger status after the transaction is confirmed to be valid and a new block is added, and provides an interface for convenient query of transaction details and historical records.
CN202411989819.5A 2024-12-31 2024-12-31 A transaction verification method and system based on blockchain Pending CN119906711A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411989819.5A CN119906711A (en) 2024-12-31 2024-12-31 A transaction verification method and system based on blockchain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411989819.5A CN119906711A (en) 2024-12-31 2024-12-31 A transaction verification method and system based on blockchain

Publications (1)

Publication Number Publication Date
CN119906711A true CN119906711A (en) 2025-04-29

Family

ID=95467500

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411989819.5A Pending CN119906711A (en) 2024-12-31 2024-12-31 A transaction verification method and system based on blockchain

Country Status (1)

Country Link
CN (1) CN119906711A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106789095A (en) * 2017-03-30 2017-05-31 腾讯科技(深圳)有限公司 Distributed system and message processing method
CN110378697A (en) * 2019-07-22 2019-10-25 南京信息工程大学 A kind of light node UTXO transaction verification method of block chain based on RSA accumulator and its device
US20220044241A1 (en) * 2020-08-08 2022-02-10 Dan Lu Achieving Decentralized Blockchain Consensus Using A State Function Driven Protocol
CN115021945A (en) * 2022-08-08 2022-09-06 四块科技(深圳)有限公司 Block chain transaction processing method and system
CN117635333A (en) * 2024-01-11 2024-03-01 国网山东省电力公司电力科学研究院 Blockchain transaction execution methods and blockchain nodes

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106789095A (en) * 2017-03-30 2017-05-31 腾讯科技(深圳)有限公司 Distributed system and message processing method
CN110378697A (en) * 2019-07-22 2019-10-25 南京信息工程大学 A kind of light node UTXO transaction verification method of block chain based on RSA accumulator and its device
US20220044241A1 (en) * 2020-08-08 2022-02-10 Dan Lu Achieving Decentralized Blockchain Consensus Using A State Function Driven Protocol
CN115021945A (en) * 2022-08-08 2022-09-06 四块科技(深圳)有限公司 Block chain transaction processing method and system
CN117635333A (en) * 2024-01-11 2024-03-01 国网山东省电力公司电力科学研究院 Blockchain transaction execution methods and blockchain nodes

Similar Documents

Publication Publication Date Title
JP7587636B2 (en) System and method for authenticating off-chain data based on proof verification
US20230410215A1 (en) Cryptographic method and system for secure extraction of data from a blockchain
CN108833081B (en) Block chain-based equipment networking authentication method
CN110089069B (en) System and method for information protection
US10944548B2 (en) Method for registration of data in a blockchain database and a method for verifying data
KR102636102B1 (en) Computer-implemented methods and systems for validating tokens for blockchain-based cryptocurrencies
CN113924747A (en) Blockchain transaction data field validation
CN110730963B (en) Systems and methods for information protection
CN110135964A (en) A kind of financial accounting method based on block chain technology
CN110009318A (en) A Monero-based digital currency tracking method
US11818271B2 (en) Linking transactions
GB2559592A (en) Blockchain (ML) Technology
CN113988857A (en) NFT transaction method, transaction system, computer-readable storage medium and terminal device
CN119444422A (en) Financial information management method and system based on blockchain technology
JP2023530594A (en) Permitted Event Processing in Distributed Databases
US11995623B2 (en) Universal payment channels
US20240311821A1 (en) Blockchain blocks &amp; proof-of-existence
CN119906711A (en) A transaction verification method and system based on blockchain
AU2019101581A4 (en) System and method for information protection
Sooksomsatarn et al. Computational cost reduction of transaction signing in blockchain
US20250371170A1 (en) Tracking hash-based signatures in LMS and XMSS using a distributed ledger
Balakrishnan et al. Test-driven development based on your own blockchain creation using javascript
Luo et al. Research on Secure Payment in the Process of Currency Transactions in Digital Economy Through Blockchain Technology
JP2025535689A (en) Method and system for applying sanctions on blockchain
Kanakam et al. Intramural Analysis of Blockchain

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination