Cryptography-based random event generation method capable of proving fairness
By introducing cryptographic design and hash functions into the random number generation method, the fairness and transparency of the random number generation process are ensured, the risks of manipulation and collusion of random number generation in the prior art are solved, and efficient and safe random number generation is achieved.
Patent Information
- Application Number
- CN202411684516.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-03-11
AI Technical Summary
The existing random number generation methods have many challenges in fairness, transparency, security and anti-manipulation. Especially in centralized and decentralized systems, it is difficult to ensure the fairness and inoperability of random number generation.
A random event generation method based on cryptography is adopted to prove fairness. By registering and numbering event participants and generating random number seeds based on their identity and numbering, the unidirectionality and avalanche effect of the hash function are used to ensure the transparency and inoperability of the random number generation process.
The random number generation process is achieved with a high degree of fairness and transparency, ensuring the unpredictability and manipulation resistance of the results, reducing the trust requirements for the central system, and improving the robustness and reliability of the system.
Smart Images

Figure CN119597243A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cryptographic data processing, and in particular to a cryptographic-based method for generating random events that is provably fair. Background Art
[0002] In many application scenarios, random number generation is a key element, such as lotteries, competition draws, resource allocation, random sorting, etc., especially in decentralized application scenarios such as blockchain technology. Ensuring the fairness and non-manipulability of random number generation is crucial to maintaining the fairness and credibility of the system. However, existing random number generation methods have many challenges in terms of fairness, transparency, security, and anti-manipulation, which are mainly manifested in the following aspects:
[0003] 1. Issues with the credibility and transparency of centralized random number generation
[0004] Traditional random number generation methods rely on centralized entities (such as servers, lottery platforms, or hosting services) to provide random numbers. However, this approach has two main problems:
[0005] Trust risk: Centralized entities have complete control over the random number generation process, and external participants need to trust that they will not interfere with or manipulate the generation process. However, this trust is not always guaranteed, because the central entity may be bribed, attacked, or have internal moral risks, which may lead to the manipulation of random numbers and affect the fairness of the system.
[0006] Unverifiability: It is difficult for participants to verify whether the random number generation process is authentic and fair, because the random number generation process is usually not transparent to the outside world. Even if a centralized entity claims that its random number is fair, participants cannot independently verify it, resulting in a lack of trust in the generated results.
[0007] 2. Risk of manipulation of random number generation on the chain
[0008] In decentralized systems (such as blockchain), random number generation is usually done publicly and relies on block information (such as block hash, timestamp, block height, etc.). This information is naturally generated during the operation of the blockchain and is theoretically unpredictable to ordinary users. However, miners or verification nodes have certain control over the block generation process, leading to the following risks:
[0009] Miner manipulation risk: Since miners or verification nodes can selectively include or exclude transactions when packaging blocks, or choose to delay the time of block generation, they have the ability to influence block information and thus affect the random number generation results. This manipulation may change the results of random events (such as lotteries or resource allocation), thereby undermining the fairness of the system.
[0010] Unforeseen deviations: Although the input data for random number generation is theoretically unpredictable, due to the manipulation capabilities of miners or nodes, the results of random numbers may be biased, causing the results to not meet the expected randomness requirements.
[0011] 3. Trust and security issues of off-chain random number generation
[0012] In some scenarios, the random number generation process can be performed off-chain, and then the generated results are submitted to the system or blockchain. However, this off-chain generation method also has challenges:
[0013] Trust dependency: Random numbers generated off-chain usually rely on off-chain entities or third-party services, which requires the system to fully trust them. Since the random number generation process is carried out off-chain, the outside world cannot verify the authenticity and fairness of the random numbers, which may lead to participants questioning the random number results.
[0014] Transmission security: The random numbers generated off-chain need to be submitted to the chain or system. This transmission process may have security issues, such as communications being intercepted, data being tampered with or forged, which may cause the random number results to be changed, undermining the fairness and security of the system.
[0015] 4. Anti-collusion issues in multi-party collaboration
[0016] In random number generation scenarios involving multi-party collaboration (such as lotteries, voting, resource allocation, etc.), the security and fairness of the system depend on the honest behavior of multiple participants. However, existing random number generation methods have obvious deficiencies in anti-collusion:
[0017] Risk of multi-party collusion: If multiple participants in the system collude, or a centralized entity conspires with some participants, they may interfere with the random number generation process by working together to affect the final random result. This kind of collusion is difficult to detect and prevent, which undermines the fairness of the system.
[0018] Difficulty in anti-manipulation: The existing random number generation methods lack clear anti-manipulation mechanisms and verifiable processes, making it difficult for the system to effectively prevent multi-party collusion and malicious intervention, and unable to ensure the fairness and unpredictability of the final random number results.
[0019] It can be seen that existing random number generation methods generally face challenges such as centralized trust issues, on-chain manipulation risks, off-chain credibility and security issues, as well as the complexity and lack of anti-collusion resistance of hybrid generation methods. In order to achieve truly fair, transparent and unmanipulable random number generation in a multi-party collaborative environment, it is necessary to develop a cryptography-based method that can effectively resist manipulation and collusion, and is open, transparent and verifiable.
[0020] The present invention aims at these technical difficulties and proposes a new provably fair random event generation system. Through multi-party collaboration and cryptographic design, the system can ensure the fairness, transparency and verifiability of the random number generation process, providing a safe and reliable technical solution for the generation of various random events. Summary of the invention
[0021] In view of the above-mentioned deficiencies in the prior art, the present invention provides a random event generation method based on cryptography that can be proven to be fair.
[0022] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is:
[0023] A cryptographically provably fair random event generation method comprises the following steps:
[0024] S1. Register and number the event participants, and make the identities and unique numbers of all participants public for confirmation by all participants;
[0025] S2, generating a random number seed based on the identity and number of the participants in the S1 event and verifying the random number seed;
[0026] S3. Generate random events based on random number seeds and publish event results.
[0027] Furthermore, the S2 specifically includes the following steps:
[0028] S21. Generate a random number for each event participant, calculate the hash value of the random number and make it public;
[0029] S22, generate a system random number, calculate the hash value of the system random number and make it public at the same time;
[0030] S23. All event participants publish their own random numbers in a set order, and the system random number is used as the last random number to be published;
[0031] S24. Concatenate the random numbers of all participants into a string, generate the final random number seed and verify it.
[0032] Furthermore, the character string in S24 is represented as:
[0033] R=r1∥r2∥…∥r N ∥r sys
[0034] In the formula, R is a string, ∥ is a concatenation operation, and r N The random number corresponding to the Nth time participant, r sys It is a system random number.
[0035] Furthermore, the final random number seed in S24 is expressed as:
[0036] r final =SHA-256(R)
[0037] In the formula, r final is the final random number seed, R is a string, and SHA-256 is a one-way hash function.
[0038] Furthermore, the S3 specifically includes the following steps:
[0039] S31. Based on the random number seed obtained in S2, the system calculates a hash value for each participant or each participant calculates a hash value by himself.
[0040] S32, initialize the ordered list Q and set its initial value to empty;
[0041] S33, for each event participant's hash value, initialize the boundary of the ordered list Q, and set two pointers or indexes to point to the start and end of the ordered list Q respectively;
[0042] S34, calculating the middle position of the ordered list, and comparing the hash value of any event participant with the middle position of the ordered list, so that the ordered list remains in order;
[0043] S35. Publish the ordered list Q, and select the first w events to participate in according to the ranking in the ordered list Q.
[0044] Furthermore, the specific calculation method of the system calculating the hash value for each participant in S31 or each participant calculating the hash value by itself is:
[0045] h i =SHA-256(Number i +id i +r final )
[0046] In the formula, h i is the calculated hash value, number i The ID of the event participant. i is the identity of the event participant, r final The final random number seed.
[0047] Furthermore, the S34 specifically includes the following steps:
[0048] S341, calculate the middle position, the calculation method is:
[0049]
[0050] In the formula, low and high are the starting and ending positions of the ordered list Q, respectively, and mid is the calculated middle position;
[0051] S342, compare hash values, if the calculated hash value h i is less than mid, the end position high is set to mid-1. If the calculated hash value h i If it is greater than mid, the starting position low of the ordered list Q is set to mid+1;
[0052] S343, when the starting position low exceeds the ending position high, the calculated hash value h i Insertion at the starting position low of the sorted list keeps the sorted list Q in order.
[0053] The present invention has the following beneficial effects:
[0054] 1. High degree of fairness
[0055] Multi-party co-generation: The final random number seed r_final is generated by combining the random numbers of all participants, ensuring that no single entity can manipulate the random number results.
[0056] Honesty guarantee: As long as one participant is honest, the randomness and fairness of the final random number result can be guaranteed.
[0057] 2. Openness, transparency and verifiability
[0058] The entire process is open: Every step of the random number generation process is open to all participants, including random number submission, hash value verification, and random number seed generation.
[0059] Traceability: All relevant data can be archived and verified, ensuring process transparency and traceability of results.
[0060] 3. Resistance to manipulation and collusion
[0061] One-way property of hash function: By utilizing the one-way property and avalanche effect of hash function, even if some participants try to collude, they still cannot predict or manipulate the final random number result in advance.
[0062] Improved security: The system can ensure the fairness and security of random event generation in any scenario of multi-party collaboration.
[0063] 4. Wide applicability
[0064] Multi-scenario application: The present invention is applicable to a variety of scenarios that require random number generation, such as lotteries, resource allocation, random sorting, competition draws, etc.
[0065] Fair and transparent process: Ensure that all processes that require random event generation can be carried out in a fair and transparent manner.
[0066] 5. Low Trust Requirement
[0067] The requirements for the central system are only that it can ensure that data collection and disclosure are carried out according to procedures, and this process is carried out under the supervision of all participants, and the central system itself has very little room to manipulate the results. In other words, the present invention has extremely low trust requirements for the central system.
[0068] Reduce trust risk: Through the participation of multiple parties and the application of cryptographic algorithms, reliance on trusted third parties is avoided and trust risks are reduced.
[0069] Decentralized design: The decentralized nature of the system makes it less susceptible to centralized failures or attacks, improving the robustness and reliability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 The figure is a flow chart of a method for generating random events that is provably fair based on cryptography according to the present invention. DETAILED DESCRIPTION
[0071] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.
[0072] A cryptographically provably fair method for generating random events, such as Figure 1 As shown, the following steps are included:
[0073] S1. Register and number the event participants, and make the identities and unique numbers of all participants public for confirmation by all participants;
[0074] In this embodiment, the system includes N participants. Each participant registers in the system, submits identity information, and is assigned a unique number ranging from 1 to N. The numbers and identity information of all participants will be made public for all participants to confirm, ensuring the consistency and transparency of information.
[0075] S2, generating a random number seed based on the identity and number of the participants in the S1 event and verifying the random number seed;
[0076] In this embodiment, the following steps are specifically included:
[0077] S21. Generate a random number for each event participant, calculate the hash value of the random number and make it public;
[0078] Generate random numbers and hash values: Each participant p i Generate a random number r i , and calculate its hash value h i =Hash(r i ), where the hash function Hash() can be a one-way hash function such as SHA-256. i is made public to ensure the transparency of the random number submission process of each participant, but the actual random number r i Keep it confidential for now to prevent advance prediction.
[0079] S22, generate a system random number, calculate the hash value of the system random number and make it public at the same time;
[0080] The system generates random numbers and hash values: The system itself also generates a random number r sys , and calculate its hash value h sys =Hash(r sys ) and are also made public.
[0081] S23. All event participants publish their own random numbers in a set order, and the system random number is used as the last random number to be published;
[0082] In accordance with the predetermined order, all participants will publish their random numbers r in turn. i The system discloses the last random number r sys .
[0083] S24. Concatenate the random numbers of all participants into a string, generate the final random number seed and verify it.
[0084] Random number concatenation: Concatenate the random numbers of all participants into a string:
[0085] R=r1||r2||r3||......||r N ||r sys
[0086] Here, “||” indicates a series operation.
[0087] Get the random number seed r through a hash function (such as SHA-256) final :
[0088] r final =SHA-256(R)
[0089] S3. Generate random events based on random number seeds and publish event results.
[0090] This embodiment specifically includes the following steps:
[0091] S31. Based on the random number seed obtained in S2, the system calculates a hash value for each participant or each participant calculates a hash value by himself.
[0092] The system calculates a hash value for each participant: For each participant i, calculate its hash value h i . Each participant can also calculate their own hash value:
[0093] h i =SHA-256(Number i +id i +r final )
[0094] S32, initialize the ordered list Q and set its initial value to empty;
[0095] Define a sorted queue Q as an ordered list, where Q[i] represents the hash value of the i-th position. Initialize Q to be empty.
[0096] S33, for each event participant's hash value, initialize the boundary of the ordered list Q, and set two pointers or indexes to point to the start and end of the ordered list Q respectively;
[0097] Initialize the boundaries: set two pointers or indexes, `low = 1` and `high = |Q|`, pointing to the start and end positions of \Q respectively.
[0098] S34, calculating the middle position of the ordered list, and comparing the hash value of any event participant with the middle position of the ordered list, so that the ordered list remains in order;
[0099] Calculate middle position: Calculate middle position
[0100] Comparing hash values:
[0101] If h i If it is less than Q[mid], set `high` to `mid-1`.
[0102] If h i If it is greater than Q[mid], set `low` to `mid+1`.
[0103] In this embodiment, due to the anti-collision property of the hash function, it is impossible for h i Equal to Q[mid].
[0104] When `low` exceeds `high`, hi Insert into the `low` position of queue Q so that Q remains ordered.
[0105] S35. Publish the ordered list Q, and select the first w events to participate in according to the ranking in the ordered list Q.
[0106] The core value of the present invention is that it can provide a fair, transparent and secure random selection mechanism, which is applicable to a wide range of application scenarios. This includes resource allocation (such as lottery for house purchase, school enrollment quota), commercial activity lottery, random event generation in games, randomized controlled trials in scientific research, blockchain applications, public service allocation (such as medical resources, emergency rescue service dispatch), sports event lottery, and various projects (such as low-rent housing allocation). In the embodiment of the present invention, the random event of lottery is used for illustration.
[0107] In this embodiment, participants can use common cryptographic tools or libraries to generate random numbers and calculate hash values. To ensure fairness, the lottery process and results should be open and transparent, and all calculation steps and intermediate results should be publicly archived and verifiable by anyone.
[0108] The system can be represented by y.
[0109] Phase 1 List generation and numbering:
[0110] There are N participants. Each participant submits necessary identity information when registering. The system assigns each participant a unique number ranging from 1 to N. Let the set P = {p1, p2, ..., p N} represents all participants. The system publishes the list and number for everyone to confirm and fix the information.
[0111] Phase 2 fair random number seed generation:
[0112] Each participant p i Generate a random number r i , r i Keep it secret from others for now. And use a hash function (such as SHA-256) to calculate its hash value h i , then make it public i .
[0113] The system itself also generates a random number r sys And calculate its hash value h sys , r sys Also confidential, public sys .
[0114] All participants, including the system itself, have their public hash value h i and h sysThen, they are required to publicly disclose their real random numbers r according to a predetermined order (e.g., by number). i ,
[0115] The system must wait until the last participant discloses before disclosing its own r sys .
[0116] Everyone, including third parties, can verify all random numbers r i The corresponding hash value is h i The matching of sys and h sys If everything is OK, go to the next step.
[0117] Concatenate all the random numbers into one long string:
[0118] R=r1∥r2∥...∥r N ∥r sys
[0119] Among them, "∥" represents a series operation.
[0120] Get the random number seed r through a hash function (such as SHA-256) final :
[0121] r final =SHA-256(R)
[0122] Each participant can independently verify r final The value of .
[0123] illustrate:
[0124] According to r final Due to the one-way nature and avalanche effect of the hash function output, as long as one of the participants in the entire system does not participate in collusion, the final result system r final The randomness is guaranteed.
[0125] Even as the central entity running the system, it cannot meaningfully manipulate the random number generation and lottery results during this process. Due to the avalanche effect of the hash function, it cannot control the results of the random number. Everyone publishes the hash value of the private random number h i Afterwards, final In fact, it has been decided, but no one knows it.
[0126] The key role of the center is to fulfill the disclosure obligation as the last entity to disclose the private random number. Because the last discloser is the only one who can calculate r after everyone else has disclosed their private random number and before he has disclosed it.final The person who has the random number can perform the calculation of phase 3 in advance and know the lottery result. But he cannot change the result. The only thing he can change is not to disclose his private random number. This will directly cause the system to shut down.
[0127] Therefore, the fairness of this system does not depend on the central entity that runs the system. The role of the central entity is only to ensure that the operation of the system is not interrupted.
[0128] Phase 3: Lottery execution phase:
[0129] The random number r generated in stage 2 final As a random number seed, generate the lottery result:
[0130] 1 The system calculates a hash value for each participant: For each participant i, calculate its hash value h i . Each participant can also calculate their own hash value:
[0131] h i =SHA-256(Number i +id i +r final )
[0132] 2. Initialize sort queue Q: Define a sort queue Q as an ordered list, where Q[i] represents the hash value of the i-th position. Initialize Q to empty.
[0133] 3. Binary insertion method:
[0134] For each j i :
[0135] Initialize the boundaries: set two pointers or indexes, `low = 1` and `high = |Q|`, pointing to the start and end positions of \Q respectively.
[0136] Calculate middle position: Calculate middle position
[0137] Comparing hash values:
[0138] If h i If it is less than Q[mid], set `high` to `mid-1`.
[0139] If h i If it is greater than Q[mid], set `low` to `mid+1`.
[0140] Note that due to the anti-collision property of the hash function, it is impossible for h i Equal to Q[mid].
[0141] When `low` exceeds `high`, h i Insert into the `low` position of queue Q so that Q remains ordered.
[0142] 4. Determine the winner: Publish the sorting queue Q. And select the first w participants as the winners based on the sorting queue Q. Participants can also compare their hash values with each other and with the sorting queue Q to verify the fairness of the sorting.
[0143] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0144] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0145] 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.
[0146] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
[0147] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the present invention.
Claims
1. A cryptographically provably fair random event generation method, characterized in that: The steps include: S1. Register and number the event participants, and make the identities and unique numbers of all participants public for confirmation by all participants; S2, generating a random number seed based on the identity and number of the participants in the S1 event and verifying the random number seed; S3. Generate random events based on random number seeds and publish event results.
2. The method for generating random events based on cryptography and provably fair according to claim 1, characterized in that: The S2 specifically includes the following steps: S21. Generate a random number for each event participant, calculate the hash value of the random number and make it public; S22, generate a system random number, calculate the hash value of the system random number and make it public at the same time; S23. All event participants publish their own random numbers in a set order, and the system random number is used as the last random number to be published; S24. Concatenate the random numbers of all participants into a string, generate the final random number seed and verify it.
3. The method for generating random events based on cryptography and provably fair according to claim 2, characterized in that: The string in S24 is represented as: R=r1∥r2∥…∥r N ∥r sys In the formula, R is a string, ∥ is a concatenation operation, and r N The random number corresponding to the Nth time participant, r sys It is a system random number.
4. The method for generating random events based on cryptography and provably fair according to claim 2, characterized in that: The final random number seed in S24 is expressed as: r final =SHA-256(R) In the formula, r final is the final random number seed, R is a string, and SHA-256 is a one-way hash function.
5. The method for generating random events based on cryptography and provably fair according to claim 1, characterized in that: The S3 specifically includes the following steps: S31. Based on the random number seed obtained in S2, the system calculates a hash value for each participant or each participant calculates a hash value by himself. S32, initialize the ordered list Q and set its initial value to empty; S33, for each event participant's hash value, initialize the boundary of the ordered list Q, and set two pointers or indexes to point to the start and end of the ordered list Q respectively; S34, calculating the middle position of the ordered list, and comparing the hash value of any event participant with the middle position of the ordered list, so that the ordered list remains in order; S35. Publish the ordered list Q, and select the first w events to participate in according to the ranking in the ordered list Q.
6. A cryptography-based provably fair random event generation method according to claim 5, characterized in that: The specific calculation method of the system calculating the hash value for each participant in S31 or each participant calculating the hash value by itself is: h i =SHA-256(Number i +id i +r final ) In the formula, h i is the calculated hash value, number i The ID of the event participant. i is the identity of the event participant, r final The final random number seed.
7. The method for generating random events based on cryptography and provably fair according to claim 5, characterized in that: The S34 specifically includes the following steps: S341, calculate the middle position, the calculation method is: In the formula, low and high are the starting and ending positions of the ordered list Q, respectively, and mid is the calculated middle position; S342, compare hash values, if the calculated hash value h i is less than mid, the end position high is set to mid-1. If the calculated hash value h i If it is greater than min, the starting position low of the ordered list Q is set to mid+1; S343, when the starting position low exceeds the ending position high, the calculated hash value h i Insertion at the starting position low of the sorted list keeps the sorted list Q in order.