Random number negotiation method and system
By determining the master participant and slave participant in random number negotiation, and using one-way functions and objective functions to generate random numbers, the problems of complexity and cost of random number negotiation in the existing technology are solved, and fairness and practicality are achieved Improvement of sex.
Patent Information
- Application Number
- CN202411025583.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-11-15
AI Technical Summary
The existing random number negotiation scheme is complex and costly, making it difficult to ensure fairness and practicality, especially in key negotiation protocols and random number generation physical device applications.
By determining the master participant and slave participant from multiple participants, using pre-set one-way function and objective function, the master participant sends the first master random number and the second master random number, and after verification by each slave participant, the master participant Generate target random numbers to ensure fairness and reduce computational complexity and cost.
It effectively avoids the possibility of manipulating random number results from participants, reduces the complexity and cost of the random number negotiation process, and improves the practicality and fairness of random number negotiation.
Smart Images

Figure CN118972045A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security technology, and in particular to a random number negotiation method and system. Background Art
[0002] Random numbers have important applications in scientific research and daily life. For example, in the fields of drug development and material design, random number input is needed to complete numerical simulation calculations; in the fields of games and artificial intelligence, random numbers are needed to control the evolution of the system.
[0003] At present, a qualified random number negotiation scheme must meet the following basic requirements: all participants have substantial contributions to the results and have the ability to influence the various values of the results. Any party, even N-1 parties (N represents the total number of participants, an integer greater than or equal to 2) colluding, cannot manipulate the results. In the related art, there are applications that determine random numbers through key negotiation protocols or using physical random number generators, but these applications are often more complex and costly. For example, key negotiation protocols require special software modules or hardware chips, and physical random number generators are expensive and have poor versatility.
[0004] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention
[0005] The purpose of the present invention is to solve one of the technical problems existing in the related art to at least a certain extent.
[0006] The main purpose of the embodiments of the present application is to propose a random number negotiation method and system, wherein the method can effectively ensure the fairness of the random number negotiation results, reduce the complexity and cost of the random number negotiation process, and improve practicality.
[0007] To achieve the above purpose, a first aspect of an embodiment of the present application proposes a random number negotiation method, including:
[0008] Determine any one of the multiple participants as a primary participant, and determine the participants other than the primary participant as secondary participants;
[0009] The main participant sends a first main random number to other participants;
[0010] Each of the slave participants sends a slave random number to other participants. After all the slave participants have finished sending the slave random numbers, the master participant sends a second master random number to other participants; wherein the first master random number is calculated from the second master random number through a one-way function that is preset and known to each of the participants;
[0011] Each of the slave participants verifies the second master random number. When the verification is successful, a target random number is generated based on the second master random number and all the slave random numbers through a preset target function known to each of the participants.
[0012] In some embodiments, the method further comprises:
[0013] The main participant randomly selects the original sample random number;
[0014] The main participant obtains multiple new sample random numbers by iteratively calling the one-way function according to the original sample random number;
[0015] The main participant determines the serial numbers corresponding to the sample random numbers in reverse order according to the order in which the sample random numbers are obtained;
[0016] Among them, the serial number corresponding to the sample random number obtained earlier by the main participant is greater than the serial number corresponding to the sample random number obtained later.
[0017] In some embodiments, the step of calculating and obtaining a plurality of new sample random numbers by iteratively calling the one-way function includes:
[0018] Obtaining a first number of target random numbers requiring multiple rounds of negotiation;
[0019] Add one to the first number to obtain a second number;
[0020] Using the latest sample random number as input, a new sample random number is calculated by the one-way function;
[0021] Count the third number of the currently obtained sample random numbers, and if the third number is equal to the second number, end the iterative call; or if the third number is less than the second number, return to the step of using the latest currently obtained sample random number as input and calculating a new sample random number through the one-way function.
[0022] In some embodiments, the main participant sends the first main random number to other participants, including:
[0023] The main participant determines the sample random number with the smallest corresponding serial number as the first main random number, and sends the first main random number to other participants;
[0024] The main participant sends a second main random number to other participants, including:
[0025] The main participant determines the sample random number with the second smallest corresponding serial number as the second main random number, and sends the second main random number to other participants.
[0026] In some embodiments, the method further comprises:
[0027] Obtaining a first number of target random numbers requiring multiple rounds of negotiation;
[0028] Detecting a fourth number of target random numbers generated in the current round;
[0029] If the fourth number is less than the first number, each of the slave participants sends a new slave random number to the other participants;
[0030] After all the slave participants have sent their new slave random numbers, the master participant determines the sample random number with a corresponding sequence number greater than and next to the first sequence number as a new second master random number, and sends the second master random number to other participants; wherein the first sequence number is the sequence number corresponding to the second master random number sent by the master participant in the previous round;
[0031] Each of the slave participants verifies the second master random number. When the verification is successful, a target random number is generated through the target function based on the second master random number and all the slave random numbers sent in this round, and the process returns to execute the fourth step of detecting the currently generated target random number.
[0032] In some embodiments, the slave party verifies the second master random number, including:
[0033] The slave participant calls the one-way function to calculate a verification random number according to the second master random number;
[0034] The slave participant compares whether the first master random number and the verification random number are consistent;
[0035] If the first master random number and the verification random number are consistent, the slave participant determines that the verification is successful; or, if the first master random number and the verification random number are inconsistent, the slave participant determines that the verification is unsuccessful.
[0036] In some embodiments, generating a target random number according to the second master random number and all the slave random numbers by using a preset target function known to all the participants includes:
[0037] Performing an XOR operation on the second master random number and all the slave random numbers to obtain the target random number;
[0038] Alternatively, a predetermined output bit width is obtained, the second master random number and all the slave random numbers are summed and the output bit width result is truncated from the tail to obtain the target random number.
[0039] A second aspect of the present application provides a random number negotiation system, including a master participant and a slave participant;
[0040] The main participant is used to send a first main random number to other participants;
[0041] Each of the slave participants is used to send a slave random number to other participants. After all the slave participants have finished sending the slave random numbers, the master participant sends a second master random number to other participants; wherein the first master random number is calculated from the second master random number through a one-way function that is preset and known to each of the participants;
[0042] Each of the slave participants is used to verify the second master random number. When the verification is successful, the master participant and each of the slave participants are used to generate a target random number based on the second master random number and all the slave random numbers through a pre-set target function known to each of the participants.
[0043] In some embodiments, the master participant is further configured to:
[0044] Randomly select the original sample random number;
[0045] According to the original sample random number, multiple new sample random numbers are calculated by iteratively calling the one-way function;
[0046] Determine the sequence number corresponding to each of the sample random numbers in reverse order according to the order in which the sample random numbers are obtained;
[0047] Among them, the serial number corresponding to the sample random number obtained earlier by the main participant is greater than the serial number corresponding to the sample random number obtained later.
[0048] In some embodiments, the slave party is specifically used to:
[0049] According to the second primary random number, calling the one-way function to calculate a verification random number;
[0050] Comparing whether the first primary random number and the verification random number are consistent;
[0051] If the first master random number and the verification random number are consistent, it is determined that the verification is successful; or if the first master random number and the verification random number are inconsistent, it is determined that the verification is unsuccessful.
[0052] The embodiments of the present application include at least the following beneficial effects:
[0053] The present application provides a random number negotiation method and system, wherein the method determines any one of the multiple participants as a master participant, and determines the participants other than the master participant as slave participants; the master participant sends a first master random number to the other participants; each of the slave participants sends a slave random number to the other participants, and after all the slave participants have finished sending the slave random numbers, the master participant sends a second master random number to the other participants; wherein the first master random number is calculated by the second master random number through a one-way function that is pre-set and known to each of the participants; each of the slave participants verifies the second master random number, and when the verification is passed, a target random number is generated according to the second master random number and all of the slave random numbers through a pre-set target function that is known to each of the participants. In the present application, after all the slave participants have finished sending the slave random numbers, the master participant sends the second master random number to the other participants, which can avoid the possibility of a slave participant manipulating the random number result.
[0054] In addition, each slave participant verifies the second master random number sent by the master participant based on the well-known one-way function and the received first master random number. Only after the verification is passed will the second master random number be used to participate in the calculation of the target random number. This can avoid the possibility of the master participant who provides the master random number manipulating the random number result and ensure the fairness of the random number negotiation result.
[0055] In addition, compared with the heavyweight public key calculation operation used in the key negotiation protocol, the one-way function and target function used in this method can be implemented based on lightweight operations, the random number negotiation process is relatively simple, requires fewer computing resources, and has low complexity; compared with the use of a physical device for generating random numbers, this method has low cost, wide application range, and better versatility. Therefore, the method in this application can reduce the complexity and implementation cost of the random number negotiation process and improve the practicality of random number negotiation. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 It is a flowchart of a random number negotiation method provided in an embodiment of the present application;
[0057] Figure 2 It is a timing flow diagram of a random number negotiation method provided in an embodiment of the present application;
[0058] Figure 3 This is a flow chart of a random number negotiation method provided in an embodiment of the present application;
[0059] Figure 4 is a detailed flow chart of step A2 provided in an embodiment of the present application;
[0060] Figure 5is a detailed schematic diagram of step S102 provided in an embodiment of the present application;
[0061] Figure 6 is a detailed schematic diagram of step S103 provided in an embodiment of the present application;
[0062] Figure 7 This is another flowchart of a random number negotiation method provided by an embodiment of the present application;
[0063] Figure 8 is a detailed flow chart of step S104 provided in an embodiment of the present application;
[0064] Fig. 9 It is a structural block diagram of a random number negotiation system provided in an embodiment of the present application;
[0065] Fig.10 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0066] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices / equipment and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0067] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0068] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0069] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0070] The following is an introduction to several terms involved in this application:
[0071] Heavyweight operation: In cryptographic technology, the public key calculation in the key negotiation protocol is a heavyweight operation, which mainly includes asymmetric encryption, digital signature, etc. It requires more computing resources, and the negotiation process based on public key calculation is relatively complicated.
[0072] Lightweight operations: In cryptographic technology, they mainly include hash functions (also known as hash functions), basic operations (such as XOR, summation, truncation, etc.), symmetric encryption, etc., which require fewer computing resources and are relatively simple to implement.
[0073] Random numbers have important applications in scientific research and daily life. For example, in the fields of drug development and material design, random number input is needed to complete numerical simulation calculations; in the fields of games and artificial intelligence, random numbers are needed to control the evolution of the system.
[0074] Currently, a qualified random number negotiation scheme must meet the following basic requirements: all participating parties have made substantial contributions to the results and have the ability to influence the various values of the results. No party, even N-1 parties (N represents the total number of participants, an integer greater than or equal to 2) can manipulate the results by collusion.
[0075] This application uses a round of simple random number negotiation in a specific application scenario as an example, where one participant in the round of random number negotiation manipulates the random number result. Specifically:
[0076] Suppose there are four teams, A, B, C, and D, holding a competition. There are only three candidate plans for the schedule of the competition, numbered 0, 1, and 2: (0) A vs. B, C vs. D, the winners of the two games compete for the championship and the losers compete for the third place (the same and omitted below); (1) A vs. C, B vs. D; (2) A vs. D, B vs. C. The four teams (four participants) jointly agree on a random integer, and the corresponding plan is selected based on the result modulo 3.
[0077] Among them, one of the schemes to reach a random integer is that each participant reports an integer and then sums them up, and the corresponding scheme is selected through modulo 3. For example, participant A reports the number 520, then participant B reports the number 1314, and then participant C reports the number 666666; participant D can calculate that the result of (520+1314+666666) modulo 3 is 1. If participant D wants to play scheme 2, participant D can report the number 1234567 through calculation, so that the final random number negotiation result modulo 3 is 2. At this time, the random number negotiation result is manipulated by participant D. For participants A, B, and C, this random number negotiation scheme cannot guarantee fairness.
[0078] In the related technology, there are applications that determine random numbers through key negotiation protocols or using physical random number generating devices, but these applications are often more complex and costly. For example, key negotiation protocols require special software modules or hardware chips, and physical random number generating devices are expensive and have poor versatility.
[0079] In view of this, the present application provides a random number negotiation method and system. After all slave participants have sent their slave random numbers, the master participant sends a second master random number to other participants, thereby avoiding the possibility of a slave participant manipulating the random number result.
[0080] In addition, each slave participant verifies the second master random number sent by the master participant based on the well-known one-way function and the received first master random number. Only after the verification is passed will the second master random number be used to participate in the calculation of the target random number. This can avoid the possibility of the master participant who provides the master random number manipulating the random number result and ensure the fairness of the random number negotiation result.
[0081] In addition, compared with the heavyweight public key calculation operation used in the key negotiation protocol, the one-way function and target function used in this method can be implemented based on lightweight operations, the random number negotiation process is relatively simple, requires fewer computing resources, and has low complexity; compared with the use of a physical device for generating random numbers, this method has low cost, wide application range, and better versatility. Therefore, the method in this application can reduce the complexity and implementation cost of the random number negotiation process and improve the practicality of random number negotiation.
[0082] A random number negotiation method provided in an embodiment of the present application can be applied to a random number generation application scenario. In a random number generation application scenario, the parties involved in the random number negotiation can negotiate a random number through the random number negotiation method provided in an embodiment of the present application. The random number can be used in fields that require the use of random numbers, such as drug development, material design, games, artificial intelligence, and security protocols. The negotiated random number can ensure fairness, and the complexity of the random number negotiation process and the required computing resources are low, and the practicality is high.
[0083] A random number negotiation method provided in an embodiment of the present application can be applied to a terminal, a server, or software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a vehicle-mounted terminal, etc., but is not limited thereto; the server side can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network; the software can be an application that implements the method, etc., but is not limited to the above forms.
[0084] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0085] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0086] Reference Figure 1 and Figure 2 , Figure 1is an optional flow chart of a random number negotiation method provided in an embodiment of the present application. Figure 2 is an optional timing flow chart of a random number negotiation method provided in an embodiment of the present application, Figure 1 The method may include but is not limited to steps S101 to S104.
[0087] Step S101: Determine any one of the multiple participants as a primary participant, and determine the participants other than the primary participant as secondary participants;
[0088] In the embodiment of the present application, the number of slave participants can be greater than or equal to 1, and each participant is connected to communicate with each other. Step S101 can be implemented based on the relevant communication protocol through the request and response operation of the participant. Specifically, in an optional simple implementation method, any participant among multiple participants can broadcast a request to become a master participant to the remaining participants. After receiving the request, the remaining participants set the participant who sent the request as the master participant, and then return the response message to the master participant in the original path. The example of this application is for illustration only and does not limit this application.
[0089] Step S102: the main participant sends a first main random number to other participants;
[0090] In an embodiment of the present application, for a certain round of negotiation in a single random number negotiation or a continuous random number negotiation, the main participant can actively send a first master random number to other participants (slave participants), and the first master random number is used as a non-cheating proof of the main participant. The first master random number can be generated by the main participant in the first round of negotiation in a single random number negotiation or a continuous random number negotiation; and in the second and subsequent rounds of negotiation in the continuous random number negotiation, the first master random number of the current round can be the second master random number provided by the main participant in the previous round of negotiation.
[0091] Step S103, each of the slave participants sends a slave random number to other participants, and after all the slave participants have finished sending the slave random numbers, the master participant sends a second master random number to other participants; wherein the first master random number is calculated from the second master random number through a one-way function that is preset and known to each of the participants;
[0092] In an embodiment of the present application, a one-way function known to all participating parties may be pre-set, or may be negotiated during the request response process between the participating parties in step S101. The specific one-way function may adopt a hash algorithm (such as the SM3 algorithm), so that it is feasible for each participating party to calculate the first master random number from the second master random number based on the one-way function, but it is computationally infeasible to derive the second master random number from the first master random number.
[0093] It can be understood that, after receiving the first master random number sent by the master participant in step S103, each slave participant retains the first master random number and generates a slave random number; then sends the slave random number to the master participant and the remaining slave participants, and after receiving the slave random numbers sent by all the slave participants, the master participant sends the second master random number to all the slave participants.
[0094] It should be noted that in the embodiment of the present application, the master party sends the second master random number after all slave parties have sent the slave random numbers, so that the slave party does not become the last party to provide a random number, thereby avoiding the possibility of a slave party manipulating the random number result.
[0095] Step S104: Each of the slave participants verifies the second master random number. When the verification is successful, a target random number is generated based on the second master random number and all the slave random numbers through a preset target function known to each of the participants.
[0096] In an embodiment of the present application, for a certain slave participant, the second master random number can be verified based on its well-known one-way function and the first master random number previously received. When the verification fails, the negotiation agreement of the participants is terminated; or, when the verification passes, the slave random numbers provided by all slave participants and the second master random number provided by the master participant can be used as inputs of the target function to generate the target random number of this round of random number negotiation process.
[0097] In an embodiment of the present application, the objective function is used to receive two or more integer inputs, and the output of the objective function is independent of the order of the integer inputs, and it can be implemented based on lightweight operations. Specifically, if the objective function receives two integer inputs, and the bit width w of the two integer inputs is the same, its first optional expression is m(x,y)=x⊕y, where m() is the objective function, x is the first integer input, y is the second integer input, and ⊕ is the XOR operator; or, its second optional expression is m(x,y)=(x+y)%W, where % is the modulus operator, and W is 2 to the power of w.
[0098] It can be understood that if the objective function receives three integer inputs, one optional expression can be m(x, y, z) = m(m(x, y), z), where z is the third integer input. The objective functions corresponding to the remaining number of integer inputs can be derived by analogy based on the foregoing content, and this application will not go into details here.
[0099] Reference Figure 3 In some embodiments, the method further comprises:
[0100] A1. The main participant randomly selects the original sample random number;
[0101] A2. The main participant obtains multiple new sample random numbers by iteratively calling the one-way function according to the original sample random number;
[0102] Further, refer to Figure 4 The step A2, calculating and obtaining a plurality of new sample random numbers by iteratively calling the one-way function, comprises:
[0103] A21. Obtain a first number of target random numbers that require multiple rounds of negotiation;
[0104] A22. Add one to the first number to obtain a second number;
[0105] A23, using the latest sample random number obtained as input, and calculating a new sample random number through the one-way function;
[0106] A24. Count the third number of the currently obtained sample random numbers. If the third number is equal to the second number, end the iterative call; or, if the third number is less than the second number, return to execute the step of using the currently obtained latest sample random number as input and calculating a new sample random number through the one-way function.
[0107] In an embodiment of the present application, when there is a need for multiple rounds of negotiation of random numbers between the main participant and each slave participant, the main participant can determine the number of random numbers to be negotiated (i.e., the first number of target random numbers) before conducting the random number negotiation; and then add one to the first number to determine the number of sample random numbers of the main participant during the multiple rounds of negotiation (i.e., the second number).
[0108] For example, for the first iterative calling process, the original sample random number is used as the latest sample random number x1[n], and the mathematical expression of step A23 can be:
[0109] x1[n-1]=f(x1[n])
[0110] Wherein, f() is a one-way function, x1[n] is the latest sample random number obtained, x1[n-1] is a new sample random number, and n is the first number of target random numbers that require multiple rounds of negotiation.
[0111] It can be understood that after the main participant executes step A23 for the first time, the third number of sample random numbers obtained by counting is 2. At this time, the third number can be compared with the second number. If the third number is smaller than the second number, it means that the main participant has not obtained enough sample random numbers, and can return to execute step A23; or, if the third number is equal to the second number, it means that the main participant has obtained enough sample random numbers, exits the iterative calling process, and executes step A3.
[0112] A3. The main participant determines the serial numbers corresponding to the sample random numbers in reverse order according to the order in which the sample random numbers are obtained;
[0113] Among them, the serial number corresponding to the sample random number obtained earlier by the main participant is greater than the serial number corresponding to the sample random number obtained later.
[0114] In an embodiment of the present application, after the main participant obtains a number of sample random numbers equal to the second number, the sample random numbers can be arranged in reverse order according to the order of generation, with the latest generated sample random number corresponding to the smallest serial number and the earliest generated sample random number (i.e., the original sample random number) corresponding to the largest serial number.
[0115] It can be understood that the several sample random numbers determined by the main participant can be expressed as x1[0], x1[1], ..., x1[n-1], x1[n], totaling n+1 (ie, the second number) sample random numbers.
[0116] It should be noted that, for continuous random number negotiation, the slave random number sent by the slave party in step S103 in the embodiment of the present application may be a slave random number with a corresponding serial number randomly generated by the slave party after receiving the first master random number.
[0117] In some embodiments, reference Figure 5 , the step S102, the main participant sends the first main random number to other participants, including:
[0118] B1. The main participant determines the sample random number with the smallest corresponding serial number as the first main random number, and sends the first main random number to other participants;
[0119] Reference Figure 6 , the step S103, the main participant sending a second main random number to other participants, includes:
[0120] C1. The main participant determines the sample random number with the second smallest corresponding serial number as the second main random number, and sends the second main random number to other participants.
[0121] In an embodiment of the present application, for a single random number negotiation or the first round of negotiation in a continuous random number negotiation, the master party may determine the sample x1[0] with the smallest serial number among all the sample random numbers as the first master random number, and send the first master random number x1[0] to the slave party.
[0122] It can be understood that, for a single random number negotiation or the first round of negotiation in a continuous random number negotiation, the corresponding sample random number x1[1] with the second smallest serial number is the second master random number, and the second master random number x1[1] is sent to the slave participant.
[0123] Reference Figure 7 In some embodiments, the method further comprises:
[0124] D1. Obtain a first number of target random numbers that require multiple rounds of negotiation;
[0125] D2, detecting the fourth number of target random numbers generated in the current round;
[0126] D3. If the fourth number is less than the first number, each of the slave participants sends a new slave random number to other participants;
[0127] D4. After all the slave participants have sent new slave random numbers, the master participant determines the sample random number with a corresponding sequence number greater than and next to the first sequence number as a new second master random number, and sends the second master random number to other participants; wherein the first sequence number is the sequence number corresponding to the second master random number sent by the master participant in the previous round;
[0128] D5. Each of the slave participants verifies the second master random number. When the verification is successful, a target random number is generated through the target function based on the second master random number and all the slave random numbers sent in this round, and the process returns to execute the fourth step of detecting the currently generated target random number.
[0129] In an embodiment of the present application, for a certain round of negotiation process in a continuous random number negotiation, after obtaining the target random number corresponding to the current round, the participating party can count the total number of target random numbers that have been generated to obtain a fourth number; then compare the size relationship between the first number and the fourth number. If the fourth number is equal to the first number, it means that enough target random numbers have been negotiated and the random number negotiation can be terminated.
[0130] Alternatively, if the fourth number is smaller than the first number, it means that the master party and the slave party still need to carry out the next round of random number negotiation process. At this time, the slave party can use the second master random number of the current round as the first master random number of the next round and send new random numbers to other parties. After receiving all new slave random numbers, the master party will send the corresponding serial number greater than and next to the first serial number as the new second master random number to other parties.
[0131] Exemplarily, for step D3 to step D4, the embodiment of the present application takes the number of slave participants as 3, which are x2, x3, and x4 respectively as an example. If in the second round of negotiation in the continuous random number negotiation, after the slave party obtains the target random number corresponding to the second round, the newly obtained fourth number is still smaller than the first number, then the second master random number x1[2] provided by the master party in the second round of negotiation can be used as the first master random number of the third round of negotiation; the three slave parties respectively provide slave random numbers x2[3], x3[3] and x4[3] of the third round of negotiation; after receiving x2[3], x3[3] and x4[3], the master party sends the second master random number x1[3] of the third round of negotiation to the three slave parties, and the sequence number of the second master random number x1[3] of the third round of negotiation is greater than and is adjacent to the sequence number of the second master random number x1[2] provided in the second round of negotiation. The example in this application is for illustration only, and the specific number of slave parties, the specific number of target random numbers (i.e., the rounds of continuous random number negotiation), the specific negotiation rounds of continuous random number negotiation, etc. can all be flexibly changed according to actual conditions.
[0132] Reference Figure 8 In some embodiments, the step S104, verifying the second primary random number from the participant, includes:
[0133] E1. The slave party calls the one-way function to calculate the verification random number according to the second master random number;
[0134] E2. The slave party compares the first master random number with the verification random number to see if they are consistent;
[0135] E3. If the first master random number and the verification random number are consistent, the slave participant determines that the verification is successful; or, if the first master random number and the verification random number are inconsistent, the slave participant determines that the verification is unsuccessful.
[0136] In an embodiment of the present application, during a negotiation process of a certain round, the slave party may use the second master random number as the input of a one-way function and the output of the one-way function as a verification random number; then reuse the second master random number of the previous round (i.e., the first master random number of the current round) to compare with the obtained verification function; if the first master random number of the current round is consistent with the verification random number, it can be considered that the second master random number provided by the master party during the negotiation process of the current round did not manipulate the random number result, and the slave party determines that the verification is successful; or, if the first master random number of the current round is inconsistent with the verification random number, it can be considered that the second master random number provided by the master party during the negotiation process of the current round manipulates the random number result, and the slave party determines that the verification is unsuccessful.
[0137] In some embodiments, the step S104, generating a target random number according to the second master random number and all the slave random numbers through a preset target function known to all the participants, includes:
[0138] F1. Perform an XOR operation on the second master random number and all the slave random numbers to obtain the target random number;
[0139] F2. Alternatively, a predetermined output bit width is obtained, the second master random number and all the slave random numbers are summed, and the result of the output bit width is cut from the tail to obtain the target random number.
[0140] In an embodiment of the present application, the number of slave participants may be greater than or equal to 1, and each slave random number corresponds to a slave participant; the objective function may be implemented based on lightweight operations, which include basic operations (such as XOR, sum, truncation, etc.), etc.
[0141] Specifically, the XOR operation in step F1 can input the second master random number and all slave random numbers into a target function that performs the XOR operation, and obtain a target random number based on each random number.
[0142] It can be understood that step F2 can be to sum the second master random number and all the slave random numbers to obtain a bit sequence composed of a number of bits; then based on a preset output bit width, a certain number of bits are cut from the tail of the bit sequence as the target random number, and the number is equal to the output bit width. The specific value of the output bit width can be set according to actual conditions.
[0143] See also Fig. 9 The embodiment of the present application also provides a random number negotiation system, including a master participant 810 and a slave participant 820, wherein the master participant and the slave participant are used to execute the above method.
[0144] It can be understood that the contents of the above method embodiments are all applicable to the present system embodiments, the functions specifically implemented by the present system embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0145] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0146] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0147] See also Fig.10 , Fig.10 The hardware structure of an electronic device of an embodiment is illustrated, and the electronic device includes:
[0148] The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0149] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 902, and the processor 901 calls and executes the methods of the embodiments of this application;
[0150] Input / output interface 903, used to implement information input and output;
[0151] Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0152] A bus 905 that transmits information between the various components of the device (e.g., the processor 901, the memory 902, the input / output interface 903, and the communication interface 904);
[0153] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .
[0154] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program, and the computer program implements the above method when executed by a processor.
[0155] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0156] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0157] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0158] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0159] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0160] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0161] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0162] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0163] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0164] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0165] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0166] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0167] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A random number negotiation method, characterized in that: The method comprises: Determine any one of the multiple participants as a primary participant, and determine the participants other than the primary participant as secondary participants; The main participant sends a first main random number to other participants; Each of the slave participants sends a slave random number to other participants. After all the slave participants have finished sending the slave random numbers, the master participant sends a second master random number to other participants; wherein the first master random number is calculated from the second master random number through a one-way function that is preset and known to each of the participants; Each of the slave participants verifies the second master random number. When the verification is successful, a target random number is generated based on the second master random number and all the slave random numbers through a preset target function known to each of the participants.
2. The negotiation method according to claim 1, characterized in that: The method further comprises: The main participant randomly selects the original sample random number; The main participant obtains multiple new sample random numbers by iteratively calling the one-way function according to the original sample random number; The main participant determines the serial numbers corresponding to the sample random numbers in reverse order according to the order in which the sample random numbers are obtained; Among them, the serial number corresponding to the sample random number obtained earlier by the main participant is greater than the serial number corresponding to the sample random number obtained later.
3. The negotiation method according to claim 2, characterized in that: The method of calculating and obtaining a plurality of new sample random numbers by iteratively calling the one-way function includes: Obtaining a first number of target random numbers requiring multiple rounds of negotiation; Add one to the first number to obtain a second number; Using the latest sample random number as input, a new sample random number is calculated by the one-way function; Count the third number of the currently obtained sample random numbers, and if the third number is equal to the second number, end the iterative call; or if the third number is less than the second number, return to the step of using the latest currently obtained sample random number as input and calculating a new sample random number through the one-way function.
4. The negotiation method according to claim 2, characterized in that: The main participant sends a first main random number to other participants, including: The main participant determines the sample random number with the smallest corresponding serial number as the first main random number, and sends the first main random number to other participants; The main participant sends a second main random number to other participants, including: The main participant determines the sample random number with the second smallest corresponding serial number as the second main random number, and sends the second main random number to other participants.
5. The negotiation method according to claim 4, characterized in that: The method further comprises: Obtaining a first number of target random numbers requiring multiple rounds of negotiation; Detecting a fourth number of target random numbers generated in the current round; If the fourth number is less than the first number, each of the slave participants sends a new slave random number to the other participants; After all the slave participants have sent their new slave random numbers, the master participant determines the sample random number with a corresponding sequence number greater than and next to the first sequence number as a new second master random number, and sends the second master random number to other participants; wherein the first sequence number is the sequence number corresponding to the second master random number sent by the master participant in the previous round; Each of the slave participants verifies the second master random number. When the verification is successful, a target random number is generated through the target function based on the second master random number and all the slave random numbers sent in this round, and the process returns to execute the fourth step of detecting the currently generated target random number.
6. The negotiation method according to any one of claims 1 to 5, characterized in that: The slave party verifies the second master random number, including: The slave participant calls the one-way function to calculate a verification random number according to the second master random number; The slave participant compares whether the first master random number and the verification random number are consistent; If the first master random number and the verification random number are consistent, the slave participant determines that the verification is successful; or, if the first master random number and the verification random number are inconsistent, the slave participant determines that the verification is unsuccessful.
7. The negotiation method according to claim 1, characterized in that: The step of generating a target random number according to the second master random number and all the slave random numbers by using a preset target function known to all the participants includes: Performing an XOR operation on the second master random number and all the slave random numbers to obtain the target random number; Alternatively, a predetermined output bit width is obtained, the second master random number and all the slave random numbers are summed and the output bit width result is truncated from the tail to obtain the target random number.
8. A random number negotiation system, characterized in that: The system includes a master participant and a slave participant; The main participant is used to send a first main random number to other participants; Each of the slave participants is used to send a slave random number to other participants. After all the slave participants have finished sending the slave random numbers, the master participant sends a second master random number to other participants; wherein the first master random number is calculated from the second master random number through a one-way function that is preset and known to each of the participants; Each of the slave participants is used to verify the second master random number. When the verification is successful, the master participant and each of the slave participants are used to generate a target random number based on the second master random number and all the slave random numbers through a pre-set target function known to each of the participants.
9. The negotiation system according to claim 8, characterized in that: The main participant is also used to: Randomly select the original sample random number; According to the original sample random number, multiple new sample random numbers are calculated by iteratively calling the one-way function; Determine the sequence number corresponding to each of the sample random numbers in reverse order according to the order in which the sample random numbers are obtained; Among them, the serial number corresponding to the sample random number obtained earlier by the main participant is greater than the serial number corresponding to the sample random number obtained later.
10. The negotiation system according to claim 8, characterized in that: The slave participants are specifically used for: According to the second primary random number, calling the one-way function to calculate a verification random number; Comparing whether the first primary random number and the verification random number are consistent; If the first primary random number is consistent with the verification random number, it is determined that the verification is successful; Alternatively, if the first primary random number and the verification random number are inconsistent, it is determined that the verification fails.
