Data processing method and device, equipment and medium
By using the Merkel tree structure to perform lottery draws, the existing lottery methods are solved, and the problem of opaqueness and inability to verify fairness is achieved, a fair, transparent and credible lottery process is achieved, ensuring users' trust in the results.
Patent Information
- Application Number
- CN202411100196.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-12-10
AI Technical Summary
The existing lottery methods are opaque, unable to intuitively supervise the lottery process, and unable to verify the fairness of the lottery process, resulting in users having doubts about the lottery results.
Random draws are performed using Merkel tree structure, and the results are authentic and immutable by calculating the hash value between each node, and the draw process is reproduced after the draw is completed, demonstrating the verification process to increase transparency and fairness.
A fair and just lottery process is achieved, ensuring users' trust in the lottery results, and demonstrating the transparency of the lottery process through hash value verification, increasing the user experience and credibility of the lottery process.
Smart Images

Figure CN119106080A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data processing method, device, equipment and medium. Background Art
[0002] In daily life, lottery activities are a traditional marketing tool that attracts consumers by providing lottery opportunities and prizes or bonuses after winning. More and more companies are beginning to use lottery activities to attract consumers to participate in order to increase consumer attention.
[0003] There are many different ways to draw a lottery, for example, using a lottery box. Specifically, when using a lottery box, the organizer will write the names of the participants or the corresponding digital identification on a piece of paper, put it in a lottery box, and a designated staff member will draw a piece of paper from it and then display the corresponding winning participant. Furthermore, in some scenarios, lottery software is also used for lottery activities, such as a lottery turntable or offline or online lottery software with a marquee effect.
[0004] It is understandable that the lottery process is not transparent when it comes to manual or online software draws, and ultimately only one lottery result can be shown to the user. The lottery mechanism and execution process cannot be intuitively supervised by users, and the fairness of the lottery process cannot be verified afterwards.
[0005] In view of this, how to provide a lottery method with an intuitive and verifiable lottery process is a problem that needs to be solved urgently. Summary of the invention
[0006] The embodiments of the present application provide a data processing method, apparatus, device and medium for achieving a fair and just lottery, ensuring that the lottery process is clearly visible and the organizer cannot arbitrarily change the lottery result. Moreover, after the lottery is over, the lottery result can be verified and the verification process can be displayed to users who have doubts.
[0007] In a first aspect, an embodiment of the present application provides a data processing method, the method comprising:
[0008] Obtaining identification information of each user; wherein the identification information of each user is different;
[0009] Based on the target hash values corresponding to the respective identification information, a Merkle tree is obtained; wherein the Merkle tree is used to display the target hash values in each layer structure;
[0010] In response to the target user's verification request for the lottery result, based on the target hash value and the Merkle tree corresponding to the target user, the verification result is obtained and the verification process of the lottery result is displayed; wherein the lottery result is obtained based on each initial node and the root node of the Merkle tree;
[0011] If the verification result is the same as the target hash value corresponding to the root node of the Merkle tree, the lottery result is displayed.
[0012] Through the above method, the Merkle tree structure is used for random lottery, and the lottery process cannot be tampered with at will. By calculating the hash value between each node, the result is authentic and reliable. In addition, the Merkle tree structure can be used to reproduce the lottery process and lottery results after the lottery is over, so that the lottery process can be displayed clearly and intuitively, which increases the user experience and ensures the fairness of the lottery process.
[0013] In an optional implementation, obtaining a Merkle tree based on target hash values corresponding to respective pieces of identification information includes:
[0014] Calculate the target hash value corresponding to each piece of identification information respectively;
[0015] Use each target hash value as the initial leaf node of the Merkle tree;
[0016] Based on the initial leaf nodes, the leaf nodes and root nodes of each layer of the Merkle tree are calculated;
[0017] Based on the initial leaf node, the leaf nodes of each layer, and the root node, a Merkle tree is constructed, and all nodes of the Merkle tree are saved.
[0018] Through the above method, each target hash value calculated based on the identification information input by the user can be used to construct a Merkle tree, and the lottery process can be displayed visually and intuitively using the Merkle tree structure.
[0019] In an optional implementation, the lottery result is obtained in the following manner:
[0020] Determine the target hash value sequences corresponding to the root node and each initial leaf node respectively;
[0021] Performing XOR operations on the target hash value sequence corresponding to the root node and the target hash value sequence corresponding to each initial leaf node, respectively, to obtain XOR operation results of the root node and each initial leaf node;
[0022] The lottery result is determined based on the results of each XOR operation.
[0023] Through the above method, the target hash value sequence of the root node and the target hash value sequence of each initial leaf node are XORed, which can effectively select the winning user. By comparing the target hash value sequence of the root node with the target hash value sequence of the initial leaf node, the winning user can be selected, and the data is true and valid.
[0024] In an optional implementation, the lottery result is determined according to each XOR operation result, including:
[0025] Determine the number of target values in the XOR operation results of the root node and each initial leaf node respectively;
[0026] Sort the number of target values and take the initial leaf node with the largest target value as the lottery result.
[0027] Through the above method, the winning user is determined based on the result with the largest number of target values in the XOR operation results.
[0028] In an optional implementation, after respectively determining the number of target values in the XOR operation results of the root node and each initial leaf node, the method further includes:
[0029] If the number of target values in at least two XOR operation results is equal, respectively determining the positions where the target values appear in the hash value sequences corresponding to the at least two XOR operation results;
[0030] The lottery result is determined according to the position where the target value first appears in each of the hash value sequences.
[0031] Through the above method, when the number of target values in each XOR operation result is equal, the winning user is accurately selected according to the position where the target value first appears in the XOR operation result.
[0032] In an optional implementation manner, before obtaining the Merkle tree for the target hash value corresponding to each piece of identification information, the method further includes:
[0033] Determine whether the number of initial leaf nodes is an even number;
[0034] If not, add a node with a hash value of 0 as the initial leaf node.
[0035] Through the above method, when the number of initial leaf nodes is an odd number, by adding an initial leaf node with a hash value of 0, a Merkle tree can be reasonably constructed, avoiding the unfair situation caused by omissions that a certain user cannot participate in the lottery.
[0036] In a second aspect, the present application provides a data processing device, the device comprising:
[0037] An acquisition module, used to acquire identification information of each user; wherein the identification information of each user is different;
[0038] A construction module is used to obtain a Merkle tree based on the target hash values corresponding to each piece of identification information; wherein the Merkle tree is used to display the target hash values in each layer structure;
[0039] A verification module, for responding to a verification request of a target user for a lottery result, obtaining a verification result based on a target hash value and a Merkle tree corresponding to the target user and displaying a verification process of the lottery result; wherein the lottery result is obtained based on each initial node and a root node of the Merkle tree;
[0040] The display module is used to display the lottery result if the verification result is the same as the target hash value corresponding to the root node of the Merkle tree.
[0041] In an optional implementation, when obtaining the Merkle tree based on the target hash values corresponding to the respective identification information, the construction module is specifically used to:
[0042] Calculate the target hash value corresponding to each piece of identification information respectively;
[0043] Using each target hash value as the initial leaf node of the Merkle tree;
[0044] Based on the initial leaf nodes, the leaf nodes and the root nodes of each layer of the Merkle tree are calculated;
[0045] Based on the initial leaf node, the leaf nodes of each layer and the root node, the Merkle tree is constructed, and all nodes of the Merkle tree are saved.
[0046] In an optional implementation, when obtaining the lottery result, a processing module is further included, and the processing module is specifically used to:
[0047] Determine the target hash value sequences corresponding to the root node and each initial leaf node respectively;
[0048] Performing XOR operations on the target hash value sequence corresponding to the root node and the target hash value sequence corresponding to each initial leaf node, respectively, to obtain XOR operation results of the root node and each initial leaf node;
[0049] The lottery result is determined based on the results of each XOR operation.
[0050] In an optional implementation, when determining the lottery result according to each XOR operation result, the processing module is specifically used to:
[0051] Determine the number of target values in the XOR operation results of the root node and each initial leaf node respectively;
[0052] Sort the number of target values and take the initial leaf node with the largest target value as the lottery result.
[0053] In an optional implementation, after respectively determining the number of target values in the XOR operation results of the root node and each initial leaf node, the processing module is further configured to:
[0054] If the number of target values in at least two XOR operation results is equal, respectively determining the positions where the target values appear in the hash value sequences corresponding to the at least two XOR operation results;
[0055] The lottery result is determined according to the position where the target value first appears in each of the hash value sequences.
[0056] In an optional implementation, before obtaining the Merkle tree based on the target hash values corresponding to the respective identification information, the construction module is further used to:
[0057] Determine whether the number of initial leaf nodes is an even number;
[0058] If not, add a node with a hash value of 0 as the initial leaf node.
[0059] In a third aspect, the present application provides an electronic device comprising a processor and a memory, wherein the memory stores program code, and when the program code is executed by the processor, the processor executes the steps of the data processing method described in the first aspect above.
[0060] In a fourth aspect, the present application provides a computer-readable storage medium, which includes a program code. When the program code is run on an electronic device, the program code is used to enable the electronic device to execute the steps of the data processing method described in the first aspect above.
[0061] In a fifth aspect, the present application provides a computer program product, which, when called by a computer, enables the computer to execute the steps of the data processing method as described in the first aspect.
[0062] In addition, other features and advantages of the present application will be described in the subsequent description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. In the drawings:
[0064] Figure 1 A schematic diagram of an implementation flow of a data processing method provided in an embodiment of the present application;
[0065] Figure 2 A schematic diagram of a Merkle tree structure provided in an embodiment of the present application;
[0066] Figure 3 A schematic diagram of a lottery verification process provided in an embodiment of the present application;
[0067] Figure 4 A schematic diagram of the structure of a data processing device provided in an embodiment of the present application;
[0068] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0069] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solution of the present application, rather than all of the embodiments. Based on the embodiments recorded in the application documents, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present application.
[0070] It should be noted that in the description of this application, "multiple" is understood as "at least two". "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent three situations: A exists alone, A and B exist at the same time, and B exists alone. A and B are connected, which can represent two situations: A and B are directly connected and A and B are connected through C. In addition, in the description of this application, words such as "first" and "second" are only used for the purpose of distinguishing descriptions, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.
[0071] In addition, the collection, dissemination, and use of data in the technical solution of this application comply with the requirements of relevant national laws and regulations.
[0072] The following is a brief introduction to the design concept of the embodiment of the present application:
[0073] In daily life, lottery activities are a traditional marketing tool that attracts consumers by providing lottery opportunities and prizes or bonuses after winning. More and more companies are beginning to use lottery activities to attract consumers to participate in order to increase consumer attention.
[0074] There are many different ways to draw a lottery, for example, using a lottery box. Specifically, when using a lottery box, the organizer will write the names of the participants or the corresponding digital identification on a piece of paper, put it in a lottery box, and a designated staff member will draw a piece of paper from it and then display the corresponding winning participant. Furthermore, in some scenarios, lottery software is also used for lottery activities, such as a lottery turntable or offline or online lottery software with a marquee effect.
[0075] It is understandable that the lottery process is not transparent when it is done manually or using online software, and ultimately only one lottery result can be shown to the user. The lottery mechanism and the lottery execution process cannot be supervised intuitively by users, and the fairness of the lottery process cannot be verified afterwards.
[0076] In view of this, in order to achieve a fair and verifiable lottery, the present application provides a data processing method, which includes: first, obtaining identification information of each user; wherein the identification information of each user is different; then, based on the target hash value corresponding to each identification information, a Merkle tree is obtained; wherein the Merkle tree is used to display the target hash value in each layer structure; further, in response to the target user's verification request for the lottery result, based on the target hash value corresponding to the target user and the Merkle tree, a verification result is obtained and the verification process of the lottery result is displayed; finally, if the verification result is the same as the target hash value corresponding to the root node of the Merkle tree, the lottery result is displayed. Through the above method, the identification information of the users participating in the lottery is hashed, and any slight change in the data of any user will affect the final winning result. The lottery is drawn through the Merkle tree structure, and the winning user is determined by selecting the winning hash value. The lottery result is fair and just. Moreover, after the lottery is over, the lottery process can be reversely reproduced. When the user has doubts about the lottery result, the lottery result can be verified according to the target hash value corresponding to the user and the Merkle tree structure, and the verification process can be displayed to the user. If the final verification result is the same as the hash value corresponding to the root node of the Merkle tree, the lottery result is fair and just.
[0077] The data processing method provided by the exemplary embodiment of the present application is described below with reference to the accompanying drawings.
[0078] See also Figure 1 As shown, it is a schematic diagram of an implementation flow of a data processing method provided in an embodiment of the present application. The specific implementation flow of the method is as follows:
[0079] S1: Obtain identification information corresponding to each user.
[0080] In an embodiment of the present application, first, the identification information of each user is obtained. It should be noted that the identification information can be the user ID, user name, or other information that can have a one-to-one correspondence with the user identity. In addition, the user's identification information is information pre-assigned or generated before the lottery starts. For example, before the lottery starts, according to the time sequence of the user's participation in the activity, the user ID assigned to the first user is "1", and the user ID assigned to the second user is "2". For another example, when the user participates in the lottery, the user name defined for himself, for example, the user name of user A is "Little A" and the user name of user B is "Little B". Therefore, the corresponding identification information between each user is different. That is to say, in an embodiment of the present application, the identification information of each user can be characters of any length or data in other formats, and the embodiment of the present application is not specifically limited here.
[0081] S2: Obtain a Merkle tree based on the target hash values corresponding to each piece of identification information.
[0082] In the embodiment of the present application, after obtaining the identification information of each user, it is necessary to perform a hash operation on each identification information.
[0083] Specifically, in the embodiment of the present application, the same hash algorithm is used to perform a hash operation on the identification information input by each user. The hash algorithm is a one-way irreversible hash algorithm that can output data of any length as an output of a fixed length, which is the hash value.
[0084] Therefore, in the embodiment of the present application, a secure hash algorithm (Secure Hash Algorithm 256-bit, SHA256) algorithm may be used to perform hash operations on the identification information corresponding to each user, thereby obtaining a target hash value corresponding to each piece of identification information.
[0085] It should be noted that in the embodiment of the present application, other hash algorithms may be used to perform hash operations on each identification information, such as MD5 Message-Digest Algorithm 5 and Secure Hash Algorithm 1 (SHA1), which are not specifically limited in the embodiment of the present application.
[0086] In the embodiment of the present application, after obtaining the target hash values corresponding to the respective pieces of identification information, a Merkle tree is constructed based on the target hash values corresponding to the respective pieces of identification information.
[0087] Specifically, in an optional implementation, the target hash values corresponding to the respective identification information are first used as the initial leaf nodes of the Merkle tree. Further, based on the target hash values corresponding to the respective initial leaf nodes, the leaf nodes and the root nodes of the next layer of the Merkle tree are calculated; after the leaf nodes and the root nodes of each layer are calculated, the Merkle tree is constructed based on the initial leaf nodes, the leaf nodes of each layer, and the root nodes, and all the nodes of the Merkle tree are saved.
[0088] In an optional implementation, since when constructing the Merkle tree, every two adjacent target hash values are concatenated and then hashed to obtain the leaf nodes of the next layer of the Merkle tree, if the number of target hash values is odd, there will be a target hash value corresponding to the remaining initial leaf node that cannot be used to calculate the next layer of leaf nodes together with the target hash values corresponding to other initial leaf nodes. In other words, the user corresponding to the remaining initial leaf node cannot participate in the lottery.
[0089] Therefore, before constructing the Merkle tree, it is also necessary to determine whether the number of initial leaf nodes is an even number. If the number of initial leaf nodes is odd, it is necessary to add a node with a hash value of 0 as the initial leaf node, so that the number corresponding to the initial leaf node is an even number, which is convenient for calculating the leaf nodes of the next layer.
[0090] When calculating the next layer of leaf nodes of the initial leaf node, the target hash values corresponding to every two adjacent initial leaf nodes are concatenated, and the concatenated hash values are hashed using the same hash algorithm as in step S2. The obtained hash value is used as the next layer of leaf nodes, and the operation is repeated until the final root node is calculated.
[0091] In order to better understand the method of constructing a Merkle tree in the embodiment of the present application, a practical example is given below for illustration:
[0092] For example, see Figure 2 As shown in the figure, there are 4 users participating in the lottery, namely user A, user B, user C and user D. The target hash value 1 corresponding to user A is: 11ac2b35fe68cd43a1894c3a2791a2c3d889435bc549f932a648912ca763b123; the target hash value 2 corresponding to user B is:
[0093] 258641ac34584369405645415bc67160215fe519732de671335941be28d953a1; the target hash value 3 corresponding to user C is:
[0094] a1578614d18540159618548bc2454402987748156bd156948150451549815185; the target hash value 4 corresponding to user D is:
[0095] 157845a15c5648219785415bda15183222154871454815de44f1548215156ad0; In the bottom nodes of the Merkle tree, the initial leaf nodes corresponding to the target hash value 1 and the target hash value 2 are adjacent nodes, and the initial leaf nodes corresponding to the target hash value 3 and the target hash value 4 are adjacent nodes, then the target hash value 1 and the target hash value 2 are spliced, the target hash value 3 and the target hash value 4 are spliced, and then the hash algorithm is used to hash the spliced hash values to obtain the target hash value 5 and the target hash value 6, then the target hash value 5 and the target hash value 6 are respectively used as the leaf nodes of the next layer, and further, the target hash value 5 and the target hash value 6 are spliced, and then the hash algorithm is used to hash the spliced hash values to obtain the target hash value 7, that is, the final root node, and then the Merkle tree is constructed and saved, and all the nodes of the Merkle tree are saved.
[0096] After the Merkle tree is constructed, it can be used to display the target hash value in each layer of the structure.
[0097] In the embodiment of the present application, after the Merkle tree is constructed, the root node and each initial leaf node of the Merkle tree can be obtained, and the initial leaf node corresponds one-to-one to the identification information of each user.
[0098] S3: In response to the target user's verification request for the lottery result, based on the target hash value and Merkle tree corresponding to the target user, obtain the verification result and display the verification process of the lottery result.
[0099] Furthermore, in an embodiment of the present application, when determining the lottery result based on the root node and each initial leaf node of the Merkle tree, the target hash value sequences corresponding to the root node and each initial leaf node are first determined respectively; then, the target hash value sequence corresponding to the root node and the target hash value sequence corresponding to each initial leaf node are XORed respectively to obtain the XOR budget results of the root node and each initial leaf node.
[0100] Specifically, when performing an XOR operation on the target hash value sequence of the root node and the target hash value sequence of each initial leaf node, the target hash values of the root node and the initial leaf node are first converted from hexadecimal numbers to binary numbers, and then the target hash value sequence of the root node is compared with the target hash values corresponding to the initial leaf nodes for parity, and finally the comparison result is converted to hexadecimal to obtain the final XOR operation result.
[0101] For example, the target hash value sequence of the root node is: 641557DDD4417095C78E74C96A3FB567FF033FBE52BC8F8080B38C1176E73DC2; the target hash value sequence corresponding to the initial leaf node 1 is:
[0102] 738D563C4411B08AFF388CD1FFDF9CA74D931EEA6B0BBE4A289CBC886D421764, the target hash value sequence corresponding to the initial leaf node 2 is: 258641AC34584369405645415BC67160215FE519732DE671335941BE28D953A1, then the target hash value sequence of the root node is XORed with the target hash value sequence of the initial leaf node 1 to obtain The XOR operation result is: 179081E19050C01F38B6F81895E029C0B290215439B731CAA82F30991BA52AA6; the XOR operation result of the target hash value sequence of the root node and the target hash value sequence of the initial leaf node 2 is: 248502A003598B13AC5D01756E5910F111597D18941440A26715150DF197A018.
[0103] Furthermore, the lottery result is determined according to the XOR operation result of the root node and each initial leaf node.
[0104] Specifically, in an optional implementation, after the target hash sequence value of the root node is XORed with the target hash sequence value of each root node to obtain the XOR result, the number of target values in the XOR results of the root node and each initial leaf node is determined; then, the XOR results are sorted according to the number of target values, and the user corresponding to the initial leaf node with the largest target value is determined as the final winning user.
[0105] For example, the target value can be 0, or other values, such as 1, 2, 3, etc. Then, as in the above-mentioned XOR operation result of the root node and the initial leaf node 1, the number of target values 0 is: 8, and in the XOR operation result of the root node and the initial leaf node 2, the number of target values 0 is: 7, then the number of target values 0 in the XOR operation result of the root node and the initial leaf node 1 is greater than the number of target values in the XOR operation result of the root node and the initial leaf node 2, and the user corresponding to the initial leaf node 1 can be determined as the winning user. If at this time, the number of values 0 in the XOR operation results corresponding to the root node and the initial leaf nodes 1-4 is 5, 6, 2, and 8 respectively, then the ranking result of the number of target values is 8>6>5>2, that is, the number of target values in the XOR operation result of the root node and the initial leaf node 4 is the largest, and the user corresponding to the initial leaf node 4 is determined as the winning user.
[0106] In an optional embodiment, if the number of target values in at least two XOR operation results is equal, the positions where the target values appear in the hash value sequences corresponding to the at least two XOR operations are determined respectively; then, the lottery result is determined based on the position where the target value first appears in each hash value sequence value.
[0107] For example, the number of target values in the XOR operation result of the root node and the initial leaf node 1 is 5, and the number of target values in the XOR operation result of the root node and the initial leaf node 2 is also 5. However, as shown in the XOR operation result of the root node and the initial leaf node 1: 179081, and the XOR operation result of the root node and the initial leaf node 2: 248502, it can be seen that the value 0 appears for the first time in the 4th bit of the XOR operation result of the root node and the initial leaf node 1, and the value 0 appears for the first time in the 5th bit of the XOR operation result of the root node and the initial leaf node 2, then the user corresponding to the initial leaf node 1 is determined as the winning user.
[0108] Furthermore, if the number of target values in the two XOR operation results is the same and the positions where the target values appear for the first time are the same, the positions where the target values appear for the second time are further compared until the final target user is determined.
[0109] Through the above method, the target hash value sequence corresponding to the root node is XORed with the target hash value sequence corresponding to each initial leaf node. In each calculation, since the target hash value is a 64-bit hexadecimal number, the probability that a single hexadecimal number is the same is Each character comparison in the target hash value sequence is a random event, so there are 64 comparisons in total, and the probability of the same character appearing is: That is, each initial leaf node has a 98.4% probability of repeating one character with the target hash value sequence corresponding to the root node. And, when there are two users participating in the lottery, the probability that each initial leaf node repeats one character with the target hash value corresponding to the root node is: When there are two users participating in the lottery, the probability that the target hash value corresponding to each initial leaf node and the root node repeats one character is Therefore, there will always be a user who is drawn as the winning user.
[0110] It should be noted that the lottery result is obtained by the initial nodes and the root node based on the Merkle tree. After the lottery result is determined by the Merkle tree structure, if a user has doubts about the lottery result, when the target user's verification request for the lottery result is obtained, the identification information corresponding to the target user is hashed to obtain the target hash value, and the target hash value of each node in the Merkle tree is obtained, and the target hash value of the identification information corresponding to the target user is spliced with the target hash value of the adjacent initial leaf node, and then the spliced target hash value is calculated to obtain the target hash value corresponding to the next layer of nodes, and then the target hash value is spliced with the adjacent target hash value in the next layer of nodes, and hashed to obtain the target hash value corresponding to the next layer of nodes, and the above process is repeated until the target hash value corresponding to the final root node is obtained. For example, if the target hash value corresponding to the target user is A, and the target hash value corresponding to its adjacent node is B, then the target hash value A and the target hash value B are concatenated to obtain the target hash value C, and the target hash value C obtained during the verification process is displayed to the target user. Furthermore, if the target hash value corresponding to the adjacent node at the same layer as the target hash value C is D, then the target hash value C and the target hash value D are concatenated, and then a hash operation is performed to obtain the target hash value E, and the target hash value E obtained during the verification process is displayed to the target user. The process is repeated until the target hash value corresponding to the root node is obtained.
[0111] During the verification process, a hash operation is performed on each of two nodes, and the verification process is displayed to the target user until the root node of the Merkle tree is obtained.
[0112] For example, see Figure 3 As shown, the initial leaf node is H A , H B , H C , H D , H E , H F , H G , H H , H I , H J , H K , H L, H M , H N , H O , H P , perform hash operation on every two adjacent initial leaf nodes to obtain the next layer of nodes, i.e. H AB , H CD , H EF , H GH , H IJ , H KL , H MN , H OP Similarly, the root node is H ABCDEFGHIJKLMNOP If node HL needs to verify the lottery process, then node H L With adjacent nodes H K Perform hash operation to obtain node H KL , H KL Then with the adjacent node H IJ Perform hash operation to obtain node H IJKL , node H IJKL Then with node H MNOP Perform hash operation to obtain node H IJKLMNOP , node H IJKLMNOP Then with node H ABCDEFGH Perform hash operation to get the root node H ABCDEFGHIJKLMNOP , that is, when verifying, you only need to repeat Figure 3 The process is presented in the dashed box.
[0113] By using the above method, when executing the verification process, the computational complexity is log 2 N, that is, when there are 16 leaf nodes, a leaf node needs to be verified, and only 4 operations need to be performed to obtain the verification result, so the lottery result can be verified quickly and accurately.
[0114] S4: If the verification process is the same as the target hash value corresponding to the root node of the Merkle tree, the lottery result is displayed.
[0115] Specifically, if the target hash value corresponding to the root node during verification is the same as the target hash value of the root node of the Merkle tree constructed during the lottery process, the lottery process is fair and just, and the final lottery result is displayed to the user. For example, the target hash value corresponding to the root node obtained during the lottery process is H 123 , the target hash value corresponding to the root node obtained in the process of verifying the lottery result is also H 123 , the entire lottery process is fair and just, and the identification information corresponding to the user is used in the lottery process. If they are different, the user may not have participated in the lottery process.
[0116] Through the above method, the verification result obtained based on the verification request of the target user is compared with the root node of the initially constructed Merkle tree, and the lottery result can be displayed to the user when the verification result is obtained.
[0117] Further, based on the same technical concept, the embodiment of the present application provides a data processing device, which is used to implement the above method flow of the embodiment of the present application. Figure 3 As shown, the device includes: an acquisition module 401, a construction module 402, a verification module 403 and a display module 404, wherein:
[0118] The acquisition module 401 is used to acquire identification information of each user; wherein the identification information of each user is different;
[0119] A construction module 402 is used to obtain a Merkle tree based on the target hash values corresponding to the respective identification information; wherein the Merkle tree is used to display the target hash values in each layer structure;
[0120] Verification module 403, for responding to the verification request of the target user for the lottery result, obtaining the verification result and displaying the verification process of the lottery result based on the target hash value and the Merkle tree corresponding to the target user; wherein the lottery result is obtained based on each initial node and the root node of the Merkle tree;
[0121] The display module 404 is used to display the lottery result if the verification result is the same as the target hash value corresponding to the root node of the Merkle tree.
[0122] In an optional implementation, when the Merkle tree is obtained based on the target hash values corresponding to the respective identification information, the construction module 402 is specifically used to:
[0123] Calculate the target hash value corresponding to each piece of identification information respectively;
[0124] Using each target hash value as the initial leaf node of the Merkle tree;
[0125] Based on the initial leaf nodes, the leaf nodes and the root nodes of each layer of the Merkle tree are calculated;
[0126] Based on the initial leaf node, the leaf nodes of each layer and the root node, the Merkle tree is constructed, and all nodes of the Merkle tree are saved.
[0127] In an optional implementation, when obtaining the lottery result, a processing module 405 is further included, and the processing module 405 is specifically used to:
[0128] Determine the target hash value sequences corresponding to the root node and each initial leaf node respectively;
[0129] Performing XOR operations on the target hash value sequence corresponding to the root node and the target hash value sequence corresponding to each initial leaf node, respectively, to obtain XOR operation results of the root node and each initial leaf node;
[0130] The lottery result is determined based on the results of each XOR operation.
[0131] In an optional implementation, when determining the lottery result according to each XOR operation result, the processing module 405 is specifically used to:
[0132] Determine the number of target values in the XOR operation results of the root node and each initial leaf node respectively;
[0133] Sort the number of target values and take the initial leaf node with the largest target value as the lottery result.
[0134] In an optional implementation, after respectively determining the number of target values in the XOR operation results of the root node and each initial leaf node, the processing module 405 is further used to:
[0135] If the number of target values in at least two XOR operation results is equal, respectively determining the positions where the target values appear in the hash value sequences corresponding to the at least two XOR operation results;
[0136] The lottery result is determined according to the position where the target value first appears in each of the hash value sequences.
[0137] In an optional implementation, before obtaining the Merkle tree based on the target hash values corresponding to the respective identification information, the construction module 403 is further used to:
[0138] Determine whether the number of initial leaf nodes is an even number;
[0139] If not, add a node with a hash value of 0 as the initial leaf node.
[0140] Based on the same technical concept, the embodiment of the present application also provides an electronic device, which can implement the data processing method provided in the above embodiment of the present application. In one embodiment, the electronic device can be a server, or a terminal device or other electronic device. Figure 5 As shown, the electronic device may include:
[0141] At least one processor 501, and a memory 502 connected to the at least one processor 501. The specific connection medium between the processor 501 and the memory 502 is not limited in the embodiment of the present application. Figure 5In the example, the processor 501 and the memory 502 are connected via a bus 500. The bus 500 is Figure 5 The connections between other components are shown in bold lines, and are not intended to be limiting. The bus 500 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. Alternatively, the processor 501 can also be called a controller, and there is no limitation on the name.
[0142] In the embodiment of the present application, the memory 502 stores instructions that can be executed by at least one processor 501. The at least one processor 501 can execute a data processing method discussed above by executing the instructions stored in the memory 502. The processor 501 can implement Figure 4 The functions of each module in the device shown.
[0143] Among them, the processor 501 is the control center of the device, and can use various interfaces and lines to connect the various parts of the entire control device. By running or executing instructions stored in the memory 502 and calling data stored in the memory 502, the various functions of the device and processing data, the device can be monitored as a whole.
[0144] In one possible design, the processor 501 may include one or more processing units, and the processor 501 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 501. In some embodiments, the processor 501 and the memory 502 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on separate chips.
[0145] Processor 501 can be a general-purpose processor, such as a CPU, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of a data processing method disclosed in the embodiments of the present application can be directly embodied as a hardware processor to be executed, or a combination of hardware and software modules in the processor can be executed.
[0146] The memory 502 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 502 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 502 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 302 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0147] By programming the processor 501, the code corresponding to the frequency offset estimation method described in the above embodiment can be fixed into the chip, so that the chip can execute the code when running. Figure 1 The steps of a data processing method in the embodiment shown are as follows: How to design and program the processor 501 is a technique known to those skilled in the art and will not be described in detail here.
[0148] Based on the same inventive concept, an embodiment of the present application further provides a storage medium, which stores computer instructions. When the computer instructions are executed on a computer, the computer executes a data processing method discussed above.
[0149] In some possible implementations, the present application also provides various aspects of a data processing method that can also be implemented in the form of a program product, which includes program code. When the program product is run on an apparatus, the program code is used to enable the control device to execute the steps of a data processing method according to various exemplary implementations of the present application described above in this specification.
[0150] 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.
[0151] 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.
[0152] 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 include computer-usable program code.
[0153] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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 server, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the flowchart. 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.
[0154] Program code for performing the operations of the present application may be written using 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 stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0155] 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.
[0156] 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 is also intended to include these modifications and variations.
Claims
1. A data processing method, characterized in that: The method comprises: Obtaining identification information of each user; wherein the identification information of each user is different; Based on the target hash values corresponding to the respective identification information, a Merkle tree is obtained; wherein the Merkle tree is used to display the target hash values in each layer structure; In response to a verification request of a target user for a lottery result, based on a target hash value corresponding to the target user and the Merkle tree, a verification result is obtained and a verification process of the lottery result is displayed; wherein the lottery result is obtained based on each initial node and a root node of the Merkle tree; If the verification result is the same as the target hash value corresponding to the root node of the Merkle tree, the lottery result is displayed.
2. The method according to claim 1, characterized in that The obtaining of the Merkle tree based on the target hash values corresponding to the respective identification information includes: Calculate the target hash value corresponding to each piece of identification information respectively; Using each of the target hash values as an initial leaf node of the Merkle tree; Based on the initial leaf nodes, the leaf nodes and the root node of each layer of the Merkle tree are calculated; Based on the initial leaf node, the leaf nodes of each layer and the root node, the Merkle tree is constructed, and all nodes of the Merkle tree are saved.
3. The method according to claim 1, characterized in that The lottery results are obtained in the following way: Respectively determine the target hash value sequences corresponding to the root node and each of the initial leaf nodes; Performing an XOR operation on the target Hash value sequence corresponding to the root node and the target Hash value sequence corresponding to each of the initial leaf nodes, respectively, to obtain an XOR operation result of the root node and each of the initial leaf nodes; The lottery result is determined according to each of the XOR operation results.
4. The method according to claim 3, characterized in that Determining the lottery result according to each of the XOR operation results includes: Respectively determine the number of target values in the XOR operation results of the root node and each initial leaf node; The number of the target values is sorted, and the initial leaf node with the largest target value is used as the lottery result.
5. The method according to claim 4, characterized in that After respectively determining the number of target values in the XOR operation results of the root node and each initial leaf node, the method further includes: If the number of the target values in at least two XOR operation results is equal, respectively determining the positions where the target values appear in the hash value sequences corresponding to the at least two XOR operation results; The lottery result is determined according to the position where the target value first appears in each of the hash value sequences.
6. The method according to claim 1, characterized in that Before obtaining the Merkle tree based on the target hash values corresponding to the respective identification information, the method further includes: Determine whether the number of the initial leaf nodes is an even number; If not, add a node with a hash value of 0 as the initial leaf node.
7. A data processing device, characterized in that: The device comprises: The acquisition module is used to acquire the identification information of each user; wherein the identification information corresponding to each user is different A construction module, used to obtain a Merkle tree based on the target hash values corresponding to each of the identification information; wherein the Merkle tree is used to display the target hash values in each layer structure; A verification module, configured to, in response to a verification request of a target user for a lottery result, obtain a verification result based on a target hash value corresponding to the target user and the Merkle tree and display a verification process of the lottery result; wherein the lottery result is obtained based on each initial node and a root node of the Merkle tree; A display module is used to display the lottery result if the verification result is the same as the target hash value corresponding to the root node of the Merkle tree.
8. The device according to claim 7, characterized in that When obtaining the Merkle tree based on the target hash values corresponding to the respective identification information, the construction module is specifically used for: Calculate the target hash value corresponding to each piece of identification information respectively; Using each of the target hash values as an initial leaf node of the Merkle tree; Based on the initial leaf nodes, the leaf nodes and the root node of each layer of the Merkle tree are calculated; Based on the initial leaf node, the leaf nodes of each layer and the root node, the Merkle tree is constructed, and all nodes of the Merkle tree are saved.
9. The device according to claim 7, characterized in that It also includes a processing module, which is specifically used for: Respectively determine the target hash value sequences corresponding to the root node and each of the initial leaf nodes; Performing an XOR operation on the target Hash value sequence corresponding to the root node and the target Hash value sequence corresponding to each of the initial leaf nodes, respectively, to obtain an XOR operation result of the root node and each of the initial leaf nodes; The lottery result is determined according to each of the XOR operation results.
10. The device according to claim 9, characterized in that When the lottery result is determined according to each of the XOR operation results, the processing module is specifically used for: Respectively determine the number of target values in the XOR operation results of the root node and each initial leaf node; The number of the target values is sorted, and the initial leaf node with the largest target value is used as the lottery result.
11. The device according to claim 10, characterized in that After respectively determining the number of target values in the XOR operation results of the root node and each initial leaf node, the processing module is further used to: If the number of the target values in at least two XOR operation results is equal, respectively determining the positions where the target values appear in the hash value sequences corresponding to the at least two XOR operation results; The lottery result is determined according to the position where the target value first appears in each of the hash value sequences.
12. The device according to claim 7, characterized in that Before obtaining the Merkle tree based on the target hash values corresponding to the respective identification information, the construction module is further used to: Determine whether the number of the initial leaf nodes is an even number; If not, add a node with a hash value of 0 as the initial leaf node.
13. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
15. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is run on a computer, the computer is enabled to execute the method according to any one of claims 1 to 6.
