Transaction method and device based on numerical encryption, server and product
By using native smart contracts to perform preset arithmetic operations on the numerical values in blockchain transactions and generating encrypted numerical values, the problem of privacy protection of numerical information on data transactions on blockchain is solved, and efficient privacy protection and resource conservation are achieved.
Patent Information
- Application Number
- CN202411948312.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-05-23
AI Technical Summary
When conducting data transactions on blockchain, how to better protect numerical information from privacy to prevent information from being tampered with or leaked.
By presetting arithmetic operations on the values using native smart contracts in the server, encrypted values are generated, and these encrypted values are used for verification and decryption during the transaction process, ensuring the privacy of transaction information.
It realizes effective encryption of numerical information in transaction information, protects the privacy of both parties to the transaction, and reduces the consumption of smart contract resources required for server encryption.
Smart Images

Figure CN120030585A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of blockchain technology, and in particular, relates to a transaction method, device, server and product based on numerical encryption. Background Art
[0002] Since blockchain has many characteristics such as immutability, traceability, and smart contracts, using blockchain to build a data trading system can meet the needs of credibility, intelligence, fairness, and other aspects of data transactions.
[0003] As an emerging technology, blockchain requires necessary privacy protection to ensure the privacy of the numerical information (e.g., transaction amount, rebate ratio, etc.) between the two parties when conducting transactions on the blockchain.
[0004] However, privacy has always been an important topic in the blockchain field. How to better protect the privacy of numerical information of data transactions in the blockchain has been an issue that has been continuously explored. Summary of the invention
[0005] The embodiments of the present application provide a transaction method, device, server and product based on numerical encryption, which can better protect the privacy of numerical information in data transactions.
[0006] In a first aspect, an embodiment of the present application provides a transaction method based on numerical encryption, which is applied to a server, wherein the server includes a native smart contract that performs a preset arithmetic operation on a numerical value, and the method includes:
[0007] The transaction information of the initiator of the transaction is published; the first encrypted value in the transaction information is the value obtained by performing a preset arithmetic operation on the first original value based on the native smart contract;
[0008] Obtaining target bidding information sent by the bidder of the transaction based on the transaction information; the target bidding information at least includes a second encrypted value determined by the first encrypted value;
[0009] Verify the second encrypted value based on the first original value to obtain a transaction verification result;
[0010] When the transaction verification result is verification passed, the transaction is completed based on the target auction information.
[0011] In one embodiment, before publishing the transaction information of the initiator of the transaction, the method further includes:
[0012] Based on the native smart contract and the first original value, determine the first value and the first algorithm value; the first original value is obtained by performing a preset arithmetic operation on the first value and the first algorithm value;
[0013] A first encrypted value is generated based on the first value and the first algorithm value.
[0014] In one embodiment, the native smart contract includes a plurality of; based on the native smart contract and the first original value, determining the first value and the first algorithm value includes:
[0015] Determine a target native smart contract from a plurality of native smart contracts, and determine a first numerical value and a first algorithm value based on the target native smart contract and the first original numerical value;
[0016] Generating a first encrypted value based on the first value and the first algorithm value includes:
[0017] The first numerical value, the first algorithm value, and the identification value corresponding to the target native smart contract are determined as a first encrypted value.
[0018] In one embodiment, generating a first encrypted value based on a first value and a first algorithm value includes:
[0019] Generate random values;
[0020] The first numerical value, the first algorithm value, and the random numerical value are determined as a first encrypted numerical value.
[0021] In one embodiment, obtaining target bidding information sent by a bidder of a transaction based on transaction information includes:
[0022] If bidding information sent by multiple bidders is obtained, the bidding amount in each bidding information is determined;
[0023] The auction information corresponding to the maximum value of the auction amount is determined as the target auction information.
[0024] In one embodiment, verifying the second encrypted value based on the first original value to obtain a transaction verification result includes:
[0025] Decrypting the second encrypted value to obtain a second original value;
[0026] If the first original value is the same as the second original value, the transaction verification result is determined to be verification passed;
[0027] If the first original value is different from the second original value, the transaction verification result is determined to be a verification failure.
[0028] In one embodiment, the native smart contract includes a first smart contract that performs a preset arithmetic operation and a second smart contract that performs a division operation; decrypting the second encrypted value to obtain a second original value includes:
[0029] Performing a division operation on the second encrypted value and the preset value based on the second smart contract to determine a second value and a second algorithm value in the second encrypted value;
[0030] Based on the first smart contract, a preset arithmetic operation is performed on the second numerical value and the second algorithm value to obtain a second original numerical value.
[0031] In a second aspect, an embodiment of the present application provides a transaction device based on numerical encryption, which is applied to a server, wherein the server includes a native smart contract for performing a preset arithmetic operation on a numerical value, and the device includes:
[0032] A publishing module, used to publish the transaction information of the initiator of the transaction; the first encrypted value in the transaction information is a value obtained by performing a preset arithmetic operation on the first original value based on the native smart contract;
[0033] An acquisition module, used to acquire target bidding information sent by a bidder of a transaction based on the transaction information; the target bidding information at least includes a second encrypted value determined by the first encrypted value;
[0034] A verification module, used to verify the second encrypted value based on the first original value to obtain a transaction verification result;
[0035] The transaction module is used to complete the transaction based on the target auction information when the transaction verification result is verification passed.
[0036] In a third aspect, an embodiment of the present application provides a server, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method of the first aspect described above when executing the computer program.
[0037] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method of the first aspect described above is implemented.
[0038] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a server, enables the server to execute the method of the first aspect.
[0039] Compared with the prior art, the beneficial effect of the embodiment of the present application is that after obtaining the transaction information of the initiator of the transaction, the server can first perform a preset arithmetic operation on the first original value in the transaction information based on the native smart contract that can perform a preset arithmetic operation on the value, and obtain the first encrypted value. Then, the transaction information containing the first encrypted value is released to the outside. After that, the server can obtain the target bidding information sent by the bidder of the transaction based on the transaction information, and verify the second encrypted value determined by the first encrypted value in the target bidding information based on the first original value to obtain the transaction verification result. Finally, when the transaction verification result is a verification pass, the transaction is completed based on the target bidding information. Using the above method, the numerical information in the transaction information can be encrypted to ensure the privacy of the transaction between the two parties. In addition, the encryption method is also a method of using the existing original smart contract to perform a preset arithmetic operation on the first original value. It can be understood that the smart contract required to process basic arithmetic operations such as addition, subtraction, multiplication and division is a native smart contract in the server. Therefore, when the above method is used for encryption, not only can the privacy of the transaction be guaranteed, but also encryption can be implemented without writing additional smart contracts in the server, thereby reducing the smart contract resources consumed by the server for encryption. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0041] Figure 1 This is a flowchart of a transaction method based on numerical encryption provided by an embodiment of the present application;
[0042] Figure 2 This is a schematic diagram of an implementation method for generating a first encrypted value in a transaction method based on numerical encryption provided in an embodiment of the present application;
[0043] Figure 3 This is a schematic diagram of an application scenario for conducting transactions in a transaction method based on numerical encryption provided in an embodiment of the present application;
[0044] Figure 4 This is a schematic diagram of an application scenario for conducting transactions in a transaction method based on numerical encryption provided by another embodiment of the present application;
[0045] Figure 5 It is a structural schematic diagram of a transaction device based on numerical encryption provided by an embodiment of the present application;
[0046] Figure 6 It is a structural diagram of a server provided in one embodiment of the present application. DETAILED DESCRIPTION
[0047] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0048] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0049] It should be noted that the information collection process (such as face image collection process, fingerprint information collection process, etc.) / feature extraction process involved in this application is performed with the user's knowledge and permission, that is, the information collection process / feature extraction process complies with the requirements of laws and regulations and does not constitute an act that harms the public interest.
[0050] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0051] Since blockchain has many characteristics such as immutability, traceability, and smart contracts, using blockchain to build a data trading system can meet the needs of credibility, intelligence, fairness, and other aspects of data transactions.
[0052] As an emerging technology, blockchain requires necessary privacy protection to ensure the privacy of the numerical information (e.g., transaction amount, rebate ratio, etc.) between the two parties when conducting transactions on the blockchain.
[0053] However, privacy has always been an important topic in the blockchain field, and how to better protect the privacy of numerical information in the blockchain has been a problem that has been continuously explored.
[0054] As an example, the existing encryption method is usually to deploy a smart contract based on string input parameters on the blockchain server to perform string encryption and decryption operations on numerical information.
[0055] However, string-based encryption and decryption operations are usually more complicated, and the smart contract corresponding to the operation is not a native smart contract in the server. For example, when performing encryption and decryption operations, it is usually necessary to perform operations such as traversing strings, comparing characters, and finding substrings.
[0056] Therefore, when using the above method to perform encryption and decryption operations, it is necessary to write additional smart contract implementations, so that string-based encryption and decryption operations usually require more computing resources. In other words, more smart contract Gas is consumed. Gas is a unit of measurement used to measure the amount of computing required to perform a specific operation on the Ethereum network.
[0057] Based on this, in order to reduce the smart contract resources consumed by the server during encryption while ensuring the privacy of the transaction, an embodiment of the present application provides a transaction method based on numerical encryption, which can be applied to the server.
[0058] In one embodiment, in the field of blockchain, an Ethereum Virtual Machine (EVM) is usually running in the server. Among them, the user can download the Ethereum client on the computer device to realize the operation result of the smart contract through the virtual operating system corresponding to the Ethereum virtual machine. For example, the Ethereum client is logged in based on the computer device, and the smart contract is called to complete the transaction. Based on this, the Ethereum virtual machine can be considered as the operating environment of the smart contract.
[0059] Usually, for digital operations, some native operation codes (opcodes) are provided in the EVM to support arithmetic operations. Therefore, it can be considered that the EVM is more efficient when performing arithmetic operations, and no additional interpretation or conversion steps are required. For example, the EVM usually has a special opcode to handle basic arithmetic operations such as addition, subtraction, multiplication and division.
[0060] Based on the above description, it can be considered that the native smart contract is the smart contract corresponding to the execution of basic arithmetic operations such as addition, subtraction, multiplication and division.
[0061] See also Figure 1 , Figure 1 The following is a flowchart of a transaction method based on numerical encryption provided by an embodiment of the present application. The method includes the following steps:
[0062] S101. Publish the transaction information of the initiator of the transaction; the first encrypted value in the transaction information is a value obtained by performing a preset arithmetic operation on the first original value based on the native smart contract.
[0063] In one embodiment, the above transaction is a transaction uploaded by the initiator after logging into the Ethereum client on the computer device. After receiving the transaction, the server can publish it to the outside so that other users can selectively complete the transaction. For example, other users can also log in to the Ethereum client on their respective computer devices to query multiple transaction information published by the server.
[0064] In one embodiment, the transaction information includes but is not limited to the transaction object, transaction amount, rebate ratio, signature information of the initiator, address information, etc., and is not limited to this.
[0066] The above transaction volume can be considered as the number of transaction objects that the initiator needs to trade. When the transaction object is digital currency, the above transaction volume can be considered as the transaction amount that needs to be traded.
[0067] The above rebate ratio is the ratio of the rebate amount to the sales amount. For example, after the transaction is completed, the ratio of the amount received by the initiator in the transaction to the auction amount paid by the bidder is the above rebate amount. The rebate amount can be a fixed value pre-set in the server or a value entered by the initiator, and there is no limitation on this.
[0068] The above-mentioned signature information is an identification in the transaction information to confirm the identity of the initiator and indicate that the initiator approves the transaction information.
[0069] The above-mentioned address information usually refers to the place or address designated by both parties when conducting a transaction, which can be a physical address or a virtual address, and there is no limitation on this. In e-commerce, the address information is related to the distribution and delivery of the transaction object.
[0070] In one embodiment, after receiving the transaction information, the server may publish the transaction information. However, it should be noted that transaction information usually includes a large amount of sensitive information. If the sensitive information is improperly used, accessed or modified without authorization, it may be detrimental to the privacy rights enjoyed by individuals according to law and cause losses to the initiator.
[0071] Based on this, when publishing transaction information, the server should also delete sensitive information in the transaction information before publishing it. That is, the information that can be viewed by the bidder is usually the transaction information authorized by the initiator.
[0072] Exemplarily, the above-mentioned sensitive information includes but is not limited to the signature information, financial account information, etc. of the initiator, which is not limited to this.
[0073] In one embodiment, based on the above explanation of the native smart contract, when encrypting the first original value in the transaction information, the server can call a native smart contract corresponding to basic arithmetic operations such as addition, subtraction, multiplication and division, and convert it into corresponding instructions to perform a preset arithmetic operation on the first original value to obtain a first encrypted value.
[0074] As an example, the server may Figure 2 The steps S201-S202 shown generate a first encrypted value. The details are as follows:
[0075] S201. Determine a first numerical value and a first algorithm value based on the native smart contract and the first original numerical value.
[0076] The first original value is obtained by performing a preset arithmetic operation on the first value and the first algorithm value.
[0077] In one embodiment, the preset arithmetic may be any one of the preset addition, subtraction, multiplication and division, without limitation. Based on this, the native smart contract may be considered as a smart contract that executes addition, subtraction, multiplication and division.
[0078] The server may first randomly generate a first algorithm value and determine a corresponding preset arithmetic, and then determine a corresponding first value based on the first original value, the first algorithm value and the preset arithmetic.
[0079] Alternatively, the server may first randomly generate a first value and determine a corresponding preset arithmetic, and then determine a corresponding first algorithm value based on the first original value, the first value and the preset arithmetic.
[0080] For example, the default arithmetic is subtraction, and the native smart contract is a smart contract that performs subtraction operations. When the first original value is 90, the server can randomly generate a first value (for example, 98). At this time, it can be considered that the first value 98 needs to be subtracted by 8 to obtain the first original value 90. That is, 90=98-8. Based on this, it can be considered that the first algorithm value is 8.
[0081] Alternatively, for example, the default arithmetic is addition, and the native smart contract is a smart contract that performs addition operations. When the first original value is 90, the server can randomly generate a first value of 87. At this time, it can be considered that the first original value 90 can only be obtained by adding 3 to the first value 87. That is, 90=87+3. Based on this, it can be considered that the first algorithm value is 3.
[0082] It is understandable that when the preset arithmetic operation corresponding to the native smart contract set in the server is fixed, the first value and the first algorithm value determined based on the first original value may include multiple situations, which are not described one by one. It is understandable that each situation can be used to generate the first encrypted value.
[0083] Based on this, it can be considered that after the first original value is encrypted in the above manner, a variety of different first encrypted values can be generated.
[0084] In this embodiment, the method for determining the first value and the first algorithm value is not limited. It should be added that when the preset arithmetic is addition, the randomly generated first value will be smaller than the first original value, and when the preset arithmetic is subtraction, the randomly generated first value will be larger than the first original value.
[0085] The above examples are only examples when the preset arithmetic is addition or subtraction. It is understandable that when the preset arithmetic is multiplication or division, the method of determining the first value and the first algorithm value can also refer to the above examples, which will not be explained again.
[0086] S202: Generate a first encrypted value based on the first value and the first algorithm value.
[0087] In one embodiment, after obtaining the first numerical value and the first algorithm value, the server may determine the first numerical value and the first algorithm value as the first encrypted numerical value.
[0088] Exemplarily, when the first value is 98 and the first algorithm value is 8, the first encrypted value may be 988. It is understandable that the first encrypted value is different from the first original value, and the encrypted first encrypted value may protect the privacy of the first original value.
[0089] In one embodiment, based on the above example description, it can be known that although the first encrypted value can be generated based on the first value and the first algorithm value, this method is usually only applicable to a smart contract that predetermines a preset arithmetic operation.
[0090] For example, the preset arithmetic operation is subtraction. When the first numerical value is 98 and the first algorithm value is 8, the server can directly obtain the first original numerical value of 90 based on the subtraction operation.
[0091] It can be understood that, due to the singularity of the preset arithmetic operation, when the server obtains the first encrypted value based on the single preset arithmetic operation, it is less difficult to decipher.
[0092] However, if the server is pre-set with multiple native smart contracts that perform preset arithmetic operations, when the attacker receives the first encrypted value, he will not be able to determine what preset arithmetic operation the first value and the first algorithm value in the first encrypted value are through to obtain the first original value. That is, based on the native smart contracts corresponding to multiple preset arithmetic operations, the attacker cannot accurately obtain the first original value through operation. In turn, the difficulty of deciphering the first encrypted value can be increased.
[0093] Based on this, in order to increase the difficulty of deciphering the first encrypted value, multiple native smart contracts can be set in the server to encrypt the first original value to obtain the first encrypted value.
[0094] Exemplarily, the server may first determine a target native smart contract from a plurality of native smart contracts. Then, based on the target native smart contract and the first original value, determine a first numerical value and a first algorithm value. Finally, the first numerical value, the first algorithm value, and the identification value corresponding to the target native smart contract are determined as the first encrypted numerical value.
[0095] Among them, the method of determining the first numerical value and the first algorithm value based on the target native smart contract and the first original numerical value can refer to the example description in the above S201, and no further explanation is given.
[0096] In one embodiment, a method of determining a target native smart contract from a plurality of native smart contracts includes, but is not limited to, random determination and determination according to a preset order, and is not limited to this.
[0097] The determination according to the preset order may be to pre-set the order in which multiple native smart contracts are used for encryption. Then, the server may determine the target native smart contract to be encrypted this time based on the native smart contract used for encryption last time and the preset order. In this embodiment, the preset order corresponding to the multiple native smart contracts is not limited.
[0098] In one embodiment, after determining the target native smart contract, in order to enable the server to subsequently decrypt the first encrypted value to obtain the first original value, the server may write the identification value corresponding to the target native smart contract into the first encrypted value during the encryption process.
[0099] The identification value includes but is not limited to letters, numbers, etc., and there is no limitation on this. In order to facilitate the server to identify, the above identification value can be a number. For example, the identification value of the native smart contract corresponding to the addition operation can be 1, the identification value of the native smart contract corresponding to the subtraction operation can be 2, the identification value of the native smart contract corresponding to the multiplication operation can be 3, and the identification value of the native smart contract corresponding to the division operation can be 4, and there is no limitation on this.
[0100] For example, taking the preset arithmetic operation corresponding to the target original smart contract as subtraction, when the first numerical value is 98 and the first algorithm value is 8, the generated first encrypted value may be 9828. 2 indicates that the preset arithmetic operation corresponding to the target original smart contract is subtraction. Therefore, after obtaining the first numerical value 98 and the first algorithm value 8, the server can directly obtain the first original numerical value of 90 based on the subtraction operation.
[0101] Alternatively, taking the preset arithmetic operation corresponding to the target original smart contract as multiplication as an example, when the first numerical value is 30 and the first algorithm value is 3, the generated first encrypted value may be 3033. 3 indicates that the preset arithmetic operation corresponding to the target original smart contract is multiplication. Therefore, after obtaining the first numerical value 30 and the first algorithm value 3, the server can directly obtain the first original numerical value of 90 based on the multiplication operation.
[0102] Alternatively, taking the preset arithmetic operation corresponding to the target original smart contract as division as an example, when the first numerical value is 180 and the first algorithm value is 2, the generated first encrypted value may be 18042. Among them, 4 indicates that the preset arithmetic operation corresponding to the target original smart contract is division. Therefore, after obtaining the first numerical value 180 and the first algorithm value 2, the server can directly obtain the first original numerical value of 90 based on the division operation.
[0103] In another embodiment, in order to further increase the difficulty of deciphering the first encrypted value, the server may also generate a random value, and then determine the first value, the first algorithm value and the random value as the first encrypted value.
[0104] The number of random values may be one or more, and there is no limitation on this. It should be noted that after the first encrypted value is generated based on the random value, the difficulty of determining the first value and the first algorithm value from the first encrypted value can be confused.
[0105] It can be understood that when there are multiple native smart contracts, the components of the first encrypted value will simultaneously include the first value, the first algorithm value, the identification value, and the random value.
[0106] It should be noted that, in the first encrypted value, the arrangement order between the first value, the first algorithm value, the identification value and the random value can be set in advance, so that when the server performs subsequent decryption, it can determine the first value, the first algorithm value and the identification value from the first encrypted value based on the arrangement order.
[0107] S102: Obtain target bidding information sent by the bidder of the transaction based on the transaction information; the target bidding information at least includes a second encrypted value determined by the first encrypted value.
[0108] In one embodiment, the bidder is the object that hopes to complete the transaction with the initiator. After obtaining the transaction information, the user can determine whether to complete the transaction information with the initiator. And when it is determined that the transaction information with the initiator is completed, the bidding information can be sent to the server. At this time, the user participating in the auction is the bidder.
[0109] As an example, after receiving the transaction information, the user can perform arbitrage analysis based on the preset analysis function in the server based on his own computer device. Then, after finding an arbitrage opportunity, the computer device can respond to the user's bidding operation, call the corresponding smart contract from the server to bid, and build a transaction bundle (i.e., the above-mentioned bidding information). Then, the computer device can send the transaction bundle to the server.
[0110] The above-mentioned bidding information includes but is not limited to the bidding amount, the second encrypted value, the address information of the initiator and the address information of the bidder, and is not limited to this.
[0111] It should be noted that the second encrypted value is the first encrypted value that the bidder can obtain from the transaction information. That is, in a normal transaction scenario, the second encrypted value is the same as the first encrypted value. However, if an attack occurs during the transaction, such as a MEV (Maximal Extractable Value) attack, the second encrypted value determined by the first encrypted value may be different from the first encrypted value. As a result, the first encrypted value corresponds to the first original value, which is different from the second original value corresponding to the second encrypted value.
[0112] In actual scenarios, transaction information may contain a large amount of numerical information. Therefore, the computer device corresponding to the bidder needs to determine the first encrypted value and the address information of the initiator from the transaction information, and then construct the target bidding information.
[0113] As an example, a protocol for information interaction between the server and the computer device may be pre-set, and the information transmission process, the first encrypted value, the address information of the initiator, and the address of other information in the message may be regulated in the protocol.
[0114] Exemplarily, for the multiple information included in the message, the server may determine the value in the "refundCfg" field in the message as the first encrypted value, and determine the address in the "refundAddres" field as the address information of the initiator.
[0115] As an example, the bidder can call the function corresponding to the smart contract according to the following interface to construct the target bidding information. Details are as follows:
[0116] interface IProxyBid{
[0117] function proxyBid(address refundAddress,uint256 refundCfg)externalpayable;
[0118] }
[0119] The refundAddress field contains the address information configured by the initiator, which the bidder can obtain from the transaction information. The refundCfg field contains the encrypted first encrypted value. When the bidder calls the smart contract to construct the target bidding information, the first encrypted value and the initiator's address information must be written into the bidding information, and the bidding amount must be set in the msg.value field to complete the construction of the target bidding information. Finally, the target bidding information is sent to the server.
[0120] In another embodiment, after obtaining the bidding information sent by the bidder, the server may also use the native smart contract to encrypt the value in the bidding information. For example, the bidding amount is encrypted. Since the first encrypted value itself is an encrypted value, the server does not need to encrypt the first encrypted value again.
[0121] It should be noted that when there is only one bidder, the bidding information corresponding to the bidder is the target bidding information; when there are multiple bidders, the server needs to determine a target bidder from the multiple bidders to complete the transaction with the initiator. In this case, the bidding information corresponding to the target bidder is the target bidding information.
[0122] As an example, if bidding information sent by multiple bidders is obtained, the server can determine the bidding amount in each bidding information, and then determine the bidding information corresponding to the maximum bidding amount as the target bidding information.
[0123] It is understandable that the above-mentioned rebate ratio is the ratio of the amount that the initiator can receive in the transaction to the bid amount paid by the bidder. When the rebate ratio is constant, the larger the bid amount, the larger the amount that the initiator will receive in the transaction, which can increase the transaction profit of the initiator.
[0124] S103. Verify the second encrypted value based on the first original value to obtain a transaction verification result.
[0125] In one embodiment, the transaction verification result is divided into two results: verification passed and verification failed. Based on the explanation in S102 above, if the transaction is normal, the first encrypted value should be the same as the second encrypted value.
[0126] Based on this, as an example, the server may determine that the transaction verification result is a passed verification when the first encrypted value is the same as the second encrypted value, and determine that the transaction verification result is a failed verification when the first encrypted value is different from the second encrypted value.
[0127] However, it should be noted that, as described in S201 above, after encrypting the first original value, multiple different first encrypted values can be generated. Therefore, even if the second encrypted value obtained by the server is different from the first encrypted value, there may be a scenario where the second original value in the second encrypted value is the same as the first original value in the first encrypted value.
[0128] Based on this, in order to improve the accuracy of the transaction verification result, in this embodiment, the second encrypted value can be verified based on the first original value. It can be understood that when the transaction is normal, the second original value after decrypting the second encrypted value should be the same as the first original value.
[0129] Based on the above description, the server can decrypt the second encrypted value to obtain the second original value. Then, when the first original value is the same as the second original value, it is determined that no attack has occurred during the transaction, and the transaction verification result can be determined to be a successful verification. Otherwise, when the first original value is different from the second original value, it is determined that an attack has occurred during the transaction. Furthermore, in order to ensure that the initiator's income is not lost, the transaction verification result can be determined to be a failed verification.
[0130] As an example, in order to enable the server to still perform decryption based on the native smart contract during the decryption process without the need for an additional smart contract, the server can divide the second encrypted value by the preset value based on the second smart contract to determine the second value and the second algorithm value in the second encrypted value. Then, based on the first smart contract, a preset arithmetic operation is performed on the second value and the second algorithm value to obtain the second original encrypted value.
[0131] In one embodiment, the first smart contract is a native smart contract that performs a preset arithmetic operation, which may be only one of addition, subtraction, division, and multiplication, or may be multiple, without limitation. And the second smart contract is a native smart contract that performs a division operation.
[0132] The division operation is a mathematical operation used to find the integer and remainder after dividing two values. In this embodiment, the number of division operations and the corresponding divisor (i.e., the preset value) each time the division operation is performed can be set according to actual conditions and are not limited thereto.
[0133] Exemplarily, when the first encrypted value is composed of a random value, a first value, an identification value, and a first algorithm value in sequence, and the first value and the random value are both two-digit numbers, and the first algorithm value and the identification value are both one-digit numbers, the corresponding second encrypted value is also composed of 6 digits. At this time, the process of decrypting the second encrypted value can be: when the second smart contract is called for the first time to perform a division operation, the divisor can be 10000 first. Among them, since the random value is located in the first two digits, the remainder obtained by the first division operation will only consist of the first value, the identification value, and the first algorithm value, and the integer part will be the random value. Then, since the first value is a two-digit number, when the second smart contract is called to perform a second division operation on the remainder, the divisor can be 100. At this time, after the division operation, the remainder part will consist of the identification value and the second algorithm value, and the integer part will be the second value. Afterwards, the second smart contract can be called to perform a third division operation on the remainder part again, and the divisor can be 10. At this time, after the division operation, the remainder part will only be the second algorithm value, and the integer part will be the identification value.
[0134] Based on this, after the above multiple division operations, the second numerical value, the identification value and the second algorithm value will be obtained in turn. Finally, based on the first smart contract corresponding to the identification value, the second numerical value and the second algorithm value can be subjected to a preset arithmetic operation to obtain the second original numerical value.
[0135] Specifically, taking the second encrypted value 819828 as an example, when performing the first division operation, the divisor is 10000. Therefore, the remainder obtained by the first division operation will be 9828, and the integer part will be 81 (random value). Then, a second division operation is performed on 9828, and the divisor is 100, and the remainder part obtained will be 28, and the integer part will be 98 (second value). Finally, a third division operation is performed on 28 again, and the divisor can be 10. At this time, after the division operation, the remainder part is 8 (second algorithm value), and the integer part will be 2 (identification value). Among them, since the remainder arithmetic operation of the first smart contract corresponding to the identification value 2 is a subtraction operation, the second value 98 minus the second algorithm value 8, the second original value, is 90.
[0136] Based on the above example, it can be understood that when the server has only one first smart contract corresponding to a preset arithmetic operation, it can be considered that the first encrypted value may not contain an identification value for identifying the preset arithmetic operation. In this case, the components of the first encrypted value will change, and then, when performing the decryption process, the server can only determine the second value and the second algorithm value.
[0137] Also, when the number and position of the digits of the random value, the second value, the second algorithm value, and the identification value change, the preset value and the number of times when performing the division operation will change accordingly, which will not be explained in detail. That is, the number of calls to the second smart contract and the preset value corresponding to the division operation during each call can be determined based on the number and position of the digits of the random value, the second value, the second algorithm value, and the identification value in the second encrypted value.
[0138] Among them, since the second encrypted value is obtained based on the first encrypted value. Therefore, it can be considered that the number of calls to the second smart contract and the preset value corresponding to the division operation for each call can also be determined based on the number and position of the random value, the first value, the first algorithm value and the identification value in the first encrypted value. Based on this, it can be considered that when the server obtains the first encrypted value after encrypting the first original value based on the native smart contract, it can determine the number of calls to the second smart contract during the decryption process and the preset value corresponding to the division operation for each call.
[0139] It is understandable that when the number and position of the random value, the first value, the first algorithm value and the identification value are fixed, the number of calls to the second smart contract and the preset value corresponding to the division operation performed each time the contract is called can also be pre-set. Please refer to the above example of decrypting 819828 for details.
[0140] In another embodiment, after obtaining the second encrypted value, the server can also query the second value, the identification value and the second algorithm value directly from the second encrypted value based on the predefined arrangement of the random value, the second value, the second algorithm value and the identification value (predefine the position and number of digits between each value). However, this method requires additional deployment of a smart contract for string parsing in the server.
[0141] For example, if it is necessary to directly determine the second value 98, the identification value 2, and the second algorithm value 8 from the second encrypted value 819828, the server needs to call the smart contract corresponding to the traversal string to determine the position of each value in the second encrypted value. Then, the smart contract corresponding to the search string is called to determine the numbers corresponding to the third and fourth digits as the second value, the number corresponding to the fifth digit as the identification value, and the number corresponding to the sixth digit as the second algorithm value.
[0142] However, in this embodiment, both the first smart contract and the second smart contract are native smart contracts that perform basic preset arithmetic operations. Therefore, during the entire encryption and decryption process, the server does not need to consume additional smart contract Gas.
[0143] It should be added that when the first original value is different from the second original value, the server can re-determine the auction information corresponding to the maximum value of the auction amount from the remaining auction information as the target auction information, and execute the above-mentioned S103 step until the transaction verification result is verification passed, or the transaction verification results corresponding to all auction information are verification failed.
[0144] S104: When the transaction verification result is verified as passed, the transaction is completed based on the target auction information.
[0145] In one embodiment, after verification, the server may send the target bidding information to the block builder. The block builder may build a block for transaction to update the account data of the corresponding accounts of the initiator and the bidder based on the target bidding information.
[0146] Exemplarily, the server may calculate the rebate amount of the initiator based on the second original value (rebate ratio) in the target bidding information, and construct a rebate transaction to send the rebate amount to the address information corresponding to the initiator (eg, a refund address).
[0147] As a specific example, refer to Figure 3 , Figure 3 This is a schematic diagram of an application scenario for a transaction in a transaction method based on numerical encryption provided by an embodiment of the present application. Figure 3 Transaction Hash indicates the transaction hash, Status indicates the transaction verification result, Block indicates the constructed block, Timestamp indicates the timestamp, $TransactionAction indicates the transaction operation, Sponsored indicates sponsorship, From indicates the address information corresponding to the bidder, and To indicates the corresponding address information of the initiator.
[0148] In this embodiment, after obtaining the transaction information of the initiator of the transaction, the server can first perform a preset arithmetic operation on the first original value in the transaction information based on the native smart contract that can perform a preset arithmetic operation on the value to obtain the first encrypted value. Then, the transaction information containing the first encrypted value is released to the outside. After that, the server can obtain the target bidding information sent by the bidder of the transaction based on the transaction information, and verify the second encrypted value determined by the first encrypted value in the target bidding information based on the first original value to obtain the transaction verification result. Finally, when the transaction verification result is a verification pass, the transaction is completed based on the target bidding information. Using the above method, the numerical information in the transaction information can be encrypted to ensure the privacy of the transaction between the two parties. In addition, the encryption method is also a method of using the existing original smart contract to perform a preset arithmetic operation on the first original value. It can be understood that the smart contract required to process basic arithmetic operations such as addition, subtraction, multiplication and division is a native smart contract in the server. Therefore, when the above method is used for encryption, not only can the privacy of the transaction be guaranteed, but also encryption can be realized without writing an additional smart contract in the server. This reduces the amount of smart contract resources consumed by server encryption.
[0149] In order to more clearly illustrate the scheme in this application, the scheme in this application is described below using specific embodiments. Figure 4 , Figure 4 It is a schematic diagram of an application scenario for conducting transactions in a transaction method based on numerical encryption provided in another embodiment of the present application.
[0150] The initiator can send transaction information to the server based on its own computer device. The server can use the first smart contract in the native smart contract to encrypt the rebate ratio in the transaction information to obtain a first encrypted value. Take the rebate ratio as 90 and the preset arithmetic operation corresponding to the first smart contract as subtraction as an example. The server can generate a first encrypted value corresponding to 819828. Among them, 81 is a random value, 98 is a first value, 2 is an identification value, and 8 is a first algorithm value. Then, the server can publish the transaction information to the outside.
[0151] Afterwards, when the bidder determines to conduct a transaction with the initiator, it can call the smart contract to bid, generate the target bidding information including the rebate ratio (the second encrypted value) and send it to the server.
[0152] The server can call the second smart contract to perform a division operation on the second encrypted value to obtain the second original value. Specifically, when the server calls the second smart contract to perform the division operation for the first time, the divisor is 10000, and the remainder is 9828. Then, the second smart contract is called to perform a second division operation on 9828, and the divisor is 100. The remainder part will be 28, and the integer part will be 98 (second value). And, the second smart contract is called to perform a third division operation on 28 again, and the divisor can be 10. The remainder part will be 8 (second algorithm value), and the integer part will be 2 (identification value). Finally, the server can call the first smart contract (the native smart contract corresponding to the identification value 2) and subtract the second algorithm value 8 from the second value 98 to obtain the value obtained as the second original value 90.
[0153] Finally, when it is determined that the first original value is consistent with the second original value, the target bidding information is sent to the block builder. The block builder can build a block for trading to update the account data of the corresponding accounts of the initiator and the bidder based on the target bidding information.
[0154] See also Figure 5 , Figure 5 1 is a block diagram of a transaction device based on numerical encryption provided in an embodiment of the present application. The transaction device based on numerical encryption in this embodiment includes modules for executing Figures 1 to 4 For details, please refer to the steps in the corresponding embodiment. Figures 1 to 4 as well as Figures 1 to 4 For the convenience of explanation, only the parts related to this embodiment are shown. Figure 5 , a transaction device 500 based on numerical encryption is applied to a server, the server includes a native smart contract that performs a preset arithmetic operation on a numerical value, and the transaction device 500 based on numerical encryption may include: a publishing module 510, an acquisition module 520, a verification module 530 and a transaction module 540, wherein:
[0155] The publishing module 510 is used to publish the transaction information of the initiator of the transaction; the first encrypted value in the transaction information is a value obtained by performing a preset arithmetic operation on the first original value based on the native smart contract.
[0156] The acquisition module 520 is used to acquire target bidding information sent by the bidder of the transaction based on the transaction information; the target bidding information at least includes a second encrypted value determined by the first encrypted value.
[0157] The verification module 530 is used to verify the second encrypted value based on the first original value to obtain a transaction verification result.
[0158] The transaction module 540 is used to complete the transaction based on the target bidding information when the transaction verification result is verification passed.
[0159] In one embodiment, the transaction device 500 based on numerical encryption further includes:
[0160] A determination module is used to determine a first numerical value and a first algorithm value based on a native smart contract and a first original numerical value; the first original numerical value is obtained by performing a preset arithmetic operation on the first numerical value and the first algorithm value.
[0161] A generating module is used to generate a first encrypted value based on a first value and a first algorithm value.
[0162] In one embodiment, the native smart contract includes multiple; the first determination module is also used to:
[0163] Determine a target native smart contract from a plurality of native smart contracts, and determine a first numerical value and a first algorithm value based on the target native smart contract and the first original numerical value;
[0164] The build module is also used to:
[0165] The first numerical value, the first algorithm value, and the identification value corresponding to the target native smart contract are determined as a first encrypted value.
[0166] In one embodiment, the generating module is further configured to:
[0167] Generate a random value; determine the first value, the first algorithm value and the random value as a first encrypted value.
[0168] In one embodiment, the acquisition module 520 is further configured to:
[0169] If bidding information sent by multiple bidders is obtained, the bidding amount in each bidding information is determined; and the bidding information corresponding to the maximum bidding amount is determined as the target bidding information.
[0170] In one embodiment, the verification module 530 is further configured to:
[0171] The second encrypted value is decrypted to obtain a second original value; if the first original value is the same as the second original value, the transaction verification result is determined to be verification passed; if the first original value is different from the second original value, the transaction verification result is determined to be verification failed.
[0172] In one embodiment, the native smart contract includes a first smart contract that performs a preset arithmetic operation and a second smart contract that performs a division operation; the verification module 530 is further used to:
[0173] Based on the second smart contract, the second encrypted value is divided by the preset value to determine the second value and the second algorithm value in the second encrypted value; based on the first smart contract, a preset arithmetic operation is performed on the second value and the second algorithm value to obtain a second original value.
[0174] When it is understood that Figure 5 In the structural block diagram of the transaction device based on numerical encryption shown in FIG. Figures 1 to 4 The steps in the corresponding embodiments, and for Figures 1 to 4 Each step in the corresponding embodiment has been explained in detail in the above embodiment. Figures 1 to 4 as well as Figures 1 to 4 The relevant descriptions in the corresponding embodiments are not repeated here.
[0175] Figure 6 1 is a structural block diagram of a server provided in an embodiment of the present application. Figure 6 As shown, the server 600 of this embodiment includes: a processor 610, a memory 620, and a computer program 630 stored in the memory 620 and executable on the processor 610, such as a program of a transaction method based on numerical encryption. When the processor 610 executes the computer program 630, the steps in each embodiment of the transaction method based on numerical encryption are implemented, such as Figure 1 Alternatively, the processor 610 implements the above when executing the computer program 630 Figure 5 The functions of each module in the corresponding embodiment are, for example, Figure 5 For details on the functions of each module shown, please refer to Figure 5 Related description in the corresponding embodiment.
[0176] Exemplarily, the computer program 630 may be divided into one or more modules, one or more modules are stored in the memory 620, and are executed by the processor 610 to implement the transaction method based on numerical encryption provided in the embodiment of the present application. One or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 630 in the server 600. For example, the computer program 630 may implement the transaction method based on numerical encryption provided in the embodiment of the present application.
[0177] The server 600 may include, but is not limited to, a processor 610 and a memory 620. Those skilled in the art will appreciate that Figure 6 This is only an example of the server 600 and does not constitute a limitation of the server 600. The server 600 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the server may also include input and output devices, network access devices, buses, etc.
[0178] The processor 610 may be a central processing unit, or other general-purpose processors, digital signal processors, application-specific integrated circuits, off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0179] The memory 620 may be an internal storage unit of the server 600, such as a hard disk or memory of the server 600. The memory 620 may also be an external storage device of the server 600, such as a plug-in hard disk, a smart memory card, a flash memory card, etc. equipped on the server 600. Furthermore, the memory 620 may also include both an internal storage unit of the server 600 and an external storage device.
[0180] An embodiment of the present application provides a computer-readable storage medium, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, a transaction method based on numerical encryption as described in the above-mentioned embodiments is implemented.
[0181] An embodiment of the present application provides a computer program product. When the computer program product runs on a server, the server executes the transaction method based on numerical encryption in the above-mentioned embodiments.
[0182] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A transaction method based on numerical encryption, characterized in that: Applied to a server, the server comprising a native smart contract for performing a preset arithmetic operation on a numerical value, the method comprising: The transaction information of the initiator of the published transaction; the first encrypted value in the transaction information is a value obtained by performing the preset arithmetic operation on the first original value based on the native smart contract; Obtaining target bidding information sent by the bidder of the transaction based on the transaction information; the target bidding information at least includes a second encrypted value determined by the first encrypted value; Verifying the second encrypted value based on the first original value to obtain a transaction verification result; When the transaction verification result is verification passed, the transaction is completed based on the target bidding information.
2. The method according to claim 1, characterized in that Before publishing the transaction information of the initiator of the transaction, it also includes: Based on the native smart contract and the first original value, determine a first value and a first algorithm value; the first original value is obtained by performing the preset arithmetic operation on the first value and the first algorithm value; The first encrypted value is generated based on the first value and the first algorithm value.
3. The method according to claim 2, characterized in that The native smart contract includes a plurality of contracts; and determining a first value and a first algorithm value based on the native smart contract and the first original value includes: Determine a target native smart contract from the plurality of native smart contracts, and determine the first value and the first algorithm value based on the target native smart contract and the first original value; The generating the first encrypted value based on the first value and the first algorithm value includes: The first numerical value, the first algorithm value, and the identification value corresponding to the target native smart contract are determined as the first encrypted value.
4. The method according to claim 2 or 3, characterized in that: The generating the first encrypted value based on the first value and the first algorithm value includes: Generate random values; The first value, the first algorithm value, and the random value are determined as the first encrypted value.
5. The method according to claim 1, characterized in that The acquiring of the target bidding information sent by the bidder of the transaction based on the transaction information includes: If bidding information sent by multiple bidders is obtained, determining the bidding amount in each bidding information; The bidding information corresponding to the maximum value of the bidding amounts is determined as the target bidding information.
6. The method according to any one of claims 1 to 3 or 5, characterized in that: The verifying the second encrypted value based on the first original value to obtain a transaction verification result includes: Decrypting the second encrypted value to obtain a second original value; If the first original value is the same as the second original value, determining that the transaction verification result is the verification passed; If the first original value is different from the second original value, the transaction verification result is determined to be a verification failure.
7. The method according to claim 6, characterized in that The native smart contract includes a first smart contract that performs the preset arithmetic operation and a second smart contract that performs a division operation; the decrypting the second encrypted value to obtain a second original value includes: Performing a division operation on the second encrypted value and a preset value based on the second smart contract to determine a second value and a second algorithm value in the second encrypted value; Based on the first smart contract, the preset arithmetic operation is performed on the second numerical value and the second algorithm value to obtain a second original numerical value.
8. A transaction device based on numerical encryption, characterized in that: Applied to a server, the server comprising a native smart contract for performing a preset arithmetic operation on a numerical value, the device comprising: A publishing module, used to publish transaction information of the initiator of the transaction; the first encrypted value in the transaction information is a value obtained by performing the preset arithmetic operation on the first original value based on the native smart contract; An acquisition module, configured to acquire target bidding information sent by the bidder of the transaction based on the transaction information; the target bidding information at least includes a second encrypted value determined by the first encrypted value; A verification module, configured to verify the second encrypted value based on the first original value to obtain a transaction verification result; The transaction module is used to complete the transaction based on the target bidding information when the transaction verification result is verification passed.
9. A server, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the server implements the method according to any one of claims 1 to 7.
10. A computer program product, characterized in that The invention comprises a computer program, which, when being executed, enables the method according to any one of claims 1 to 7 to be performed.