Transaction processing method and device in block chain, electronic equipment and storage medium

By using anti-parallel algorithms in blockchain for transaction authenticity proof and consensus node verification, the problem of the inability to effectively identify sandwich attacks in the existing technology is solved, effective defense against sandwich attacks is achieved, and transaction security is improved.

CN119515386APending Publication Date: 2025-02-25WEBANK (CHINA)
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411578598.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-07
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

The existing technology cannot effectively identify sandwich attacks. The attacker uses front and back trading to gain benefits in the target transaction, causing the target trader to bear the price slippage loss.

Method used

Anti-parallel algorithm is used to prove transaction authenticity, verify transaction authenticity through consensus nodes, ensure the step-by-step transmission of transaction requests and supplementary transaction information, and increase the difficulty of attackers forgers in falsifying transactions.

Benefits of technology

Effectively identify and prevent sandwich attacks, reduce the possibility of attackers forgers invoking transactions, and improve transaction security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119515386A_ABST
    Figure CN119515386A_ABST
Patent Text Reader

Abstract

The invention discloses a transaction processing method and device in a block chain, electronic equipment and a storage medium, and belongs to the technical field of network security. In the method, after a request end obtains target transaction information required by an AMM transaction, transaction authenticity proof is carried out by using an anti-parallel algorithm; according to the method, a transaction request carrying part of target transaction information is sent to a consensus node in a block chain network, then supplementary transaction information of the transaction request is sent to the consensus node, and the supplementary transaction information comprises the remaining part of target transaction information, verification auxiliary information and authenticity proof information obtained by using an anti-parallel algorithm; a consensus node performs transaction authenticity verification based on verification auxiliary information and authenticity proof information, and responds to a transaction request based on an authenticity verification result, and when an anti-parallel algorithm is utilized to perform transaction authenticity proof, an attacker is difficult to forge a transaction matched with the authenticity proof, so that sandwich attacks can be effectively discriminated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of network security technology, and in particular to a transaction processing method, device, electronic device and storage medium in a blockchain. Background Art

[0002] In automated market maker (AMM) transactions, sandwich attacks are a common attack method that mainly exploits the time difference between transactions being processed on the blockchain to make profits.

[0003] Generally, attackers usually perform sandwich attacks by following these steps:

[0004] 1. Observe the target transaction: The attacker monitors the unconfirmed transactions in the transaction pool and looks for large transactions or transactions with high slippage;

[0005] 2. Front-running: The attacker initiates a transaction before the target transaction is executed. This is usually done by paying a higher fee to confirm the transaction first, thereby affecting the price in the liquidity pool.

[0006] 3. Back-running: After the target transaction is completed, the attacker initiates another transaction, usually in the opposite direction, to profit from price fluctuations.

[0007] In this way, two transactions are initiated before and after the target transaction, sandwiching the target transaction in the middle, so it is figuratively called a sandwich attack. In this way, the attacker can make a profit without the target trader knowing, while the target trader may suffer losses due to price slippage.

[0008] In related technologies, the slippage tolerance is adjusted to deal with sandwich attacks. Specifically, the slippage tolerance is clearly stated in the trading interface or smart contract, such as 0.5%, which means that if the slippage exceeds 0.5%, the transaction will be automatically canceled. Before executing the transaction, the smart contract checks the difference between the current market price and the user's expected price. If the difference exceeds the set slippage tolerance, the transaction will be refused. However, this method actually reduces the probability of attack by reducing the size of a single profit, and cannot effectively identify sandwich attacks. Summary of the invention

[0009] The embodiments of the present application provide a transaction processing method, device, electronic device and storage medium in a blockchain, so as to solve the problem that sandwich attacks cannot be effectively identified in the related art.

[0010] In a first aspect, an embodiment of the present application provides a transaction processing method in a blockchain, comprising:

[0011] The consensus node receives a transaction request of an automated market maker AMM transaction, wherein the transaction request includes first information. The transaction request is sent by the requesting end after obtaining the target transaction information required for the AMM transaction and starting to use the anti-parallel algorithm to prove the authenticity of the transaction. The first information includes part of the target transaction information.

[0012] receiving supplementary transaction information of the transaction request sent by the requesting end, the supplementary transaction information comprising second information, verification auxiliary information, and the latest authenticity proof information obtained by using an anti-parallel algorithm, the second information comprising information in the target transaction information except the first information, and the supplementary transaction information is sent by the requesting end after a preset condition is met;

[0013] Performing transaction authenticity verification based on the authenticity certification information and the verification auxiliary information;

[0014] Based on the authenticity verification result, respond to the transaction request.

[0015] In some embodiments, the second information includes the transaction initiation time and the exchanged object identifier.

[0016] In some embodiments, the authenticity proof information includes the latest target value, and based on the authenticity proof information and the verification auxiliary information, performing transaction authenticity verification includes:

[0017] Based on the target value and the verification auxiliary information, verify whether the anti-parallel computing amount of the requesting end matches the target duration, the starting time of the target duration is the transaction initiation time corresponding to the transaction request, and the ending time of the target duration is the time when the supplementary transaction information is received;

[0018] Based on the verification result, determine whether the AMM transaction corresponding to the transaction request is a real transaction.

[0019] In some embodiments, the authenticity proof information further includes the total number of iterative calculations, and before verifying whether the anti-parallel calculation amount of the requesting end matches the target duration based on the target value and the verification auxiliary information, it also includes:

[0020] Determining a calculation frequency of the requesting end based on the target duration and the total number of times;

[0021] It is determined that the calculation frequency of the request end is greater than the calculation frequency of the single-core processor.

[0022] In some embodiments, the first information further includes a hash value of the target transaction information and two prime numbers, the verification auxiliary information includes a target prime number and an intermediate value, and based on the target value and the verification auxiliary information, verifying whether the anti-parallel computing amount of the requesting end matches the target duration includes:

[0023] Determine an initial value according to the hash value of the target transaction information and N, where N is the product of the two prime numbers;

[0024] Substituting the initial value, the target prime number and the intermediate value into a verification algorithm to obtain a verification value;

[0025] If the verification value is equal to the target value, it is determined that the anti-parallel calculation amount of the request end matches the target duration.

[0026] In some embodiments, determining the initial value according to the hash value of the target transaction information and N includes:

[0027] Determine the value of the hash value modulo N;

[0028] If the value is not included in the set G, the hash value is increased according to the set amplitude, and the step of determining the value of the hash value modulo N is executed until the value is included in the set G, and the value is used as the initial value. The set G is used to store integers that are coprime with N.

[0029] In some embodiments, the first information further includes exchange object description information, the second information further includes exchange object identification, and further includes:

[0030] After receiving the transaction request, according to the exchange object description information, a corresponding amount of the exchange object is transferred out from the external user account corresponding to the requesting end;

[0031] Based on the authenticity verification result, responding to the transaction request includes:

[0032] After determining that it is a real transaction, according to the exchanged object identifier and AMM rules, a corresponding number of exchanged objects matching the transferred exchange objects are transferred to the external user account.

[0033] In a second aspect, an embodiment of the present application provides a transaction processing method in a blockchain, including:

[0034] After the requester obtains the target transaction information required for the AMM transaction, it begins to use the anti-parallel algorithm to prove the authenticity of the transaction;

[0035] Sending a transaction request to a consensus node, wherein the transaction request includes first information, and the first information includes part of the target transaction information;

[0036] After the preset conditions are met, supplementary transaction information of the transaction request is sent to the consensus node, wherein the supplementary transaction information includes second information, verification auxiliary information and the latest authenticity proof information obtained using an anti-parallel algorithm, so as to trigger the consensus node to perform transaction authenticity verification based on the verification auxiliary information and the authenticity proof information, and respond to the transaction request based on the authenticity verification result, wherein the second information includes information in the target transaction information except the first information, and the verification auxiliary information is generated by a verification auxiliary algorithm.

[0037] In some embodiments, transaction authenticity verification is performed according to the following steps:

[0038] Determine an initial value according to the hash value of the target transaction information and N, where N is the product of two randomly generated prime numbers, both of which are greater than a preset value;

[0039] Using the initial value as an input parameter of the anti-parallel algorithm for iterative calculation, wherein the target value after taking the modulo N of the result of each iterative calculation is used as the input value of the next iterative calculation; and

[0040] The first information also includes a hash value of the target transaction information and the two prime numbers, and the authenticity proof information includes the latest target value.

[0041] In some embodiments, the authenticity proof information also includes the total number of iterative calculations.

[0042] In some embodiments, the verification auxiliary information includes a target prime number and an intermediate value, wherein the target prime number is selected from the set G, and the target prime number is not less than at least one of the two prime numbers, and the intermediate value is obtained by substituting the target prime number into a verification auxiliary algorithm.

[0043] In some embodiments, determining the initial value according to the hash value of the target transaction information and N includes:

[0044] Determine the value of the hash value modulo N;

[0045] If the value is not included in the set G, the hash value is increased according to the set amplitude, and the step of determining the value of the hash value modulo N is executed until the value is included in the set G, and the value is used as the initial value. The set G is used to store integers that are coprime with N.

[0046] In some embodiments, it also includes:

[0047] If it is determined that the AMM transaction corresponding to the transaction request is successfully executed, the transaction authenticity proof will be stopped.

[0048] In some embodiments, it also includes:

[0049] If it is determined that the AMM transaction corresponding to the transaction request has failed, the step of sending a transaction request to the consensus node is executed until the transaction cancellation condition is met, and then the AMM transaction cancellation request is sent to the consensus node.

[0050] In a third aspect, an embodiment of the present application provides a transaction processing device in a blockchain, including:

[0051] A first receiving module is used to receive a transaction request of an automated market maker AMM transaction, wherein the transaction request includes first information, and the transaction request is sent after the requesting end obtains the target transaction information required for the AMM transaction and starts to use the anti-parallel algorithm to prove the authenticity of the transaction, and the first information includes part of the target transaction information;

[0052] a second receiving module, configured to receive supplementary transaction information of the transaction request sent by the requesting end, wherein the supplementary transaction information includes second information, verification auxiliary information, and the latest authenticity proof information obtained by using an anti-parallel algorithm, wherein the second information includes information in the target transaction information other than the first information, and the supplementary transaction information is sent by the requesting end after a preset condition is met;

[0053] A verification module, used to verify the authenticity of the transaction based on the authenticity proof information and the verification auxiliary information;

[0054] The response module is used to respond to the transaction request based on the authenticity verification result.

[0055] In a fourth aspect, an embodiment of the present application provides a transaction processing device in a blockchain, including:

[0056] The proof module is used to obtain the target transaction information required for the automated market maker AMM transaction, and then use the anti-parallel algorithm to prove the authenticity of the transaction;

[0057] A first sending module, configured to send a transaction request to a consensus node, wherein the transaction request includes first information, and the first information includes part of the target transaction information;

[0058] The second sending module is used to send supplementary transaction information of the transaction request to the consensus node after the preset conditions are met, and the supplementary transaction information includes second information, verification auxiliary information and the latest authenticity proof information obtained by using the anti-parallel algorithm, so as to trigger the consensus node to perform transaction authenticity verification based on the verification auxiliary information and the authenticity proof information, and respond to the transaction request based on the authenticity verification result, the second information includes information in the target transaction information except the first information, and the verification auxiliary information is generated by a verification auxiliary algorithm.

[0059] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein:

[0060] The memory stores a computer program that can be executed by at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the transaction processing method in the above-mentioned blockchain.

[0061] In a sixth aspect, an embodiment of the present application provides a storage medium. When the computer program in the storage medium is executed by a processor of an electronic device, the electronic device can execute the transaction processing method in the above-mentioned blockchain.

[0062] In a seventh aspect, an embodiment of the present application provides a computer program product, including a computer program, which implements the transaction processing method in the above-mentioned blockchain when executed by a processor.

[0063] In the embodiment of the present application, after the request end obtains the target transaction information required for the AMM transaction, it starts to use the anti-parallel algorithm to prove the authenticity of the transaction, and sends a transaction request carrying part of the target transaction information to the consensus node in the blockchain network. After that, it sends the supplementary transaction information of the transaction request to the consensus node. The supplementary transaction information includes the remaining target transaction information, verification auxiliary information and the authenticity proof information obtained by using the anti-parallel algorithm. The consensus node verifies the authenticity of the transaction based on the verification auxiliary information and the authenticity proof information, and responds to the transaction request based on the authenticity verification result. Since it is difficult for an attacker to forge a transaction that matches the authenticity proof when using the anti-parallel algorithm to prove the authenticity of the transaction, the sandwich attack can be effectively identified. In addition, the attacker generally launches the attack after seeing the complete transaction information, and the target transaction information is sent twice, which can make the complete transaction information lag behind the transaction request and be exposed on the blockchain. In this way, it can further increase the difficulty for the attacker to forge the authenticity proof and launch a sandwich attack, and it can also reduce the probability of the attacker launching a sandwich attack to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0065] Figure 1 A schematic diagram of a curve of a constant product function provided in an embodiment of the present application;

[0066] Figure 2 A schematic diagram of price changes of a transaction provided in an embodiment of the present application;

[0067] Figure 3 A flowchart of a transaction processing method in a blockchain provided in an embodiment of the present application;

[0068] Figure 4 A flowchart for proving the authenticity of a transaction provided in an embodiment of the present application;

[0069] Figure 5 A schematic diagram of the structure of a transaction processing device in a blockchain provided in an embodiment of the present application;

[0070] Figure 6 A schematic diagram of the structure of another transaction processing device in a blockchain provided in an embodiment of the present application;

[0071] Figure 7 A schematic diagram of the hardware structure of an electronic device for implementing a transaction processing method in a blockchain provided in an embodiment of the present application. DETAILED DESCRIPTION

[0072] In order to solve the problem that sandwich attacks cannot be effectively identified in the related art, the embodiments of the present application provide a transaction processing method, device, electronic device and storage medium in a blockchain.

[0073] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.

[0074] In order to facilitate the understanding of this application, the technical terms involved in this application are:

[0075] Token, in blockchain technology, refers to a token, which is a form of cryptocurrency, such as the ERC-20 token on Ethereum. It can be used as a digital asset to represent specific assets or values, and is mostly used in transactions, investments, payments and other activities on decentralized finance (DeFi) platforms.

[0076] AMM trading automatically performs market-making functions through smart contracts and mathematical algorithms, providing a trading solution for decentralized exchanges (DEX) without intermediaries. The core of AMM lies in its unique market mechanism, which does not rely on traditional order books or professional market makers, but relies on pre-set mathematical formulas to determine asset prices. The most typical AMM model uses a constant product formula: x*y=k, where x and y are the quantities of two assets in the liquidity pool, and k is a constant. This formula ensures that whenever a transaction occurs, the product of the quantities of the two assets in the pool remains unchanged, thereby dynamically adjusting the price.

[0077] See also Figure 1 , Figure 1 A curve diagram of a constant product function provided in an embodiment of the present application, wherein the horizontal axis x represents the number of token0s in the pool, and the vertical axis y represents the number of token1s in the pool. The starting point of each transaction is the point on the curve corresponding to the current ratio of the two tokens. In order to calculate the number of tokens obtained from the transaction, it is necessary to find a new point on the curve, whose horizontal coordinate value is x+Δx, that is, the current number of token0s in the pool plus the number of sold tokens, and the change on the y-axis is the number of token1s that will be obtained.

[0078] Although Uniswap does not calculate transaction prices, there are many prices in a transaction: before the transaction, there is a spot price, which is equal to the ratio of the two assets in the pool: y / x or x / y, depending on the direction of the transaction, and this price is also the slope of the tangent line at the starting point. After the transaction, there is a new spot price, which is the slope of the tangent line at the new point. The actual price of the transaction is the slope of the line connecting the new and old points.

[0079] See also Figure 2 , Figure 2 A schematic diagram of price changes of a transaction provided in an embodiment of the present application, wherein the solid line represents the curve of the constant product function. At the beginning, the number of the two tokens is equal, both 400, so the starting price is 1. Assuming that 200 token0s are sold, if only the spot price is calculated, 200 token1s are expected to be obtained. However, since other transactions change the number of the two assets in the pool, the end price is 0.444, and the actual price of the transaction is Δy / Δx=133.333 / 200=0.666. This transaction actually only obtains 133.333 token1s.

[0080] Due to this characteristic, sandwich attacks are a common attack method in AMMs, which exploit the time difference when transactions are processed on the blockchain to make profits.

[0081] Generally, attackers usually perform sandwich attacks by following these steps:

[0082] 1. Observe the target transaction: The attacker monitors the unconfirmed transactions in the transaction pool and looks for large transactions or transactions with high slippage;

[0083] 2. Front-running: The attacker initiates a transaction before the target transaction is executed. This is usually done by paying a higher fee to confirm the transaction first, thereby affecting the price in the liquidity pool.

[0084] 3. Back-running: After the target transaction is completed, the attacker initiates another transaction, usually in the opposite direction, to profit from price fluctuations.

[0085] In this way, two transactions are initiated before and after the target transaction, sandwiching the target transaction in the middle, so it is figuratively called a sandwich attack. In this way, the attacker can make a profit without the target trader knowing, while the target trader may suffer losses due to price slippage.

[0086] In related technologies, the slippage tolerance is adjusted to deal with sandwich attacks. Specifically, the slippage tolerance is clearly stated in the trading interface or smart contract, such as 0.5%, which means that if the slippage exceeds 0.5%, the transaction will be automatically canceled. Before executing the transaction, the smart contract checks the difference between the current market price and the user's expected price. If the difference exceeds the set slippage tolerance, the transaction will be refused. However, this method actually reduces the probability of attack by reducing the size of a single profit, and cannot effectively identify sandwich attacks.

[0087] In the embodiment of the present application, after the request end obtains the target transaction information required for the AMM transaction, it starts to use the anti-parallel algorithm to prove the authenticity of the transaction, and sends a transaction request carrying part of the target transaction information to the consensus node in the blockchain network. After that, it sends the supplementary transaction information of the transaction request to the consensus node. The supplementary transaction information includes the remaining target transaction information, verification auxiliary information and the latest authenticity proof information obtained by using the anti-parallel algorithm. The consensus node verifies the authenticity of the transaction based on the verification auxiliary information and the authenticity proof information, and responds to the transaction request based on the authenticity verification result. Since it is difficult for an attacker to forge a transaction that matches the authenticity proof when using the anti-parallel algorithm to prove the authenticity of the transaction, the sandwich attack can be effectively identified. In addition, the attacker generally launches the attack after seeing the complete transaction information, and the target transaction information is sent twice, which can make the complete transaction information lag behind the transaction request and be exposed on the blockchain. In this way, it can further increase the difficulty for the attacker to forge the authenticity proof and reduce the probability of the sandwich attack.

[0088] See also Figure 3 , Figure 3 An interactive flow chart of a transaction processing method in a blockchain provided in an embodiment of the present application includes the following steps.

[0089] In step 301, after the requesting end obtains the target transaction information required for the AMM transaction, it begins to use the anti-parallel algorithm to prove the authenticity of the transaction.

[0090] Among them, the target transaction information includes the description information of the exchange object such as the name and quantity of the exchange object, the identifier of the exchanged object such as the name of the exchanged object, the time when the transaction was initiated, the hash value F5 of the block height of the blockchain network when the transaction was initiated, the identifier of the transaction, the external user account (Externally Owned Account, EOA) address F7 corresponding to the requesting end, the contract address F8 of the AMM, and the hash calculation result F9 after splicing all fields, that is, F9 = Hash (F1, F2, F3, F4, F5, F6, F7, F8).

[0091] In specific implementation, Figure 4 The process shown in the figure proves the authenticity of the transaction, including the following steps:

[0092] In step 301a, an initial value is determined based on the hash value of the target transaction information and N, where N is the product of two randomly generated prime numbers, both of which are greater than a preset value.

[0093] For example, the value of the hash value modulo N of the target transaction information is calculated and determined. If this value is not included in the set G, the hash value of the target transaction information is increased by a set amount, and the step of calculating the value of the hash value modulo N of the target transaction information is performed until this value is included in the set G, and this value is used as the initial value, wherein the set G is used to store integers that are coprime to N.

[0094] In step 302a, the initial value is used as an input parameter of the anti-parallel algorithm for iterative calculation, wherein the target value modulo N of each iterative calculation result is used as the input value of the next iterative calculation.

[0095] For example, the anti-parallel algorithm is: 2t mod N.

[0096] The core operation of the anti-parallel algorithm is to repeatedly square x 2tThis process is sequential and must be performed step by step. It cannot be split into independent subtasks for parallel processing. The calculation result of each step depends on the calculation result of the previous step. This dependence means that the calculation cannot be assigned to multiple processors such as CPUs for parallel processing. The amount of calculation (i.e., the number of iterations) is proportional to the calculation time. In addition, the result of each iteration is calculated modulo N and used as the input for the next iteration, which can ensure that the calculated value is not greater than N, thereby reducing the calculation complexity. It should be noted that this is only an example, and other exponential functions can also be used.

[0097] In actual applications, blockchain networks conduct transactions in the order of the transaction initiation time, and sandwich attacks manipulate prices through a large number of forged transactions to make profits. The key to the attacker's forgery is to forge the transaction initiation time. If an anti-parallel algorithm is used, any request end that wants to conduct AMM transactions must first prove the authenticity of the transaction through an anti-parallel algorithm, then send a transaction request, and then submit the transaction supplementary information of the transaction request. From the transaction initiation time to the time when the consensus node receives the transaction supplementary information, the request end needs to perform anti-parallel calculations all the time. If the transaction initiation time is forged (that is, the transaction initiation time carried in the transaction request is later than the actual transaction initiation time), the amount of anti-parallel calculations performed by the request end must be too little. The consensus node can effectively identify the sandwich attack by judging whether the amount of anti-parallel calculations submitted by the request end is sufficient.

[0098] In step 302, the requesting end sends a transaction request to the consensus node, where the transaction request includes first information, and the first information includes part of the target transaction information.

[0099] In some embodiments, the first information further includes a hash value of the target transaction information and the two prime numbers mentioned above.

[0100] In actual applications, after the requesting end starts using the anti-parallel algorithm to prove the authenticity of the transaction, it can send a transaction request to the consensus node.

[0101] In some embodiments, the first information also includes exchange object description information. After receiving the transaction request, the corresponding amount of exchange objects can be transferred from the external user account corresponding to the requesting end according to the exchange object description information. This operation similar to mortgage freezing can prevent the requesting end from submitting forged transaction requests indefinitely, further increasing the difficulty of transaction forgery.

[0102] In step 303, after the preset conditions are met, the requesting end sends supplementary transaction information of the transaction request to the consensus node. The supplementary transaction information includes the second information, verification auxiliary information and the latest authenticity proof information obtained using the anti-parallel algorithm. The second information includes information in the target transaction information except the first information. The verification auxiliary information is generated by the verification auxiliary algorithm.

[0103] Among them, the preset condition is, for example, after a preset duration of sending a transaction request.

[0104] In some embodiments, the second information includes the transaction initiation time and the identifier of the object to be exchanged.

[0105] In this way, the transaction initiation time and the identifier of the object to be exchanged are exposed later than the transaction request. Generally, an attacker发起攻击 after seeing the initiation time and the identifier of the object to be exchanged. Since the time when the attacker sees this information is later than the transaction initiation time, it is very difficult to catch up with the parallel computing volume during this period, that is, it is very difficult to forge a transaction, which can reduce the probability of the attacker发起三明治攻击 to a certain extent.

[0106] In some embodiments, the authenticity proof information includes the latest target value.

[0107] In some embodiments, the authenticity proof information further includes the total number of iterative calculations.

[0108] In some embodiments, the verification auxiliary information includes a target prime number and an intermediate value. The target prime number is selected from the set G, and the target prime number is not less than at least one of the two prime numbers. The intermediate value is obtained by substituting the target prime number into the verification auxiliary algorithm.

[0109] For example, select a prime number p from the set G, p < N, and p >= a or p >= b, and calculate r = 2 t mod p, Then p is the target prime number, and both r and v are intermediate values.

[0110] In step 304, the consensus node performs transaction authenticity verification based on the authenticity proof information and the verification auxiliary information.

[0111] In some embodiments, if the authenticity proof information includes the latest target value, then based on the target value and the verification auxiliary information, it can be verified whether the anti-parallel computing volume of the requesting end matches the target duration, and then based on the verification result, it can be determined whether the AMM transaction corresponding to the transaction request is a real transaction. Among them, the start time of the target duration is the transaction initiation time corresponding to the transaction request, and the end time of the target duration is the time when the supplementary transaction information of the transaction request is received.

[0112] When the first information further includes the hash value of the target transaction information and two prime numbers, and the verification auxiliary information includes the target prime number and the intermediate value, then the initial value can be determined according to the hash value of the target transaction information and N, where N is the product of the two prime numbers. Substitute the initial value, the target prime number, and the intermediate value into the verification algorithm to obtain the verification value. If the verification value is equal to the target value, it is determined that the anti-parallel computing volume of the requesting end matches the target duration. Among them, the process of determining the initial value is the same as that of the requesting end and will not be elaborated here.

[0113] In some embodiments, the authenticity proof information includes the latest target value and the total number of iterative calculations. The calculation frequency of the requesting end can be determined based on the target duration and the total number of iterative calculations to determine whether the calculation frequency of the requesting end is greater than the calculation frequency of the single-core processor. If not, it can be determined that the transaction is not authentic. If so, it can be further verified based on the target value and verification auxiliary information whether the anti-parallel calculation amount of the requesting end matches the target duration. Based on the verification result, it is determined whether the AMM transaction corresponding to the transaction request is a real transaction.

[0114] In step 305, the consensus node responds to the transaction request based on the authenticity verification result.

[0115] In some embodiments, the second information also includes the exchanged object identifier. After determining that it is a real transaction, the corresponding number of exchanged objects matching the transferred exchange object can be transferred to the external user account corresponding to the requesting end according to the exchanged object identifier and AMM rules. If it is determined to be a fake transaction, the transaction can be rolled back.

[0116] In step 306, if the requesting end determines that the AMM transaction corresponding to the transaction request is successfully executed, it stops proving the authenticity of the transaction.

[0117] In actual applications, the requesting end can monitor the execution status of the corresponding AMM transaction. If the execution is determined to be successful, the transaction authenticity proof can be stopped. If the execution is determined to be failed, the transaction request can be resent to the consensus node until the transaction cancellation conditions are met. For example, if the execution fails twice in a row, an AMM transaction cancellation request can be sent to the consensus node.

[0118] The scheme of the embodiment of the present application is introduced below in conjunction with specific embodiments.

[0119] The first step is that the requesting end obtains the target transaction information required for the AMM transaction.

[0120] The target transaction information includes the following information:

[0121] The name of the token to be exchanged (i.e. the exchange object) F1, such as Asset0;

[0122] The number of tokens to be exchanged F2, for example 1000;

[0123] The name of the target token (i.e. the object to be exchanged) F3, for example, Asset1;

[0124] The timestamp F4 of the transaction initiation (i.e. the time when the transaction was initiated), for example, November 5, 2024, 16:59:49;

[0125] The hash value F5 of the block height of the blockchain network when the transaction is initiated. This hash value can prove that the user can only initiate the transaction after the time when this block height is created, because the user cannot fabricate this block height. Through this property, it can be ensured that the transaction requester cannot rush ahead, and the transaction can only be initiated after the current block is generated;

[0126] The transaction identifier nonce F6, which can be any random number, is used to prevent duplicate transactions and ensure the uniqueness of transactions;

[0127] The EOA address corresponding to the requesting end is F7;

[0128] AMM’s contract address F8;

[0129] F9 is the hash calculation result after concatenating all the above fields, that is, F9 = Hash (F1, F2, F3, F4, F5, F6, F7, F8).

[0130] In the second step, the requesting end starts to execute the transaction authenticity proof.

[0131] a. Select the initial value of the authenticity proof.

[0132] The requester randomly selects two large prime numbers a and b (in order to improve the robustness of the algorithm, it is required that both a and b are greater than the preset value, and a and b are not repeated with the previously submitted large prime numbers), and calculates the product N of a and b. Then, the group G is defined as (Z / NZ) × , that is, G is the set of all integers that are relatively prime to N. For ease of understanding, we can choose small a and b as examples, such as a=3, b=5, then N=15, then G={1, 2, 4, 7, 8, 11, 13, 14}.

[0133] Then, calculate the initial value x=F9 mod N. If x is not in group G, set F9=F9+1 and recalculate x=F9 mod N until x belongs to group G, and use x as the initial value.

[0134] b. Perform calculations to prove the authenticity of the calculations.

[0135] calculate

[0136] The core operation of the algorithm is repeated squaring This process is sequential and must be performed step by step. It cannot be split into independent subtasks for parallel processing. The calculation result of each step depends on the calculation result of the previous step. This dependence means that the calculation cannot be assigned to multiple processors for parallel processing. The amount of calculation is proportional to the calculation time. In addition, It can ensure that the value of Y is not greater than N, thereby reducing the computational complexity.

[0137] Step 3: The requesting end sends the transaction request of the AMM transaction to the consensus nodes in the blockchain.

[0138] In practical applications, the requesting end can submit a transaction request to the blockchain network through the Software Development Kit (SDK) of the blockchain. The transaction request contains the first information, and the first information may include the following information:

[0139] The name F1 of the token to be exchanged;

[0140] The quantity F2 of the token to be exchanged;

[0141] The hash value F5 of the block height of the blockchain network when the transaction is initiated;

[0142] The nonce F6 of the transaction;

[0143] The EOA address F7 corresponding to the requesting end;

[0144] The contract address F8 of the AMM;

[0145] F9;

[0146] Large prime numbers a and b.

[0147] Step 4: The consensus nodes verify whether the transaction is legal.

[0148] The consensus node corresponding to the contract address F8 can first check whether the block hash of F5 exists. If it exists, then check whether the transaction nonce of F6, the large prime numbers a and b, exist repeatedly. If there is a repetition, the transaction can be rolled back. If the check passes, it can authorize the transfer of the token F1 from the EOA address F7, with a quantity of F2, for subsequent transactions. Through this operation similar to collateral freezing, it can prevent the requesting end from submitting forged transaction requests infinitely and further increase the difficulty of transaction forgery.

[0149] In addition, since the target token F3 is not public and the timestamp F4 of the transaction initiation is not public, the difficulty of attacking the transaction for the attacker is also increased. Because when the currency pair and the transaction timestamp of the transaction cannot be determined, attacking rashly may cause the attacker to be subject to a sandwich attack instead.

[0150] Step 5: When the preset conditions are met, the requesting end sends supplementary transaction information of the transaction request to the consensus nodes.

[0151] For example, after a preset duration, such as the preset duration for sending the transaction request, select a prime number p from G, where p < N and p >= a or p >= b, and calculate r = 2 t mod p, For example, choose p=3 and calculate r=2 3 mod 3 = 2, calculate

[0152] Then, send the supplementary transaction information, the parameters of which are as follows:

[0153] The name of the target token (i.e. the object to be exchanged) F3;

[0154] Timestamp of transaction initiation F4;

[0155] The transaction nonce F6;

[0156] prime number p;

[0157] The intermediate value r of the verification;

[0158] The intermediate value v of the verification;

[0159] The latest target value Y;

[0160] The number of parallel calculations is Tv.

[0161] Assuming that the consensus node receives the supplementary transaction information at time T1, F3 and F4 will be made public only at time T1. If the consensus node itself is an attacker, then F3 and F4 can only be learned at time T1. At this moment, T1-F4 has passed. Due to the limitations of the anti-parallel algorithm, it is impossible for the attacker to catch up with the anti-parallel computing during this period.

[0162] Step 6: The consensus node verifies the authenticity of the transaction.

[0163] According to the transaction nonce F6, the previous transaction information is queried to verify whether the value of F9 is correct, that is, verify whether F9 is equal to Hash (F1, F2, F3, F4, F5, F6, F7, F8). If not, the transaction is rolled back. If so, the values ​​of F4 and F5 can be verified to be correct, such as checking whether the difference between F4 and the block timestamp corresponding to the hash value F5 of the block height of the blockchain network when the transaction was initiated is less than the empirical threshold. If not, the transaction is rolled back. If so, it can be verified whether the calculation frequency of the request end matches the calculation frequency of the single-core processor.

[0164] Specifically, it is determined whether the target duration (i.e., T1-F4) is greater than the set value. If the set value is greater than the preset value, if not, the possibility of the transaction being forged is high, and the transaction can be determined to be forged (i.e., a non-authentic transaction). If so, the ratio of the target duration to Tv (i.e., the calculation frequency of the requesting end) can be calculated. If the ratio is less than the calculation frequency of a single-core processor, such as 100,000, it can be determined that the transaction is forged, that is, the transaction may be constructed at a time after F4, and the transaction is automatically rolled back. If the ratio is not less than the calculation frequency of a single-core processor, it can be verified whether the anti-parallel calculation amount of the requesting end matches the target duration.

[0165] Specifically, obtain F9, a, and b corresponding to the transaction, calculate the product N of a and b, calculate x based on F9 and N, the calculation method is the same as the request end, and will not be repeated here. Then, verify v based on x, p, r, and v p ·x r =Y is true. For example, r = 2, v = 4, p = 3, x = 2, Y = 1, then 4 3 *2 2 =64*4=256mod 15=1, then it is confirmed to be a real transaction.

[0166] Here, the consensus node needs to verify v p ·x r =Y, substitute Transformed into So the verification equation becomes: Thus, the formula is proved, which ensures the correctness of this algorithm.

[0167] And, since v is calculated during verification p and x r The complexity is low, which makes the computational complexity of verification significantly smaller than that of authenticity calculation, so the consensus node can complete the verification in a very short time.

[0168] Step 7: The consensus node adds transactions that have passed the authenticity verification to the transaction pool to be executed.

[0169] Once all the above checks are passed, the transaction can be marked as pending, and the transaction will then be placed in the pending transaction pool by the AMM contract.

[0170] Step 8. The consensus node smart contract sorts and executes transactions based on transaction timestamps.

[0171] For the above transaction, the F2 amount of token1 is converted into the corresponding token2.

[0172] In actual applications, consensus nodes sort and execute transactions in order according to the F4 of each transaction. The earlier the transaction, the earlier it will be executed. Since the Ethereum Virtual Machine (EVM) is strictly single-threaded, this mechanism can ensure that transactions are executed in the order in which they were initiated, thereby effectively eliminating the possibility of sandwich transaction attacks.

[0173] Step 9: The requesting end detects that the transaction is successful and stops the calculation of transaction authenticity proof.

[0174] In actual applications, if the time difference between the requester and the consensus node is too large, the real transaction may be misjudged as a forged transaction. Therefore, if the requester detects that the transaction failed, it can not terminate the authenticity verification operation, but re-execute step 5 and provide the latest proof of work. If the transaction fails again, the authenticity verification operation can be terminated and a request to cancel the transaction can be submitted to the consensus node. The corresponding token1 F1 will be returned to the requester's account after deducting a certain handling fee and gas fee. If the transaction is detected to be successful, the authenticity verification operation can be terminated.

[0175] Based on the same technical concept, the embodiments of the present application also provide two transaction processing devices in blockchains. The principles of solving problems by the transaction processing devices in blockchains are similar to the transaction processing methods in the above-mentioned blockchains. Therefore, the implementation of the transaction processing devices in blockchains can refer to the implementation of the transaction processing methods in blockchains, and the repeated parts will not be repeated.

[0176] Figure 5 A schematic diagram of a transaction processing device in a blockchain provided in an embodiment of the present application includes:

[0177] The first receiving module 501 is used to receive a transaction request of an automated market maker AMM transaction, wherein the transaction request includes first information. The transaction request is sent by the requesting end after obtaining the target transaction information required for the AMM transaction and starting to use the anti-parallel algorithm to prove the authenticity of the transaction. The first information includes part of the target transaction information.

[0178] A second receiving module 502 is used to receive supplementary transaction information of the transaction request sent by the requesting end, wherein the supplementary transaction information includes second information, verification auxiliary information, and the latest authenticity proof information obtained by using an anti-parallel algorithm, wherein the second information includes information in the target transaction information except the first information, and the supplementary transaction information is sent by the requesting end after a preset condition is met;

[0179] Verification module 503, used to verify the authenticity of the transaction based on the authenticity certification information and the verification auxiliary information;

[0180] The response module 504 is used to respond to the transaction request based on the authenticity verification result.

[0181] In some implementations, the second information includes the transaction initiation time and the exchanged object identifier.

[0182] In some implementations, the authenticity proof information includes the latest target value, and the verification module 503 is specifically used to:

[0183] Based on the target value and the verification auxiliary information, verify whether the anti-parallel computing amount of the requesting end matches the target duration, the starting time of the target duration is the transaction initiation time corresponding to the transaction request, and the ending time of the target duration is the time when the supplementary transaction information is received;

[0184] Based on the verification result, determine whether the AMM transaction corresponding to the transaction request is a real transaction.

[0185] In some implementations, the authenticity proof information further includes the total number of iterative calculations, and the verification module 503 is further used to:

[0186] Before verifying whether the anti-parallel computing amount of the request end matches the target duration based on the target value and the verification auxiliary information, determining the computing frequency of the request end based on the target duration and the total number of times;

[0187] It is determined that the calculation frequency of the request end is greater than the calculation frequency of the single-core processor.

[0188] In some implementations, the first information further includes a hash value of the target transaction information and two prime numbers, the verification auxiliary information includes a target prime number and an intermediate value, and the verification module 503 is specifically used to:

[0189] Determine an initial value according to the hash value of the target transaction information and N, where N is the product of the two prime numbers;

[0190] Substituting the initial value, the target prime number and the intermediate value into a verification algorithm to obtain a verification value;

[0191] If the verification value is equal to the target value, it is determined that the anti-parallel calculation amount of the request end matches the target duration.

[0192] In some implementations, the verification module 503 is specifically configured to:

[0193] Determine the value of the hash value modulo N;

[0194] If the value is not included in the set G, the hash value is increased according to the set amplitude, and the step of determining the value of the hash value modulo N is executed until the value is included in the set G, and the value is used as the initial value. The set G is used to store integers that are coprime with N.

[0195] In some implementations, the first information further includes exchange object description information, the second information further includes exchange object identification, and the response module 504 is further configured to:

[0196] After receiving the transaction request, according to the exchange object description information, a corresponding amount of the exchange object is transferred out from the external user account corresponding to the requesting end;

[0197] After determining that it is a real transaction, according to the exchanged object identifier and AMM rules, a corresponding number of exchanged objects matching the transferred exchange objects are transferred to the external user account.

[0198] Figure 6 A schematic diagram of a transaction processing device in a blockchain provided in an embodiment of the present application includes:

[0199] The proof module 601 is used to obtain the target transaction information required for the automated market maker AMM transaction and then use the anti-parallel algorithm to prove the authenticity of the transaction;

[0200] A first sending module 602 is used to send a transaction request to a consensus node, wherein the transaction request includes first information, and the first information includes part of the target transaction information;

[0201] The second sending module 603 is used to send supplementary transaction information of the transaction request to the consensus node after the preset conditions are met, and the supplementary transaction information includes the second information, verification auxiliary information and the latest authenticity proof information obtained by using the anti-parallel algorithm, so as to trigger the consensus node to perform transaction authenticity verification based on the verification auxiliary information and the authenticity proof information, and respond to the transaction request based on the authenticity verification result, the second information includes information in the target transaction information except the first information, and the verification auxiliary information is generated by a verification auxiliary algorithm.

[0202] In some embodiments, the certification module 601 is specifically used to perform transaction authenticity certification according to the following steps:

[0203] Determine an initial value according to the hash value of the target transaction information and N, where N is the product of two randomly generated prime numbers, both of which are greater than a preset value;

[0204] Using the initial value as an input parameter of the anti-parallel algorithm for iterative calculation, wherein the target value after taking the modulo N of the result of each iterative calculation is used as the input value of the next iterative calculation; and

[0205] The first information also includes a hash value of the target transaction information and the two prime numbers, and the authenticity proof information includes the latest target value.

[0206] In some embodiments, the authenticity proof information also includes the total number of iterative calculations.

[0207] In some embodiments, the verification auxiliary information includes a target prime number and an intermediate value, wherein the target prime number is selected from the set G, and the target prime number is not less than at least one of the two prime numbers, and the intermediate value is obtained by substituting the target prime number into a verification auxiliary algorithm.

[0208] In some embodiments, the certification module 601 is specifically used to:

[0209] Determine the value of the hash value modulo N;

[0210] If the value is not included in the set G, the hash value is increased according to the set amplitude, and the step of determining the value of the hash value modulo N is executed until the value is included in the set G, and the value is used as the initial value. The set G is used to store integers that are coprime with N.

[0211] In some embodiments, the certification module 601 is further configured to:

[0212] If it is determined that the AMM transaction corresponding to the transaction request is successfully executed, the transaction authenticity proof will be stopped.

[0213] In some embodiments, the processing module 604 is further included, which is used to:

[0214] If it is determined that the AMM transaction corresponding to the transaction request has failed, the step of sending a transaction request to the consensus node is executed until the transaction cancellation condition is met, and then the AMM transaction cancellation request is sent to the consensus node.

[0215] The division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, the functional modules in the embodiments of the present application may be integrated in a processor, or may exist physically separately, or two or more modules may be integrated in one module. The coupling between the modules may be achieved through some interfaces, which are usually electrical communication interfaces, but it is not excluded that they may be mechanical interfaces or other forms of interfaces. Therefore, the modules described as separate components may or may not be physically separated, and may be located in one place or distributed to different locations of the same or different devices. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.

[0216] After introducing the transaction processing method and device in the blockchain according to the exemplary embodiment of the present application, next, an electronic device according to another exemplary embodiment of the present application is introduced.

[0217] Refer to the following Figure 7 The electronic device 130 implemented according to this embodiment of the present application is described. Figure 7 The electronic device 130 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0218] like Figure 7 As shown, the electronic device 130 is in the form of a general electronic device. The components of the electronic device 130 may include but are not limited to: the at least one processor 131, the at least one memory 132, and a bus 133 connecting different system components (including the memory 132 and the processor 131).

[0219] Bus 133 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a processor, or a local bus using any of a variety of bus architectures.

[0220] The memory 132 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 1321 and / or a cache memory 1322 , and may further include a read-only memory (ROM) 1323 .

[0221] The memory 132 may also include a program / utility 1325 having a set (at least one) of program modules 1324, such program modules 1324 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0222] The electronic device 130 may also communicate with one or more external devices 134 (e.g., keyboards, pointing devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 130, and / or communicate with any device that enables the electronic device 130 to communicate with one or more other electronic devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 135. Furthermore, the electronic device 130 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 136. As shown, the network adapter 136 communicates with other modules for the electronic device 130 via a bus 133. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 130, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0223] In an exemplary embodiment, a storage medium is also provided, and when the computer program in the storage medium is executed by the processor of the electronic device, the electronic device can execute the transaction processing method in the above-mentioned blockchain. Optionally, the storage medium can be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0224] In an exemplary embodiment, the electronic device of the present application may include at least one processor and a memory communicatively connected to the at least one processor, wherein the memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor may execute the steps of the transaction processing method in any blockchain provided in the embodiments of the present application.

[0225] In an exemplary embodiment, a computer program product is also provided. When the computer program product is executed by an electronic device, the electronic device can implement any exemplary method provided in the present application.

[0226] Furthermore, the computer program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a RAM, a ROM, an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a compact disk read only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0227] The program product for transaction processing in the blockchain in the embodiment of the present application may adopt a CD-ROM and include program code, and may be run on a computing device. However, the program product of the present application is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.

[0228] The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein the readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0229] The program code contained on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, radio frequency (RF), etc., or any suitable combination of the foregoing.

[0230] Program code for performing the operations of the present application may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device via any type of network such as a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0231] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.

[0232] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0233] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0234] The present application is described with reference to the flowcharts and / or block diagrams of the methods, apparatus (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0235] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0236] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0237] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0238] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application also includes these modifications and variations.

Claims

1. A transaction processing method in a blockchain, characterized in that: include: The consensus node receives a transaction request of an automated market maker AMM transaction, wherein the transaction request includes first information. The transaction request is sent by the requesting end after obtaining the target transaction information required for the AMM transaction and starting to use the anti-parallel algorithm to prove the authenticity of the transaction. The first information includes part of the target transaction information. receiving supplementary transaction information of the transaction request sent by the requesting end, the supplementary transaction information comprising second information, verification auxiliary information, and the latest authenticity proof information obtained by using an anti-parallel algorithm, the second information comprising information in the target transaction information except the first information, and the supplementary transaction information is sent by the requesting end after a preset condition is met; Performing transaction authenticity verification based on the authenticity certification information and the verification auxiliary information; Based on the authenticity verification result, respond to the transaction request.

2. The method according to claim 1, characterized in that The second information includes the transaction initiation time and the exchanged object identifier.

3. The method according to claim 1, characterized in that The authenticity proof information includes the latest target value, and based on the authenticity proof information and the verification auxiliary information, the transaction authenticity verification is performed, including: Based on the target value and the verification auxiliary information, verify whether the anti-parallel computing amount of the requesting end matches the target duration, the starting time of the target duration is the transaction initiation time corresponding to the transaction request, and the ending time of the target duration is the time when the supplementary transaction information is received; Based on the verification result, determine whether the AMM transaction corresponding to the transaction request is a real transaction.

4. The method according to claim 3, characterized in that The authenticity proof information also includes the total number of iterative calculations, and before verifying whether the anti-parallel calculation amount of the requesting end matches the target duration based on the target value and the verification auxiliary information, it also includes: Determining a calculation frequency of the requesting end based on the target duration and the total number of times; It is determined that the calculation frequency of the request end is greater than the calculation frequency of the single-core processor.

5. The method according to claim 3 or 4, characterized in that The first information further includes a hash value of the target transaction information and two prime numbers, the verification auxiliary information includes a target prime number and an intermediate value, and based on the target value and the verification auxiliary information, verifying whether the anti-parallel computing amount of the requesting end matches the target duration includes: Determine an initial value according to the hash value of the target transaction information and N, where N is the product of the two prime numbers; Substituting the initial value, the target prime number and the intermediate value into a verification algorithm to obtain a verification value; If the verification value is equal to the target value, it is determined that the anti-parallel calculation amount of the request end matches the target duration.

6. The method according to claim 5, characterized in that According to the hash value of the target transaction information and N, an initial value is determined, including: Determine the value of the hash value modulo N; If the value is not included in the set G, the hash value is increased according to the set amplitude, and the step of determining the value of the hash value modulo N is executed until the value is included in the set G, and the value is used as the initial value. The set G is used to store integers that are coprime with N.

7. The method according to any one of claims 1 to 4, characterized in that: The first information further includes exchange object description information, the second information further includes exchange object identification, and further includes: After receiving the transaction request, according to the exchange object description information, a corresponding amount of the exchange object is transferred out from the external user account corresponding to the requesting end; Based on the authenticity verification result, responding to the transaction request includes: After determining that it is a real transaction, according to the exchanged object identifier and AMM rules, a corresponding number of exchanged objects matching the transferred exchange objects are transferred to the external user account.

8. A transaction processing method in a blockchain, characterized in that: include: After the requester obtains the target transaction information required for the AMM transaction, it begins to use the anti-parallel algorithm to prove the authenticity of the transaction; Sending a transaction request to a consensus node, wherein the transaction request includes first information, and the first information includes part of the target transaction information; After the preset conditions are met, supplementary transaction information of the transaction request is sent to the consensus node, wherein the supplementary transaction information includes second information, verification auxiliary information and the latest authenticity proof information obtained using an anti-parallel algorithm, so as to trigger the consensus node to perform transaction authenticity verification based on the verification auxiliary information and the authenticity proof information, and respond to the transaction request based on the authenticity verification result, wherein the second information includes information in the target transaction information except the first information, and the verification auxiliary information is generated by a verification auxiliary algorithm.

9. The method according to claim 8, characterized in that Follow the steps below to prove the authenticity of the transaction: Determine an initial value according to the hash value of the target transaction information and N, where N is the product of two randomly generated prime numbers, both of which are greater than a preset value; Using the initial value as an input parameter of the anti-parallel algorithm for iterative calculation, wherein the target value after taking the modulo N of the result of each iterative calculation is used as the input value of the next iterative calculation; and The first information also includes a hash value of the target transaction information and the two prime numbers, and the authenticity proof information includes the latest target value.

10. The method according to claim 9, characterized in that The authenticity proof information also includes the total number of iterative calculations.

11. The method according to claim 9 or 10, characterized in that The verification auxiliary information comprises a target prime number and an intermediate value, wherein the target prime number is selected from the set G, and the target prime number is not less than at least one of the two prime numbers, and the intermediate value is obtained by substituting the target prime number into a verification auxiliary algorithm.

12. The method according to claim 9, characterized in that According to the hash value of the target transaction information and N, an initial value is determined, including: Determine the value of the hash value modulo N; If the value is not included in the set G, the hash value is increased according to the set amplitude, and the step of determining the value of the hash value modulo N is executed until the value is included in the set G, and the value is used as the initial value. The set G is used to store integers that are coprime with N.

13. The method according to claim 8, characterized in that Also includes: If it is determined that the AMM transaction corresponding to the transaction request is successfully executed, the transaction authenticity proof will be stopped.

14. The method according to claim 8, characterized in that Also includes: If it is determined that the AMM transaction corresponding to the transaction request has failed, the step of sending a transaction request to the consensus node is executed until the transaction cancellation condition is met, and then the AMM transaction cancellation request is sent to the consensus node.

15. A transaction processing device in a blockchain, characterized in that: include: A first receiving module is used to receive a transaction request of an automated market maker AMM transaction, wherein the transaction request includes first information, and the transaction request is sent after the requesting end obtains the target transaction information required for the AMM transaction and starts to use the anti-parallel algorithm to prove the authenticity of the transaction, and the first information includes part of the target transaction information; a second receiving module, configured to receive supplementary transaction information of the transaction request sent by the requesting end, wherein the supplementary transaction information includes second information, verification auxiliary information, and the latest authenticity proof information obtained by using an anti-parallel algorithm, wherein the second information includes information in the target transaction information other than the first information, and the supplementary transaction information is sent by the requesting end after a preset condition is met; A verification module, used to verify the authenticity of the transaction based on the authenticity proof information and the verification auxiliary information; The response module is used to respond to the transaction request based on the authenticity verification result.

16. A transaction processing device in a blockchain, characterized in that: include: The proof module is used to obtain the target transaction information required for the automated market maker AMM transaction, and then use the anti-parallel algorithm to prove the authenticity of the transaction; A first sending module, configured to send a transaction request to a consensus node, wherein the transaction request includes first information, and the first information includes part of the target transaction information; The second sending module is used to send supplementary transaction information of the transaction request to the consensus node after the preset conditions are met, and the supplementary transaction information includes second information, verification auxiliary information and the latest authenticity proof information obtained by using the anti-parallel algorithm, so as to trigger the consensus node to perform transaction authenticity verification based on the verification auxiliary information and the authenticity proof information, and respond to the transaction request based on the authenticity verification result, the second information includes information in the target transaction information except the first information, and the verification auxiliary information is generated by a verification auxiliary algorithm.

17. An electronic device, characterized in that: include: at least one processor, and a memory communicatively connected to the at least one processor, wherein: The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the method according to any one of claims 1 to 14.

18. A storage medium, characterized in that: When the computer program in the storage medium is executed by a processor of an electronic device, the electronic device can execute the method according to any one of claims 1 to 14.

19. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 14 when executed by a processor.

Citation Information

Cited By

  • Real-time quantitative risk transaction method and device, computer equipment and storage medium

    CN121352804A