Method and system for generating random number based on decentralized verifiable delay function
1. A method for generating random numbers based on a decentralized verifiable delay function, applied to a blockchain system comprising a plurality of user nodes, the method comprising:
the user nodes determine modulus parameters based on the selected RSA moduli, determine at least one block-out time as a time parameter, and write the modulus parameters and the time parameter into an excitation contract as public parameters;
starting at a preset number of blocks based on the block height specified by the excitation contract: each user node calculates a respective generated random number based on a verifiable delay function VDF using public parameters in the incentive contract;
and the user node which calculates the random number firstly sends the calculation result and the certificate to the excitation contract for verification, and the random number calculated by the user node is taken as the random number generated at this time after the verification is passed.
2. The method as claimed in claim 1, wherein the determining, by the plurality of user nodes, the modulus parameter based on the selected plurality of RSA moduli specifically comprises:
and the user nodes determine the product of the selected RSA moduli as a modulus parameter.
3. The method as claimed in claim 1, wherein the determining, by the plurality of user nodes, the modulus parameter based on the selected plurality of RSA moduli specifically comprises:
and the plurality of user nodes obtain the modulus parameter based on the average of the selected RSA moduli.
4. A method as claimed in any one of claims 1 to 3, wherein the plurality of RSA moduli are RSA moduli of root certificates voted by the plurality of user nodes.
5. A method according to any of claims 1-3, wherein each user node calculates a respective generated random number based on a verifiable delay function VDF using public parameters in the incentive contract, in particular comprising:
each user node calculates a respective generated random number using the following formula:
wherein, N is a modulus parameter in the public parameters, T is a time parameter in the public parameters, x is a hash of a block corresponding to the user node, and y is a random number generated by the user node.
6. A system for generating random numbers based on a decentralized verifiable delay function, comprising a plurality of user nodes, wherein,
the user nodes determine modulus parameters based on the selected RSA moduli, determine at least one block-out time as a time parameter, and write the modulus parameters and the time parameter into an excitation contract as public parameters;
starting at a preset number of blocks based on the block height specified by the excitation contract: each user node calculates a respective generated random number based on a verifiable delay function VDF using public parameters in the incentive contract;
and the user node which calculates the random number firstly sends the calculation result and the certificate to the excitation contract for verification, and the random number calculated by the user node is taken as the random number generated at this time after the verification is passed.
7. The system as claimed in claim 6, wherein the plurality of user nodes are specifically configured to determine a product of the selected RSA moduli as the modulus parameter when determining the modulus parameter based on the selected RSA moduli.
8. The system as claimed in claim 6, wherein the plurality of user nodes are specifically configured to obtain the modulus parameter by averaging based on the selected RSA moduli when determining the modulus parameter based on the selected RSA moduli.
9. The system as claimed in any one of claims 6 to 8, wherein the plurality of RSA moduli are RSA moduli of root certificates picked by the plurality of user nodes by voting.
10. The system according to any of claims 6-8, wherein each user node, when calculating the respective generated random number based on the verifiable delay function VDF using the public parameters in the incentive contract, is specifically configured to calculate the respective generated random number using the following formula:
wherein, N is a modulus parameter in the public parameters, T is a time parameter in the public parameters, x is a hash of a block corresponding to the user node, and y is a random number generated by the user node.
11. An electronic device comprises
A processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to perform the method steps performed by the user node of any of claims 1-5.
12. A computer readable storage medium storing one or more programs which, when executed by an electronic device comprising a plurality of application programs, cause the electronic device to perform the method steps of any of claims 1-5.
Background
The blockchain is a decentralized and innovative solution for solving the multi-party trust problem by using a distributed book technology, and is a leading-edge technology of the current society.
The generation of random numbers in the field of block chains is a key technology, and the essence of various consensus algorithms is the problem of randomly selecting blockmen, wherein the randomness is verified by nodes of the whole network and cannot be manipulated.
However, the conventional consensus algorithm still has the problem of centralization, and cannot ensure the absolute decentration effect, so a new random number generation scheme is needed to solve the defect of centralization.
Disclosure of Invention
It is an object of one or more embodiments of the present specification to provide a method and system for generating random numbers based on a decentralized verifiable delay function, so as to ensure that the verifiable delay function generates random numbers in a decentralized manner through modulus parameters determined by a distributed modulus.
To solve the above technical problem, one or more embodiments of the present specification are implemented as follows:
in a first aspect, a method for generating random numbers based on a decentralized verifiable delay function is provided, which is applied to a blockchain system including a plurality of user nodes, and the method includes:
the user nodes determine modulus parameters based on the selected RSA moduli, determine at least one block-out time as a time parameter, and write the modulus parameters and the time parameter into an excitation contract as public parameters;
starting at a preset number of blocks based on the block height specified by the excitation contract: each user node calculates a respective generated random number based on a verifiable delay function VDF using public parameters in the incentive contract;
and the user node which calculates the random number firstly sends the calculation result and the certificate to the excitation contract for verification, and the random number calculated by the user node is taken as the random number generated at this time after the verification is passed.
In a second aspect, a system for generating random numbers based on a decentralized verifiable delay function is proposed, comprising a plurality of user nodes, wherein,
the user nodes determine modulus parameters based on the selected RSA moduli, determine at least one block-out time as a time parameter, and write the modulus parameters and the time parameter into an excitation contract as public parameters;
starting at a preset number of blocks based on the block height specified by the excitation contract: each user node calculates a respective generated random number based on a verifiable delay function VDF using public parameters in the incentive contract;
and the user node which calculates the random number firstly sends the calculation result and the certificate to the excitation contract for verification, and the random number calculated by the user node is taken as the random number generated at this time after the verification is passed.
In a third aspect, an electronic device is provided, including:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to perform the method steps performed by the user node.
In a fourth aspect, a computer-readable storage medium is presented, storing one or more programs which, when executed by an electronic device comprising a plurality of application programs, cause the electronic device to perform the method steps of:
as can be seen from the technical solutions provided by one or more embodiments of the present disclosure, when a user node in a blockchain network generates a random number using a VDF, a modulus parameter serving as a public parameter in an excitation contract may be determined based on a plurality of RSA moduli selected, so that the modulus in the excitation contract is not determined by a single modulus, but is determined by a plurality of RSA moduli together through multiplication or averaging, so that the modulus parameter used in calculating the VDF is not centrally controlled, and the decentralization degree of the random number generation scheme is effectively ensured.
Drawings
In order to more clearly illustrate one or more embodiments or prior art solutions of the present specification, reference will now be made briefly to the attached drawings, which are needed in the description of one or more embodiments or prior art, and it should be apparent that the drawings in the description below are only some of the embodiments described in the specification, and that other drawings may be obtained by those skilled in the art without inventive exercise.
Fig. 1 is a schematic diagram of a scenario architecture according to an embodiment of the present specification.
Fig. 2 is a schematic diagram illustrating steps of a method for generating random numbers based on a decentralized verifiable delay function according to an embodiment of the present disclosure.
Fig. 3 is a schematic structural diagram of a system for generating random numbers based on a decentralized verifiable delay function according to an embodiment of the present disclosure.
Fig. 4 is a schematic structural diagram of an electronic device provided in an embodiment of the present specification.
Detailed Description
In order to make the technical solutions in the present specification better understood, the technical solutions in one or more embodiments of the present specification will be clearly and completely described below with reference to the accompanying drawings in one or more embodiments of the present specification, and it is obvious that the one or more embodiments described are only a part of the embodiments of the present specification, and not all embodiments. All other embodiments that can be derived by a person skilled in the art from one or more of the embodiments described herein without making any inventive step shall fall within the scope of protection of this document.
It should be understood that at present, the most extensive workload proves that the PoW-type consensus algorithm is calculated by setting a hash problem, who calculates out who has the block right first, and the probability of winning out by a person with high calculation is high, so that the block-out person can be ensured to be randomly selected, and the random performance is verified through the whole network. However, the random number generation scheme has two disadvantages, one is that the power competition brings huge power consumption and causes resource waste; secondly, because the appearance of an ore machine and an ore pond, ordinary people are difficult to participate in the ore digging process, the centralization degree is damaged. In order to solve the two problems, other consensus algorithms represented by rights and interests PoS appear, however, the consensus algorithms still need to concentrate certain resources, and the problem of incomplete decentralization still exists.
Thus, the present application introduces a verifiable delay function VDF, which in fact means that a random number can be generated by computing a function, which takes a certain amount of time, and which cannot be accelerated by parallel computing, the result of which is verifiable and easy to verify. In the application, different from the centrally-arranged VDF in the prior art, the scheme for generating the random number by the VDF is realized based on decentralized processing through distributed processing of the model parameter in the public parameter in the excitation contract used by the VDF.
Referring to fig. 1, a scenario architecture according to an embodiment of the present disclosure is shown, where the scenario architecture may be used in a basic consensus scenario, and further may be used in a random number generation scenario. In the scene, a plurality of user nodes A participate in the consensus of the block chain network B, the user node which calculates the VDF result firstly in the consensus process sends the calculation result and the certificate to an excitation contract for verification, and the user node is used as the random number generated this time after the verification is passed.
The details of the modified embodiments of the present application are described below by way of specific examples.
Example one
Referring to fig. 2, a schematic diagram of steps of a method for generating random numbers based on a decentralized verifiable delay function according to an embodiment of the present disclosure is applied to a block chain system including a plurality of user nodes, where the method may include the following steps:
step 202: the plurality of user nodes determine modulus parameters based on the selected RSA moduli, determine at least one block-out time as a time parameter, and write the modulus parameters and the time parameter into an excitation contract as public parameters.
Optionally, in this embodiment of the present application, when the multiple user nodes determine the modulus parameter based on the selected multiple RSA moduli, the following manner may be adopted:
the first method is as follows: and the user nodes determine the product of the selected RSA moduli as a modulus parameter.
The second method comprises the following steps: and the plurality of user nodes obtain the modulus parameter based on the average of the selected RSA moduli.
In this way, the modulus parameter in the public parameter used for calculating the VDF in the excitation contract is not determined by a single certain modulus, but is determined by a plurality of RSA moduli together through multiplication or averaging, so that the modulus parameter used for calculating the VDF is not centrally controlled, and the decentralization degree of the random number generation scheme is effectively ensured.
Further, the plurality of RSA moduli are RSA moduli of root certificates selected by the plurality of user nodes in a voting manner. Therefore, the RSA moduli used for determining the modulus parameters are selected by the user nodes in a voting mode, and the randomness of the determined RSA moduli is ensured, so that the decentralization thought is better fitted, and the subsequent determination of random numbers is facilitated.
For example, RSA modulus N of three root CA certificates is selected by voting1,N2,N3Calculating N ═ N1*N2*N3. Meanwhile, the time parameter may be set to be related to the block-out time of 5 blocks (theoretically, greater than the block-out time of one block). The determined modulus parameter N and the time parameter T are then written as public parameters into the excitation contract.
Step 204: starting at a preset number of blocks based on the block height specified by the excitation contract: each user node calculates a respective generated random number based on a verifiable delay function VDF using public parameters in the incentive contract.
It should be understood that the excitation contract specifies that, starting from a block of height k, every m blocks are rewarded with a random number generated by the verifiable delay function VDF, the input x of each round of VDF being the hash of this block.
In this embodiment, in the step 204, each user node is specifically configured to calculate the respective generated random number using the following formula when calculating the respective generated random number based on the verifiable delay function VDF using the public parameter in the incentive contract:
wherein, N is a modulus parameter in the public parameters, T is a time parameter in the public parameters, x is a hash of a block corresponding to the user node, and y is a random number generated by the user node.
Therefore, the problem that more power resources are consumed in the prior art can be solved by using the VDF to calculate the random number, and the analog-to-digital parameter in the public parameter is determined by the plurality of RSA analog-to-digital determined in the voting mode, so that the centralization problem is well solved.
Step 206: and the user node which calculates the random number firstly sends the calculation result and the certificate to the excitation contract for verification, and the random number calculated by the user node is taken as the random number generated at this time after the verification is passed.
In fact, step 206 can be implemented in the existing verification manner, i.e. by calculating the result And certifyAnd sending the result to an incentive contract for result verification, and giving a reward to the user node after the verification is passed, so that the user node calculates the generated y as a random source, namely a random number, of the time. Wherein:, ii is the proof used in the verification, and μiIs a proof component, which is reduced in computation by way of dimension reduction at the time of verificationAmount of the compound (A).
In essence, when validating based on an incentive contract, a user node may prove to the incentive contract that a tuple (x, y) satisfiesThe user node sends the incentive contract firstThe excitation contract computation tuple (x ', y') -xrμ,μry), wherein r ═ hash ((x, y), μ), ifThe result is, then,and if so, otherwise,it is not true. Therefore, the current time parameter is reduced to T/2, the calculation amount is reduced, and the calculation result can be verified by repeating the process log (T).
Through the technical scheme, when the user node in the block chain network generates the random number by using the VDF, the modulus parameter serving as the public parameter in the excitation contract can be determined based on the selected multiple RSA moduli, so that the modulus in the excitation contract is not determined by a single certain modulus, but is determined by the multiple RSA moduli together in a mode of multiplication, averaging or the like, the modulus parameter used in the VDF calculation is not centrally controlled, and the decentralization degree of the random number generation scheme is effectively ensured.
Example two
Referring to fig. 3, for the system for generating random numbers based on a decentralized verifiable delay function provided in the embodiments of the present description, the system 300 may include: a plurality of user nodes 302 that may participate in transactions of a blockchain network 304 based on intelligent contracts. Wherein the content of the first and second substances,
the user nodes 302 determine a modulus parameter based on the selected RSA moduli, determine at least one block-out time as a time parameter, and write the modulus parameter and the time parameter as public parameters into an excitation contract;
starting at a preset number of blocks based on the block height specified by the excitation contract: each user node 302 calculates a respective generated random number based on a verifiable delay function VDF using public parameters in the incentive contract;
the user node 302 which calculates the random number first sends the calculation result and the certificate to the excitation contract for verification, and after the verification is passed, the random number calculated by the user node is used as the random number generated this time.
Optionally, as an embodiment, when determining the modulus parameter based on the selected RSA moduli, the user nodes are specifically configured to determine a product of the selected RSA moduli as the modulus parameter.
Optionally, in a specific implementation manner of the embodiment of the present specification, when determining the modulus parameter based on the selected multiple RSA moduli, the multiple user nodes are specifically configured to obtain the modulus parameter based on averaging of the selected multiple RSA moduli.
Optionally, in another specific implementation manner of the embodiment of the present specification, the RSA moduli are RSA moduli of root certificates chosen by the user nodes in a voting manner.
Optionally, in another specific implementation manner of the embodiment of this specification, when calculating the respective generated random number based on the verifiable delay function VDF by using the public parameter in the incentive contract, each user node is specifically configured to calculate the respective generated random number by using the following formula:
wherein, N is a modulus parameter in the public parameters, T is a time parameter in the public parameters, x is a hash of a block corresponding to the user node, and y is a random number generated by the user node.
Through the technical scheme, when the user node in the block chain network generates the random number by using the VDF, the modulus parameter serving as the public parameter in the excitation contract can be determined based on the selected multiple RSA moduli, so that the modulus in the excitation contract is not determined by a single certain modulus, but is determined by the multiple RSA moduli together in a mode of multiplication, averaging or the like, the modulus parameter used in the VDF calculation is not centrally controlled, and the decentralization degree of the random number generation scheme is effectively ensured.
EXAMPLE III
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. Referring to fig. 4, at a hardware level, the electronic device includes a processor, and optionally further includes an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory, such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, the network interface, and the memory may be connected to each other via an internal bus, which may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 4, but that does not indicate only one bus or one type of bus.
And the memory is used for storing programs. In particular, the program may include program code comprising computer operating instructions. The memory may include both memory and non-volatile storage and provides instructions and data to the processor.
The processor reads a corresponding computer program from the nonvolatile memory into the memory and then runs the computer program to form a block chain node (i.e., a user node) on a logic level. A processor executing a program stored in the memory and specifically configured to perform the method steps described in fig. 2.
The method performed by the apparatus according to the embodiment shown in fig. 2 of the present specification can be applied to or implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. The methods, steps, and logic blocks disclosed in one or more embodiments of the present specification may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with one or more embodiments of the present disclosure may be embodied directly in hardware, in a software module executed by a hardware decoding processor, or in a combination of the hardware and software modules executed by a hardware decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor.
The electronic device may also execute the method of fig. 2 and implement the functions of the corresponding apparatus in the embodiment shown in fig. 2, which are not described herein again in this specification.
Of course, besides the software implementation, the electronic device of the embodiment of the present disclosure does not exclude other implementations, such as a logic device or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or a logic device.
Through the technical scheme, when the user node in the block chain network generates the random number by using the VDF, the modulus parameter serving as the public parameter in the excitation contract can be determined based on the selected multiple RSA moduli, so that the modulus in the excitation contract is not determined by a single certain modulus, but is determined by the multiple RSA moduli together in a mode of multiplication, averaging or the like, the modulus parameter used in the VDF calculation is not centrally controlled, and the decentralization degree of the random number generation scheme is effectively ensured.
Example four
This specification embodiment also proposes a computer readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a portable electronic device comprising a plurality of application programs, are capable of causing the portable electronic device to perform the method of the embodiment shown in fig. 2.
In the technical scheme of the specification, when a user node in a block chain network generates a random number by using a VDF, a modulus parameter serving as a public parameter in an excitation contract can be determined based on a plurality of selected RSA moduli, so that the modulus in the excitation contract is not determined by a single modulus, but is determined by a plurality of RSA moduli together in a mode of multiplication or averaging and the like, the modulus parameter used in the VDF calculation is not centrally controlled, and the decentralization degree of the random number generation scheme is effectively ensured.
In short, the above description is only a preferred embodiment of the present disclosure, and is not intended to limit the scope of the present disclosure. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present specification shall be included in the protection scope of the present specification.
The system, apparatus, module or unit illustrated in one or more of the above embodiments may be implemented by a computer chip or an entity, or by an article of manufacture with a certain functionality. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.