Random number seed generation method, apparatus, electronic device and storage medium
By having all consensus nodes in the blockchain participate in random number generation, and by storing encrypted random numbers on the blockchain and broadcasting key information, the problem of low reliability of random number results in existing technologies is solved, and the fairness and security of the random number generation process are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-31
- Publication Date
- 2026-03-10
AI Technical Summary
Existing random number generation methods are completed by only one blockchain node, resulting in low reliability of the generated random numbers and easy tampering, which fails to reflect the value of blockchain as a multi-party collaborative scenario.
By having all consensus nodes in the blockchain participate in random number generation, using encrypted random numbers stored on the chain and broadcasting key information, and processing encrypted random numbers based on preset rules and key information, a target random number seed is generated.
It improves the credibility of the random number generation process and results, ensures the fairness and security of the generation process, ensures that all consensus nodes participate in the generation, and prevents tampering.
Smart Images

Figure CN115037464B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing technology, and in particular to a method, apparatus, electronic device, and storage medium for generating random number seeds. Background Technology
[0002] With the rapid development of computer technology, random numbers have permeated all aspects of people's lives. For example, users can use verification codes issued by servers for identity verification, or use dynamic verification codes generated by web pages for identity verification.
[0003] However, existing random number generation methods often require only a user and a blockchain node to generate random numbers, which raises the possibility that the generated random number results can be tampered with. Furthermore, the fact that only one node participates in the generation of random numbers makes the generated random number results unreliable. Summary of the Invention
[0004] This disclosure provides a method, apparatus, electronic device, and storage medium for generating random number seeds, enabling all consensus nodes in a blockchain to participate in the generation of random numbers, thereby improving the reliability of the random number generation process and results.
[0005] In a first aspect, embodiments of this disclosure provide a method for generating a random number seed, the method comprising:
[0006] Upon receiving encrypted random numbers corresponding to the random number generation requests from each consensus node, the encrypted random numbers are stored on the blockchain; and,
[0007] All encrypted random numbers are sent to each consensus node, and the corresponding key information is broadcast after the consensus node receives the encrypted random numbers.
[0008] Based on preset rules and corresponding key information, the consensus node processes all received encrypted random numbers to obtain the target random number seed.
[0009] Secondly, embodiments of this disclosure also provide a random number seed generation device, the device comprising:
[0010] The data storage and transmission module is used to store the encrypted random number on the blockchain when it receives the encrypted random number corresponding to the random number generation request from each consensus node; and to send all the encrypted random numbers to each consensus node, and broadcast the corresponding key information after the consensus node receives the encrypted random number.
[0011] The random number seed acquisition module is used to process all the encrypted random numbers received by the consensus node based on preset rules and corresponding key information to obtain the target random number seed.
[0012] Thirdly, embodiments of this disclosure also provide an electronic device, the device comprising:
[0013] One or more processors;
[0014] Storage device for storing one or more programs.
[0015] When the one or more programs are executed by the one or more processors, the one or more processors implement the random number seed generation method as described in any embodiment of this disclosure.
[0016] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the random number seed generation method as described in any of the embodiments of this disclosure.
[0017] The technical solution of this embodiment, upon receiving encrypted random numbers corresponding to random number generation requests from various consensus nodes, stores these encrypted random numbers on the blockchain and sends them to each consensus node, while also broadcasting the key information corresponding to each consensus node. This allows each consensus node to process all received encrypted random numbers based on preset rules and the corresponding key information to obtain the target random number seed. Based on this technical solution, all consensus nodes in the blockchain can participate in the random number generation process, ensuring the fairness and security of the random number generation process, thereby improving the credibility of the random number generation process and its results. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the exemplary embodiments of this disclosure, the accompanying drawings used in describing the embodiments are briefly introduced below. Obviously, the accompanying drawings described are only a portion of the embodiments to be described in this disclosure, and not all of them. For those skilled in the art, other drawings can be obtained from these drawings without any creative effort.
[0019] Figure 1 A flowchart of a random number seed generation method provided in this embodiment of the disclosure;
[0020] Figure 2 A flowchart of a random number seed generation method provided in this embodiment of the disclosure;
[0021] Figure 3 This is a structural block diagram of a random number seed generation method apparatus provided in an embodiment of the present disclosure;
[0022] Figure 4This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0023] The present disclosure will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present disclosure and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the present disclosure are shown in the drawings, not the entire structure.
[0024] Example 1
[0025] Figure 1 This is a flowchart of a random number seed generation method provided in an embodiment of this disclosure. This embodiment is applicable to situations where, upon receiving a random number generation request, the random number seed is generated jointly by various nodes. This method can be executed by the random number seed generation device in this embodiment. The system can be implemented in software and / or hardware, optionally through an electronic device, such as a mobile terminal or PC. The device can be configured in a computing device or in a webpage.
[0026] Before introducing this technical solution, an illustrative application scenario can be provided. This disclosed technical solution can be applied to any scenario involving the generation of random numbers, such as mobile SMS verification codes, dynamic verification codes on web pages, and web page lotteries. For example, it can be applied to web page lotteries, where multiple random numbers are often generated. In this case, blockchain technology can be used to generate these random numbers.
[0027] It should be noted that existing random number generation methods often involve a single blockchain node receiving random number information from multiple nodes, concatenating the received random number information in chronological order, and then performing a hash operation on the concatenated information. The resulting hash value is used as the random number seed. Since all operations are performed by the same blockchain node, it is impossible to guarantee that the node is not malicious and that the results could be manipulated. Furthermore, the participants in random number generation are only the user and a single blockchain node, failing to reflect the value of blockchain as a multi-party collaborative scenario. Therefore, existing random number generation methods need to be improved. The random number seed generation method provided in this embodiment specifically includes the following steps:
[0028] S110. Upon receiving the encrypted random number corresponding to the random number generation request from each consensus node, the encrypted random number is stored on the blockchain; and all encrypted random numbers are sent to each consensus node, and the corresponding key information is broadcast after the consensus node receives the encrypted random number.
[0029] In a blockchain, a consensus node can be a special type of ordinary node. Besides performing the functions of a regular time node, a consensus node is used to reach consensus and update data. A blockchain is a chain of blocks, each storing specific information, linked together in chronological order of their creation. A random number generation request can be understood as a request sent by a requesting node to instruct the generation of random numbers. Encrypted random numbers are data obtained by encrypting the generated random numbers by the consensus node. Key information can be understood as parameters used to convert plaintext data to ciphertext data or vice versa. It's understood that for different consensus nodes, key information can be private or public, such as a private key and a public key. Key information can be used to encrypt or decrypt the generated encrypted random numbers, etc.
[0030] Specifically, after receiving the encrypted random numbers corresponding to the random number generation requests from each consensus node, the system stores the received encrypted random numbers on the blockchain and sends all received encrypted random numbers to each consensus node, while simultaneously broadcasting the corresponding key information of each consensus node. For example, each consensus node could generate encrypted random numbers, store the generated encrypted random numbers on the blockchain, and simultaneously broadcast the generated encrypted random numbers and their corresponding key information to other consensus nodes.
[0031] It should be noted that the key information is the encryption information used by consensus nodes when generating encrypted random numbers. It can be encrypted using symmetric encryption and asymmetric encryption algorithms. The specific encryption method can be preset according to the requirements. Since the key information of each consensus node may be different, after the consensus node sends the encrypted random number, each consensus node will send the corresponding key information to other consensus nodes so that other consensus nodes can decrypt the encrypted random number based on the key information.
[0032] Based on the above technical solution, before receiving the encrypted random numbers corresponding to the random number generation requests from each consensus node, the method further includes: generating the random number generation request based on the requesting node and sending it to each consensus node, so that the corresponding consensus node generates a random number to be used based on the random number generation request; processing the random number to be used into plaintext data to be stored; encrypting the corresponding plaintext data to be stored based on the key of each consensus node to obtain the encrypted random number corresponding to each consensus node, and sending each encrypted random number to the requesting node.
[0033] In this context, the requesting node can be the node that generates the random number generation request. The random number to be used can be understood as the random number generated by each consensus node based on the random number generation request, and the corresponding plaintext data to be stored can be the original random number generated by each consensus node.
[0034] Specifically, when a user needs to generate random numbers, they can send a corresponding random number generation command. Upon receiving the command, the requesting node generates a random number generation request. Alternatively, the system can automatically generate a random number generation command when pre-defined conditions are triggered, such as when a user performs a certain operation or a pre-defined time condition is met. The requesting node then sends the generated random number generation request to each consensus node, enabling each node to generate a random number to be used based on the request. The generated random number is then stored as plaintext data. After generating the random number, each consensus node encrypts it using a corresponding key to obtain an encrypted random number, which is then sent to the requesting node.
[0035] For example, when a user needs to authenticate, they can send an authentication command to the server. After receiving the command, the requesting node generates a random number generation request and sends it to each consensus node, so that each consensus node generates a corresponding random number to be used. Each consensus node encrypts the generated random number using key information to obtain an encrypted random number, and then sends the encrypted random number to the requesting node.
[0036] It should be noted that the random numbers to be used generated by each consensus node based on the random number generation request can be the same or different, and the encryption method can be symmetric encryption or asymmetric encryption. When the encryption method is symmetric encryption, each consensus node can use the same key to encrypt the random number to be used to generate an encrypted random number. When the encryption method is asymmetric encryption, each consensus node can use the public key to encrypt the random number to be used to obtain an encrypted random number.
[0037] S120. Based on preset rules and corresponding key information, the consensus node processes all received encrypted random numbers to obtain the target random number seed.
[0038] The preset rules can be pre-defined rules for processing data. The target random number seed can be understood as the initial value used to generate pseudo-random numbers.
[0039] Specifically, based on the pre-set data processing rules and the response key information, each consensus node processes all the received encrypted random numbers to obtain the target random number seed. It can be understood that in order to ensure that the random number seeds generated by each consensus node are the same, it is necessary to process the decrypted random numbers to be used according to the rules to obtain the final random number seed.
[0040] Based on the above technical solution, the step of processing all received encrypted random numbers by the consensus node based on preset rules and corresponding key information to obtain a target random number seed includes: decrypting the corresponding encrypted random numbers based on each key information to obtain plaintext information to be used corresponding to each encrypted random data; if each plaintext information is consistent with the corresponding plaintext data to be stored, then obtaining the random number to be used; and processing the random number to be used according to preset rules to obtain the target random number seed.
[0041] The plaintext information to be used can be the information obtained by decrypting the encrypted random number using the key.
[0042] Specifically, after obtaining the encrypted random numbers and key information broadcast by each consensus node, the corresponding encrypted random numbers are decrypted according to the key information of each consensus node to obtain the plaintext information to be used for each consensus node. The obtained plaintext information to be used is then matched with the already stored plaintext data to be stored. If the match is consistent, the random numbers to be used for each consensus node are obtained, and each random number to be used is processed according to the preset rules to obtain the target random number seed.
[0043] It should be noted that the preset rules include, but are not limited to, hash algorithms, VRF (Verifiable Random Functions) algorithms, etc. That is, the random number obtained by the hash algorithm can be transformed into a fixed-length output by the hash algorithm, or the random number can be processed by the VRF algorithm to obtain a verifiable pseudo-random output, etc.
[0044] Based on the above technical solution, the method further includes: determining the storage method corresponding to the target random number seed; if the storage method is interval block generation, then the target random number seed is generated periodically and stored in the corresponding block in the blockchain, so that when a random number generation request is received, the target random number seed is obtained according to the timestamp of each block.
[0045] It should be noted that different random number seed generation methods can be determined according to different needs. When users need to quickly obtain multiple random number seeds, the instant generation method will cause users to wait too long, making it impossible for users to obtain the required random number seeds immediately, thereby reducing the user experience. Therefore, different random number seed generation methods will exist to meet different user needs.
[0046] The storage method can be a method used to store the random number seed. The timestamp can be understood as the digital signature data corresponding to a block in the blockchain and the digital signature data of the generated random number seed. It's important to understand that since each block and random number seed is generated at a different time, the timestamps of different blocks and different random number seeds are completely different.
[0047] Specifically, if the current target random number seed is stored using interval block generation, meaning multiple random number seeds may need to be provided to the user simultaneously, then random number seeds are generated periodically according to a preset method and stored in the corresponding blocks. Upon receiving a random number generation request, the target random number seed can be retrieved based on the timestamps corresponding to each block and the random number seed. For example, to improve the efficiency of random number generation, a random number seed can be generated every n blocks and stored in the (n+1)th block. Then, upon receiving a random number generation request, the random number seed can be retrieved sequentially based on the preset interval and the timestamps corresponding to each block and random number seed.
[0048] Based on the above technical solution, it further includes: if the storage method is to determine and store the target random number seed when a random number generation request is received, then determine the target random number seed corresponding to the random number generation request and store it on the blockchain.
[0049] Specifically, if the current random number seed generation method is to generate and store the random number seed upon receiving a random number generation request, then the target random number seed corresponding to the random number generation request is generated according to a preset method, and the generated random number seed is stored in the blockchain.
[0050] The technical solution of this disclosure provides a variety of random number seed storage methods, with different storage methods corresponding to different random number seed generation methods. This allows the solution to meet user needs under different requirements, thereby improving the generation efficiency of random number seeds.
[0051] Based on the above technical solution, it also includes: broadcasting the target random number seed corresponding to each consensus node to other consensus nodes.
[0052] Specifically, each consensus node, after receiving the encrypted random number and corresponding key from other consensus nodes, can process the encrypted random number according to the key and preset rules to obtain the target random number seed. After generating the target random number seed, it is broadcast to other nodes.
[0053] It should be noted that, since the random number generation method provided in this embodiment only involves blockchain nodes and no external factors intervene, the generation process is completely recorded on the chain and bound to the consensus mechanism of the blockchain network, ensuring complete distribution and full traceability. Therefore, in order to ensure the correctness of the random number seeds generated by each consensus node, it is necessary to broadcast the random number seeds generated by each consensus node to other nodes.
[0054] Based on the above technical solutions, it is possible to combine Figure 2 The technical solution disclosed herein will be further described, such as... Figure 2 As shown, users can choose the random number generation method according to their needs. Users can choose between instant generation or pre-generation. When the user chooses instant generation, the requesting node, upon receiving a request to generate random numbers from an external source, broadcasts the request to all other consensus nodes. The other consensus nodes generate random numbers *r*, form plaintext information according to a specified format, and encrypt it using a symmetric encryption key or an asymmetric encryption public key through the information processing module to obtain *R*. It should be noted that the specified format is set by the user according to their needs. To ensure the consistency of the generated information format, the format for the plaintext information generated by each consensus node needs to be pre-defined. Each consensus node then sends R to the requesting node. After collecting all R values, the requesting node broadcasts or writes all R values directly into a block and sends them to all consensus nodes. Each consensus node, upon receiving all R values, broadcasts or writes them directly into a block and sends its symmetric key or private key to other nodes. Other nodes, after receiving the keys from each node, first decrypt all R values to obtain plaintext information, discard information that does not conform to the specified plaintext format, obtain all random numbers, and then process the random numbers according to preset rules to obtain a random number seed S, which is then broadcast to other nodes. When a user needs to generate multiple random number seeds in advance, the specific method for generating random number seeds is consistent with the method for generating them on the fly. However, after obtaining the random number seeds, the requesting node will encrypt the obtained random number seeds again and store the encrypted random number seeds in the block. It should be noted that, to ensure fairness in the random number seed generation process, the technical solution provided in this embodiment also changes the requesting node according to preset rules. The preset rules can be determined by the user according to their needs, such as meeting a preset duration or meeting the required number of random number seeds to be generated.
[0055] The technical solution of this embodiment, upon receiving encrypted random numbers corresponding to random number generation requests from various consensus nodes, stores these encrypted random numbers on the blockchain and sends them to each consensus node, while also broadcasting the key information corresponding to each consensus node. This allows each consensus node to process all received encrypted random numbers based on preset rules and the corresponding key information to obtain the target random number seed. Based on this technical solution, all consensus nodes in the blockchain can participate in the random number seed generation process, ensuring the fairness and security of the random number seed generation process, thereby improving the credibility of the random number seed generation process.
[0056] Example 2
[0057] Figure 3 This is a structural block diagram of a random number seed generation device provided in an embodiment of the present disclosure. The system includes: a data storage and transmission module 310 and a random number seed acquisition module 320.
[0058] The data storage and transmission module 310 is used to store the encrypted random number on the blockchain when it receives the encrypted random number corresponding to the random number generation request from each consensus node; and to send all the encrypted random numbers to each consensus node, and broadcast the corresponding key information after the consensus node receives the encrypted random number.
[0059] The random number seed acquisition module 320 is used to process all the encrypted random numbers received by the consensus node based on preset rules and corresponding key information to obtain the target random number seed.
[0060] Based on the above technical solution, the device further includes:
[0061] The information processing module is used to generate a random number generation request based on the requesting node and send it to each consensus node so that the corresponding consensus node generates a random number to be used based on the random number generation request; processes the random number to be used into plaintext data to be stored; encrypts the corresponding plaintext data to be stored based on the key of each consensus node to obtain an encrypted random number corresponding to each consensus node, and sends each encrypted random number to the requesting node.
[0062] Based on the above technical solution, the random number seed acquisition module includes:
[0063] The plaintext information acquisition unit is used to decrypt the corresponding encrypted random numbers based on each key information to obtain the plaintext information to be used corresponding to each encrypted random data.
[0064] The random number acquisition unit is used to acquire a random number if each piece of plaintext information matches the corresponding plaintext data to be stored.
[0065] The target random number seed generation unit is used to process the random number to be used according to a preset rule to obtain the target random number seed.
[0066] Based on the above technical solution, the device further includes:
[0067] The storage method determination module is used to determine the storage method corresponding to the target random number seed; if the storage method is interval block generation, the target random number seed is generated periodically and stored in the corresponding block in the blockchain, so that when a random number generation request is received, the target random number seed is obtained according to the timestamp of each block.
[0068] Based on the above technical solution, the storage method determination module is further configured to: if the storage method is to determine and store the target random number seed when a random number generation request is received, then determine the target random number seed corresponding to the random number generation request and store it on the blockchain.
[0069] Based on the above technical solution, the random number seed acquisition module is also used to: broadcast the target random number seed corresponding to each consensus node to other consensus nodes.
[0070] Based on the above technical solution, the random number seed generation device is applied in scenarios of generating random numbers.
[0071] The technical solution of this embodiment, upon receiving encrypted random numbers corresponding to random number generation requests from various consensus nodes, stores these encrypted random numbers on the blockchain and sends them to each consensus node, while also broadcasting the key information corresponding to each consensus node. This allows each consensus node to process all received encrypted random numbers based on preset rules and the corresponding key information to obtain the target random number seed. Based on this technical solution, all consensus nodes in the blockchain can participate in the random number seed generation process, ensuring the fairness and security of the random number seed generation process, thereby improving the credibility of the random number seed generation process.
[0072] The random number seed generation apparatus provided in this disclosure can execute the random number seed generation method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects of executing the method.
[0073] It is worth noting that the various units and modules included in the above system are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of this disclosure.
[0074] Example 3
[0075] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Figure 4 A block diagram is shown of an exemplary electronic device 40 suitable for implementing embodiments of the present disclosure. Figure 4 The electronic device 40 shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments disclosed herein.
[0076] like Figure 4 As shown, electronic device 40 is represented in the form of a general-purpose computing device. The components of electronic device 40 may include, but are not limited to: one or more processors or processing units 401, system memory 402, and bus 403 connecting different system components (including system memory 402 and processing unit 401).
[0077] Bus 403 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0078] Electronic device 40 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by electronic device 40, including volatile and non-volatile media, removable and non-removable media.
[0079] System memory 402 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 404 and / or cache memory 405. Electronic device 40 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 406 may be used to read and write non-removable, non-volatile magnetic media (… Figure 4 Not shown; usually referred to as a "hard drive"). Although Figure 4Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 403 via one or more data media interfaces. Memory 402 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of this disclosure.
[0080] A program / utility 408 having a set (at least one) of program modules 407 may be stored, for example, in memory 402. Such program modules 407 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 407 typically perform the functions and / or methods described in the embodiments of this disclosure.
[0081] Electronic device 40 can also communicate with one or more external devices 409 (e.g., keyboard, pointing device, display 410, etc.), and with one or more devices that enable a user to interact with the electronic device 40, and / or with any device that enables the electronic device 40 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 411. Furthermore, electronic device 40 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 412. As shown, network adapter 412 communicates with other modules of electronic device 40 via bus 403. It should be understood that, although... Figure 4 As not shown, other hardware and / or software modules may be used in conjunction with electronic device 40, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0082] The processing unit 401 executes various functional applications and data processing by running programs stored in the system memory 402, such as implementing the random number seed generation method provided in the embodiments of this disclosure.
[0083] Example 4
[0084] This disclosure also provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform a random number seed generation method. The method includes:
[0085] Upon receiving encrypted random numbers corresponding to the random number generation requests from each consensus node, the encrypted random numbers are stored on the blockchain; and,
[0086] All encrypted random numbers are sent to each consensus node, and the corresponding key information is broadcast after the consensus node receives the encrypted random numbers.
[0087] Based on preset rules and corresponding key information, the consensus node processes all received encrypted random numbers to obtain the target random number seed.
[0088] The computer storage medium of this disclosure can be any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0089] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0090] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including—but not limited to—wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0091] Computer program code for performing the operations of embodiments of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0092] Note that the above description is merely a preferred embodiment and the technical principles employed in this disclosure. Those skilled in the art will understand that this disclosure is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of this disclosure. Therefore, although this disclosure has been described in detail through the above embodiments, it is not limited to the above embodiments. Many other equivalent embodiments may be included without departing from the concept of this disclosure, and the scope of this disclosure is determined by the scope of the appended claims.
Claims
1. A random number seed generation method characterized by comprising: Applied in a blockchain, comprising: Upon receiving the encrypted random numbers corresponding to the random number generation request fed back by each consensus node, store the encrypted random numbers on the chain; and Send all encrypted random numbers to each consensus node, and broadcast the corresponding key information after the consensus nodes receive the encrypted random numbers; Based on a preset rule and the corresponding key information, process all the encrypted random numbers received by the consensus nodes to obtain a target random number seed; Wherein, the preset rule is a hash algorithm or a VRF algorithm; When the preset rule is the hash algorithm, the processing of the encrypted random numbers received by the consensus nodes to obtain a target random number seed comprises: transforming the encrypted random numbers into fixed-length outputs through a hash algorithm by the hash algorithm; When the preset rule is the VRF algorithm, the processing of the encrypted random numbers received by the consensus nodes to obtain a target random number seed comprises: processing the encrypted random numbers to obtain a verifiable pseudo-random output by the VRF algorithm; Determine the storage mode corresponding to the target random number seed; If the storage mode is interval block generation, periodically generate a target random number seed and store it in the corresponding block in the blockchain, so that when a random number generation request is received, the target random number seed can be obtained according to the time stamp of each block, wherein the time stamp is the digital signature data of the block in the blockchain and the digital signature data of the generated random number seed.
2. The method of claim 1, wherein, Before receiving the encrypted random numbers corresponding to the random number generation request fed back by each consensus node, it also comprises: Based on the request node, generate the random number generation request and send it to each consensus node, so that the corresponding consensus node generates a to-be-used random number based on the random number generation request; Process the to-be-used random number into to-be-stored plaintext data; Based on the key of each consensus node, encrypt the corresponding to-be-stored plaintext data to obtain the encrypted random number corresponding to each consensus node, and send each encrypted random number to the request node.
3. The method of claim 1, wherein, The processing of the encrypted random numbers received by the consensus nodes to obtain a target random number seed based on a preset rule and the corresponding key information comprises: Based on each key information, decrypt the corresponding encrypted random number to obtain the to-be-used plaintext information corresponding to each encrypted random data; If each plaintext information is consistent with the corresponding to-be-stored plaintext data, obtain the to-be-used random number; Process the to-be-used random number according to the preset rule to obtain a target random number seed.
4. The method of claim 1, wherein, It also comprises: If the storage mode is to determine the target random number seed and store when receiving the random number generation request, determine the target random number seed corresponding to the random number generation request and store it on the chain.
5. The method of claim 1, wherein, It also comprises: Broadcast the target random number seed corresponding to each consensus node to other consensus nodes.
6. The method according to any one of claims 1 to 5, characterized in that, The method is applied in the scene of generating random numbers.
7. A random number seed generating apparatus characterized by comprising: Comprising: A data storage and sending module for storing the encrypted random numbers on the chain when receiving the encrypted random numbers corresponding to the random number generation request fed back by each consensus node; and, for sending all encrypted random numbers to each consensus node, and broadcasting corresponding key information after the consensus node receives the encrypted random numbers; a random number seed obtaining module, configured to process all received encrypted random numbers based on a preset rule and corresponding key information, to obtain a target random number seed; wherein, the preset rule is a hash algorithm or a VRF algorithm; the random number seed obtaining module is configured to, when the preset rule is the hash algorithm, transform the encrypted random number into a fixed-length output through a hash algorithm by using the hash algorithm; the random number seed obtaining module is configured to, when the preset rule is the VRF algorithm, process the encrypted random number by using the VRF algorithm to obtain a verifiable pseudo-random output; the device further comprises a storage mode determining module, configured to determine a storage mode corresponding to the target random number seed; if the storage mode is interval block generation, the target random number seed is generated periodically and stored in a corresponding block in the blockchain; and when a random number generation request is received, the target random number seed is obtained according to a timestamp of each block, wherein the timestamp is digital signature data of a block in the blockchain and digital signature data of the generated random number seed.
8. An electronic device, comprising: The device comprises: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the random number seed generation method of any one of claims 1-6.
9. A computer readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the random number seed generation method of any one of claims 1-6.
Citation Information
Patent Citations
Method for generating random number based on blockchain smart contract
CN110865793A
Consensus system and method of block chain
CN112734576A