Random number generation method and device and electronic equipment
By building a computing service for generating time proofs on the blockchain, ensuring the credibility of random number generation, the problem of low credibility in traditional methods is solved, and a more fair and reliable random number generation process is achieved.
Patent Information
- Application Number
- CN202411662593.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-11-20
AI Technical Summary
The traditional random number generation method on blockchain has the problem of low credibility, especially when blockchain nodes or validators can give up or delay unfavorable transactions.
By constructing a first computing service for generating a start time proof and a second computing service for generating an end time proof, it is ensured that at least two random number generators generate random numbers based on the time proof generated by these services, and generate sub-random numbers through a verifiable random function, which is ultimately verified and recorded on the blockchain.
It enhances the credibility of random number generation, prevents blockchain nodes from maliciously delaying or ignoring transactions, thereby ensuring that there is a valid time proof of each random number submission and block generation process.
Smart Images

Figure CN119512504A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology; specifically, to a random number generation method, device and electronic device. Background Art
[0002] Generating credible and verifiable random numbers based on the Verifiable Random Function (VRF) on the blockchain plays a vital role in ensuring the fairness of blockchain randomness services (such as lotteries, NFT casting, and packager selection).
[0003] However, the current method of generating random data based on VRF, although it solves the reliability of the random data source, cannot solve the malicious space for blockchain nodes to package transactions; specifically, it is generally necessary to collect enough random numbers and write them into the on-chain contract for aggregation, but in this case, blockchain nodes or validators can abandon transactions that are not favorable to them, or delay packaging and block entry, which ultimately affects the generation results of random numbers.
[0004] It can be seen that the traditional on-chain random number generation method has the problem of low credibility. Summary of the invention
[0005] In order to solve the above technical problems, the embodiments of the present application provide a random number generation method, device and electronic device, which solve the problem of low credibility of the random number generation method on the chain in the related art.
[0006] According to one aspect of an embodiment of the present application, a random number generation method is provided, the method comprising: constructing a first computing service for generating a start time proof and a second computing service for generating an end time proof; when there is a random number collection request in a random number collection contract on a blockchain, at least two random number generators generate a transaction start time corresponding to the random number collection request according to the first computing service, generate a sub-random number according to a verifiable random function, and generate a transaction end time corresponding to the random number collection request according to the second computing service; the random number generator generates a random number according to the transaction start time, the sub-random number and the transaction end time, submits the transaction and submits it to an on-chain node, so that the on-chain node successfully verifies the trustworthiness of the sub-random number The random number submission transaction is then written into the local transaction pool; when the on-chain node creates a new block, the block creation time corresponding to the new block is generated according to the first computing service, and the block packaging time corresponding to the new block is generated according to the second computing service after the random number to be packaged is obtained from the local transaction pool and the submission transaction is obtained; the consensus node verifies the new block according to the transaction start time, the transaction end time, the block creation time and the block packaging time, and writes the new block into the blockchain when the verification passes; when the block creation time of the new block in the blockchain is greater than the random number collection termination time in the random number collection request, the random number collection contract aggregates the collected sub-random numbers according to the random number aggregation method to generate the target random number.
[0007] Optionally, constructing a first computing service for generating a start time proof includes: generating a computing process based on the received request parameters; using the current time as the start time of the computing process, and generating a computing order number based on the start time; generating a start time signature based on the start time of the computing process, the computing order number and the private key of the computing service; and using the computing order number, the start time and the start time signature as the output of the first computing service.
[0008] Optionally, constructing a second computing service for generating an end time proof includes: obtaining a computing process corresponding to a received computing order number based on the computing order number; ending the computing process to obtain an output computing result and a computing proof; using the current time as the end time of the computing process; generating an end time signature based on the computing result, the computing proof, the end time and the private key of the computing service; and using the computing result, the computing proof, the end time and the end time signature as the output of the second computing service.
[0009] Optionally, before a random number collection request exists in a random number collection contract on the blockchain, the method further includes: a random number user uses the random number collection termination time and the random number aggregation method as request parameters, and sequentially calls the first computing service and the second computing service, so that the first computing service and the second computing service generate time proof credentials according to the request parameters; the random number user initiates a random number collection request to the random number collection contract on the blockchain; when the random number collection contract verifies that the time proof credential in the random number collection request is qualified, the random number collection request is displayed.
[0010] Optionally, at least two random number generators generate a transaction start time corresponding to the random number collection request according to the first computing service, generate a sub-random number according to a verifiable random function, and generate a transaction end time corresponding to the random number collection request according to the second computing service, including: the random number generator uses the transaction hash value corresponding to the random number collection request as a request parameter, calls the first computing service, and enables the first computing service to generate a first proof credential according to the transaction hash value; wherein the first proof credential includes the transaction start time; the random number generator generates a declaration request according to the transaction hash value, the random identifier and the first proof credential, and enables the on-chain node to perform declaration verification according to the declaration request; after receiving the consent statement sent by the on-chain node, the random number generator uses the transaction hash value, the random identifier, the calculation order number in the first proof credential and the start time in the first proof credential as the seed of the random number generation algorithm, and generates a sub-random number and a random number proof through the random number generation algorithm and the random number proof algorithm; the random number generator calls the second computing service according to the calculation order number in the first proof credential, and enables the second computing service to generate a second proof credential according to the calculation order number; wherein the second proof credential includes the transaction end time.
[0011] Optionally, the random number generator generates a random number submission transaction based on the transaction start time, the sub-random number and the transaction end time and submits it to the on-chain node, so that the on-chain node writes the random number submission transaction into the local transaction pool after successfully verifying the trustworthiness of the sub-random number, including: the random number generator generates a target proof credential using the first proof credential and the second proof credential; the random number generator generates a random number submission transaction using the target proof credential, the sub-random number and the random number proof; the on-chain node determines that the transaction start time in the target proof credential is less than the transaction end time. When it is determined that the calculation proof and the calculation result are generated by the request parameters, the end time signature in the target proof credential is verified by the on-chain public key; when it is determined that the end time signature is composed of the string concatenation of the calculation result, the calculation proof, the start time and the end time, the sub-random number and the random number proof are verified by the random number verification algorithm; when the random number verification algorithm verifies the sub-random number and the random number proof, the on-chain node writes the random number submission transaction into the local transaction pool.
[0012] Optionally, when creating a new block, the on-chain node generates a block creation time corresponding to the new block according to the first computing service, obtains the random number to be packaged from the local transaction pool and submits the transaction, and then generates a block packaging time corresponding to the new block according to the second computing service, including: when creating a new block, the on-chain node calls the first computing service according to the hash value of the last packaged block as a request parameter, so that the first computing service generates a first block certificate according to the hash value of the last packaged block, and the first block certificate includes the creation start time of the new block; the on-chain node obtains the random number to be packaged from the local transaction pool and submits the transaction, and calls the second computing service to obtain the second block certificate; the second block certificate includes the creation end time of the new block; the on-chain node writes the first block certificate and the second block certificate into the time proof voucher field of the new block header; the on-chain node initiates an on-chain consensus, so that the consensus node verifies the new block.
[0013] Optionally, after the random number collection contract aggregates the collected sub-random numbers according to the random number aggregation method to generate a target random number, the method also includes: the random number generator obtains the new block packaged by the on-chain node from the blockchain; when it is determined that the new block does not contain the random number submission transaction submitted by it and the block creation time of the new block is greater than the transaction end time of the random number submission transaction, the random number generator sends a random number packaging review to the consensus node, so that the consensus node reviews the packaging transaction of the on-chain node.
[0014] According to one aspect of an embodiment of the present application, a random number generating device is provided, the device comprising: a computing service construction module, for constructing a first computing service for generating a start time proof and a second computing service for generating an end time proof; a time voucher generating module, for when there is a random number collection request in a random number collection contract on a blockchain, at least two random number generators generate a transaction start time corresponding to the random number collection request according to the first computing service, generate a sub-random number according to a verifiable random function, and generate a transaction end time corresponding to the random number collection request according to the second computing service; a transaction generating module, for the random number generator to generate a random number according to the transaction start time, the sub-random number and the transaction end time and submit the transaction to an on-chain node, so that the on-chain node can verify the trustworthiness of the sub-random number. After success, the random number submission transaction is written into the local transaction pool; a block packaging module is used for the on-chain node to generate a block creation time corresponding to the new block according to the first computing service when creating a new block, and obtain the random number to be packaged from the local transaction pool and submit the transaction, and then generate a block packaging time corresponding to the new block according to the second computing service; a block verification module is used for the consensus node to verify the new block according to the transaction start time, the transaction end time, the block creation time and the block packaging time, and write the new block into the blockchain when the verification passes; a random number aggregation module is used for the random number collection contract to aggregate the collected sub-random numbers according to the random number aggregation method to generate a target random number when the block creation time of the new block in the blockchain is greater than the random number collection termination time in the random number collection request.
[0015] According to one aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the random number generation method in the above technical solution is implemented.
[0016] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the executable instructions so that the electronic device implements a random number generation method as in the above technical solution.
[0017] According to one aspect of an embodiment of the present application, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the random number generation method in the above technical solution is implemented.
[0018] The technical solution provided by this application includes at least the following beneficial effects:
[0019] The present application provides a reliable time proof credential generation service through the constructed first computing service and second computing service, so that each block includes the block creation time and block packaging time, and each random number transaction includes the transaction start time and transaction end time. The on-chain node verifies the time of each submitted transaction when packaging, and the consensus node verifies the time of each on-chain block. This ensures that there is a valid time proof for each random number submission and block generation process. For situations where blockchain nodes may maliciously delay or ignore transactions, any participant on the blockchain can conduct autonomous verification through the on-chain time proof credential, thereby enhancing the credibility of random number generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0021] Figure 1 The figure is a schematic diagram of a flow chart of a random number generation method provided in an embodiment of the present application;
[0022] Figure 2 The figure is a schematic diagram of an application scenario of a random number generation method provided by an embodiment of the present application;
[0023] Figure 3 Shown Figure 1 An exemplary flow chart of step S20 in FIG.
[0024] Figure 4 The figure shows a schematic diagram of a random number transaction process provided by an embodiment of the present application;
[0025] Figure 5 Shown Figure 1 An exemplary flow chart of step S40 in FIG.
[0026] Figure 6 The figure is a schematic diagram of the structure of a random number generating device provided in an embodiment of the present application;
[0027] Figure 7 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0028] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0029] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0030] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0031] It should also be noted that the "multiple" mentioned in this application refers to two or more than two. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship.
[0032] Figure 1 FIG. 1 is a flow chart of a random number generation method provided in an embodiment of the present application; Figure 1 As shown, the method specifically comprises the following steps:
[0033] Step S10: construct a first computing service for generating a start time certificate and a second computing service for generating an end time certificate.
[0034] The application scenarios of the random number generation method of this embodiment are as follows: Figure 2 As shown in the figure, the application scenario includes the following roles and services:
[0035] 1. Blockchain nodes: In this embodiment, only nodes with read and write permissions are considered to package transactions.
[0036] 2. Random number generator: It is an external account (EOA) of the blockchain, responsible for generating random numbers and proofs locally, and writing them into the random number collection contract on the chain through the node.
[0037] 3. Random number user: initiates the random number collection task and finally uses the generated random number.
[0038] 4. Computing server: It can be expanded in parallel. It is deployed with a first computing service for generating a proof of start time and a second computing service for generating a proof of end time. It is a public capability and any role can call the services on the computing server.
[0039] 5. Blockchain: It is not limited to specific public chains or alliance chains, has smart contract functions, and a random number collection contract is deployed on the chain.
[0040] In one embodiment, constructing a first computing service for generating a start time proof includes: generating a computing process based on received request parameters; using the current time as the start time of the computing process, and generating a computing order number based on the start time; generating a start time signature based on the start time, the computing order number and a private key of the computing service; and using the computing order number, the start time and the start time signature as outputs of the first computing service.
[0041] It should be noted that the first computing service is used to generate the upper part of the time proof credential - the start time proof; for a request parameter x for generating a time proof credential, the first computing service needs to return the calculation order number orderId, the start time start_time and the start time signature sig of this time proof credential. start Specifically, when the first computing service receives the service call command, it needs to start a computing process immediately, using the incoming request parameter x as the computing input parameter, and obtaining the current timestamp from the NTP service as the start time start_time of the computing process, generating a computing order number orderId locally, and concatenating the computing start_time and the computing order number orderId as the original text, and using the computing service's private key to generate the start time signature sig start ;Finally, (orderId, start_time, sig start ) is returned to the caller as the upper half of the time proof credential.
[0042] In one embodiment, constructing a second computing service for generating an end time proof specifically includes: obtaining a computing process corresponding to a received computing order number based on the computing order number; ending the computing process to obtain an output computing result and a computing proof; using the current time as the end time of the computing process; generating an end time signature based on the computing result, the computing proof, the end time and the private key of the computing service; and using the computing result, the computing proof, the end time and the end time signature as the output of the second computing service.
[0043] It should be noted that the second computing service is used to generate the lower part of the time proof credential - the end time; the calculation order number orderId of the previously applied time proof credential is used as the input parameter, and after passing through the second computing service, the calculation result y of the delayable verification function, the calculation proof p, the end time end_time of the calculation process and the end time signature sig end Specifically, when the second computing service receives the call command, it finds the computing process corresponding to the previous orderId locally according to the received computing order number orderId, and then terminates it to obtain the computing result y and the computing proof p; at the same time, it obtains the current timestamp from the NTP service and uses it as the end time end_time of the calculation, and then concatenates the y, p, start_time, and end_time strings as the original text, and uses the private key of the computing service to generate the end time signature sig end ;Finally, (y,p,end_time,sig end ) is returned to the caller as the lower half of the time proof credential.
[0044] It should also be noted that the first computing service and the second computing service need to initialize the following parameters in advance: determine the specific calculation algorithm, verification algorithm and calculation parameters of the verifiable random function used; for example, use the perfect square method as the calculation algorithm, Boneh as the proof algorithm, and the genesis block hash as the modulus parameter N; at the same time, a set of shared public and private keys need to be generated, the public key is sent to the chain, and the private key is retained locally; finally, all parties upload the above information to the chain through node consensus.
[0045] The computing service of this embodiment generally includes three processes: initialization Setup, calculation Eval and verification Verify. The initialization phase accepts the security parameter λ and the time parameter (actual time consumption) τ, and can determine the parameter ek and the verification parameter vk used for calculation. The calculation phase accepts the calculation parameter ek and the input x, and generates the output y and the proof π (i.e. (y, π) = Eval (ek, x)) through a sufficiently long calculation time. The verification phase accepts vk, x, y and π, and can quickly verify and output pass or fail (i.e. accept / reject = Verify (vk, x, y, π)); specifically, the calculation process of the complete square modulus is: square the incoming x, continue to square the squared result, continue T times (total time consumption τ), and finally take the result modulo N. The repetition of squaring cannot be parallelized, and the result is not known until the last calculation, so the time consumption and uniqueness requirements of the algorithm are met. Generally speaking, the larger the value of T, the higher the difficulty of the problem, and the longer the average calculation time.
[0046]
[0047] In order to meet the needs of computing services and make them easy to verify, the computer needs to provide a proof π. There are many forms of proof π that meet the conditions, such as the integer N multiplication group based on Euler function, Boneh interactive verification, Wislowski verification protocol, etc.; the proof π will be sent to the verifier together with y, x, and vk to perform Verify verification. Generally speaking, the time spent on verifying the results should be much less than the Eval calculation time, and it can be ignored compared to it. The following is a set of comparison data for the proof Verify based on repeated square Eval + integer N multiplication group:
[0048] T value 100 1000 100000 10000000 Eval calculation time 2.365 5.489 670.615 67749.56 Verify verification time 0.0008 0.006 1.145 6.871
[0049] In this embodiment, a time proof credential tpr orderId The composition needs to include the start time, end time, calculation result, calculation proof and end time signature, that is, (orderId,x,y,p,start_time,end_time,sig end ).
[0050] In this embodiment, the verification of the time proof credential can be performed by any participant, even the smart contract itself. The specific verification steps are as follows, and all three must be verified:
[0051] (1) Verify start_time <end_time;
[0052] (2) Use the verification algorithm to verify that the calculation proof p and the calculation result y are indeed generated by the request parameter x;
[0053] (3) Verify sig end The signature can be verified by the public key on the chain, and the original signature is indeed the string concatenation of the calculation result y, the calculation proof p, the start time start_time and the end time end_time.
[0054] It can be seen that by constructing the first computing service and the second computing service, each participant has realized a read-only global clock in the form of a monotonically increasing time proof credential in the sense of a verifiable random function service in a low-cost manner; at the same time, the generated time proof credential can be used as a non-interactive proof to prove the passage of a period of time starting from a certain point in time (i.e., start_time).
[0055] Step S20: When there is a random number collection request in the random number collection contract on the blockchain, at least two random number generators generate a transaction start time corresponding to the random number collection request according to the first computing service, generate sub-random numbers according to a verifiable random function, and generate a transaction end time corresponding to the random number collection request according to the second computing service.
[0056] In an embodiment, before there is a random number collection request in the random number collection contract on the blockchain, the method further includes: The random number user takes the random number collection termination time and the random number aggregation method as request parameters, and sequentially calls the first computing service and the second computing service, so that the first computing service and the second computing service generate a time proof credential according to the request parameters; The random number user发起 a random number collection request to the random number collection contract on the blockchain; When the random number collection contract verifies that the time proof credential in the random number collection request is qualified, the random number collection request is displayed.
[0057] It should be noted that the random number user determines the random number collection termination time rand_collect_termination and the aggregation method of the collected random numbers locally, concatenates the two into a string as the request parameter x, and sequentially calls the interfaces of the first computing service and the second computing service of the computing server to obtain a time proof credential; Wherein, the time proof credential includes a computing order number, a request parameter, a computing result, a computing proof, a start time, an end time, and an end time signature.
[0058] Next, the random number user发起 a random number collection transaction (i.e., a random number collection request) to the random number collection contract, where the random number collection request includes the random number collection termination time, the random number aggregation method, and the time proof credential; The random number collection contract verifies whether this time proof credential is incorrect. If it is correct, this collection request is displayed in the contract; The specific verification method includes: (1) Verify start_time < end_time; (2) Use the verification algorithm to verify that the computing proof p and the computing result y are indeed generated by the request parameter x; (3) Verify sig end It can be verified by the public key on the chain, and the signed original text is indeed the string concatenation of the computing result y, the computing proof p, the start time start_time, and the end time end_time; All three steps need to be verified to be correct.
[0059] In an embodiment, such as Figure 3As shown, when there is a random number collection request in the random number collection contract on the blockchain, at least two random number generators generate a transaction start time corresponding to the random number collection request according to the first computing service, generate a sub-random number according to a verifiable random function, and generate a transaction end time corresponding to the random number collection request according to the second computing service, specifically including the following steps:
[0060] Step S210: The random number generator uses the transaction hash value corresponding to the random number collection request as a request parameter to call the first computing service, so that the first computing service generates a first certification certificate according to the transaction hash value.
[0061] It should be noted that there are multiple random number generators in this embodiment. Finally, the random number collection contract needs to aggregate the sub-random numbers generated by multiple random number generators to obtain the target random number required by the random number user. Next, this embodiment takes random number generator i as the i-th random number generator for example. The transaction process of random numbers is as follows: Figure 4 As shown, when the random number generator i listens to a new random number collection request, it starts to prepare to generate random numbers locally, that is, the sub-random numbers that make up the target random number; but before that, it is necessary to apply for time proof credentials separately and issue a statement to the upstream node.
[0062] Specifically, the random number generator i uses the transaction hash value corresponding to the random number collection request as the request parameter x, calls the first computing service, and the first computing service returns the corresponding computing order orderId, the computing start time start_time and the start time signature sigs according to the computing process of the above embodiment according to the request parameter x. tart As the first proof voucher; note that at this time the first proof voucher only has the time proof voucher and only has the first half, that is, the start time.
[0063] Step S220: The random number generator generates a declaration request according to the transaction hash value, the random identifier and the first proof certificate, so that the on-chain node performs declaration verification according to the declaration request.
[0064] It should be noted that the random number generator i converts the transaction hash value txHash, the random identifier nonce and the orderId, start_time, sig returned in the previous step start The first proof credential generates a claim request claim and sends it to the on-chain node n that is on-chain for its transaction, declaring that the generator is about to generate a random number; among them, the random identifier nonce is also a random number, which is used to distinguish different transactions and prevent the input parameter string of replay attack.
[0065] Optionally, after receiving the claim request from the random number generator i, the on-chain node n verifies the following:
[0066] (1) Verify sig start It is indeed generated by start_time and orderId as the original text.
[0067] (2) The start_time in the verification statement request claim must be greater than the block creation time when the chain node n creates a new block locally; therefore, this verification can ensure that the transaction start time start_time in the declaration request claim must be greater than the end time end_time of all existing random number upload transactions in the current latest block.
[0068] If the on-chain node verifies correctly and can package the random numbers subsequently generated by random number generator i for on-chain, it will send a reply package with the content of accept_claim; otherwise, it will reply with reject_claim. In any case, the random number generator can continue to look for other nodes to agree to the statement.
[0069] The purpose of steps S210 to S220 is that the random number generator needs to confirm the business intention with the on-chain node; if no node agrees to the statement, the random number generator cannot and does not need to continue the subsequent process until a node agrees.
[0070] Step S230: After receiving the consent statement sent by the on-chain node, the random number generator uses the transaction hash value, the random identifier, the calculated order number in the first proof certificate, and the start time in the first proof certificate as seeds for the random number generation algorithm, and generates a sub-random number and a random number certificate through the random number generation algorithm and the random number proof algorithm.
[0071] It should be noted that after receiving the consent statement accept_claim sent by the uplink connection n, the random number generator i locally uses the transaction hash value txHash, the random identifier nonce, the calculation order number orderId in the first proof voucher, and the calculation start time start_time in the first proof voucher as the random number generation algorithm VRF VAL The seed is generated using the random number generation algorithm VRF VAL Generate a random number ri and use the random number proof algorithm VRF PROVE Generate a random number proof pri.
[0072] Optionally, a Verifiable Random Function (VRF) is a verifiable random number generator. It is an encryption function that, based on a set of public and private keys, can map an input (i.e., a seed) to a random output and a proof that verifies that the output is indeed generated by a specific input and key. Its characteristics include: (1) Verifiability: Any public key holder can verify the results of the VRF operation (but only the private key can be calculated); (2) Randomness: In the absence of a private key or seed, the output of the VRF is unpredictable and has a uniform probability distribution; (3) Unforgeable and indistinguishable: In the absence of a private key, it is impossible to distinguish the outputs corresponding to two different input seeds, nor is it possible to generate valid outputs and corresponding proofs. The main process of VRF in this embodiment includes the following three steps: (1) Pass in the private key and seed, and use the random number generation algorithm VRF VAL Generate a random number; (2) Pass in the private key and seed, and use the random number proof algorithm VRF PROVE Generate the corresponding certificate); (3) Enter the random number, certificate and public key, and verify the random number through the random number verification algorithm VRF VER Verify the random number. The first two steps are performed by the random number generator, and the result will be delivered to the user; the user will then call the random number verification algorithm VRF VER Verification is performed. If the verification is correct, the random number can be put into use.
[0073] Step S240: The random number generator calls the second computing service according to the computing order number in the first certification certificate, so that the second computing service generates a second certification certificate according to the computing order number.
[0074] It should be noted that the random number generator i uses the calculation order number in the first proof voucher as a request parameter to call the second calculation service, so that the second calculation service outputs a second proof voucher according to the calculation order number, and the second proof voucher specifically includes the calculation result, calculation proof, end time and end time signature. Among them, the processing process of the second calculation service is the same as that in step S10, which will not be repeated here.
[0075] Step S30: The random number generator generates a random number submission transaction based on the transaction start time, the sub-random number and the transaction end time and submits it to the on-chain node, so that the on-chain node writes the random number submission transaction into the local transaction pool after the trusted verification of the sub-random number is successful.
[0076] In one embodiment, the following steps are specifically included: the random number generator generates a target proof credential from the first proof credential and the second proof credential; the random number generator submits a random number submission transaction generated from the target proof credential, the sub-random number, and the random number proof; when the on-chain node determines that the transaction start time in the target proof credential is less than the transaction end time, it verifies the calculation proof and the calculation result; when it is determined that the calculation proof and the calculation result are generated from the request parameters, it verifies the end time signature in the target proof credential through the on-chain public key; when it is determined that the end time signature is the string concatenation of the calculation result, the calculation proof, the start time, and the end time, it verifies the sub-random number and the random number proof through the random number verification algorithm; when the random number verification algorithm passes the verification of the sub-random number and the random number proof, the on-chain node writes the random number submission transaction into the local transaction pool.
[0077] It should be noted that the random number generator combines the first proof credential and the second proof credential into a complete time proof credential tpr orderId That is, the target proof credential; at this time, the random number generator has generated a random number on the premise of obtaining the consent of the on-chain node to go on-chain and obtained a complete time proof credential.
[0078] Further, the random number generator i sends a random number submission transaction submit to the on-chain node n that previously received the consent statement again, requesting to write it into the on-chain random number collection contract. This transaction needs to carry the fields (ri, pri, tpr orderId ), indicating that the random number calculation and the time proof credential have been completed and need to be on-chain; after the on-chain node n receives the random number submission transaction submit from the random number generator i, it needs to verify it. The specific verification process includes:
[0079] (1) Verification of the time proof credential tpr orderId The specific verification steps include: ① Verify start_time < end_time; ② Use the verification algorithm to verify that the calculation proof p and the calculation result y are indeed generated from the request parameter x; ③ Verify sig end Can be verified by the on-chain public key, and the original signature is indeed the string concatenation of the calculation result y, the calculation proof p, the start time start_time, and the end time end_time; among them, all three steps need to pass the verification to be correct.
[0080] (2) Use the random number verification algorithm VRF VER To verify the sub-random number ri and the random number proof pri, and confirm that the sub-random number ri is a credible random number.
[0081] If everything is correct, the transaction will be put into the node's pending transaction pool for packaging and uploading to the chain, and accept_submit will be replied to agree to packaging; otherwise, the transaction will be discarded and reject_submit will be replied.
[0082] In addition, after the on-chain node n replies to the random number generator i with the accept_submit message that it agrees to package, it needs to broadcast the random number submission transaction to as many other nodes as possible; other nodes that receive the transaction broadcast need to verify the transaction according to the above steps before writing it into the local transaction packaging pool.
[0083] At any time, the node n on the chain needs to always observe the latest block of the blockchain at this time to see if there is an end_time greater than the start_time of the random number transaction submitted in its own transaction pool. If there is, it means that a new block containing an updated random number has been submitted to the chain, and the transaction on hand will not have a chance to be on the chain later. At this time, the node n on the chain needs to resend reject_submit to the corresponding random number generator i.
[0084] Step S40: When creating a new block, the on-chain node generates a block creation time corresponding to the new block according to the first computing service, obtains the random number to be packaged from the local transaction pool, submits the transaction, and generates a block packaging time corresponding to the new block according to the second computing service.
[0085] In this embodiment, the main purpose of this step is for the on-chain node to package the blockchain containing the uploaded random number submission transaction on the chain; combined with Figure 4 and Figure 5 As shown, the specific steps are as follows:
[0086] Step S410: When creating a new block, the on-chain node calls the first computing service based on the hash value of the last packaged block as a request parameter, so that the first computing service generates a first block certificate based on the hash value of the last packaged block.
[0087] Step S420: The on-chain node obtains the random number to be packaged from the local transaction pool and submits the transaction, and calls the second computing service to obtain the second block certificate.
[0088] Step S430: The on-chain node writes the first block proof and the second block proof into the time proof credential field of the new block header.
[0089] Step S440: The on-chain node initiates an on-chain consensus, so that the consensus node verifies the new block.
[0090] In this embodiment, the first block proof includes the creation start time of a new block, and the second block proof includes the creation end time of the new block.
[0091] It should be noted that each block in this embodiment generally includes a block header and a block body; among them, the block header is the meta-information storage part of the block, mainly used for identifying, verifying, and explaining the block content. The following are the main fields included in the block header: (1) ParentHash: The hash value of the parent block. This is the hash value linked to the previous block, ensuring the continuity between blocks; (2) StatusRoot: The hash of the world state, that is, the hash value after the RLP encoding of stateDB. It represents the total hash value of the blockchain world state after all transactions in the current block are completed; (3) TxHashRoot: The root hash of the transaction trie, calculated from the transaction hashes of all transactions in this block. It verifies the validity and integrity of all transactions; (4) ReceptHashRoot: The root hash of the receipt tree. This is the hash value used to verify the block receipt, providing evidence of the transaction execution result; (5) Time: The Unix timestamp when the block is generated. It records the time when the block is mined; (6) Number: The block number. It represents the position of the block in the blockchain; (7) Bloom: The Bloom filter, which quickly locates whether a log is in this block. It provides an efficient way to check whether a certain data exists in a certain set without providing the complete data set. The block body contains all the transactions packed in the block. Each transaction on the blockchain is stored in a block and is verified and packed through specific data structures and algorithms.
[0092] The block header in this embodiment has a new field: tpr, the content of which is the time proof credential generated by the first computing service and the second computing service. For a block without this credential, all the random number collection contract transactions packed in the block are invalid and not included in the random number aggregation. For different blocks A and B, if the block height BHA < BHB, then it must be required that end_timeA < start_timeB.
[0093] When creating each new block, the on-chain node in this embodiment needs to write a legal time proof credential into the tpr field of its block header, which is used as a non-interactive global trusted timestamp for random number collection. Therefore, after the previous block is packed, each on-chain node needs to immediately call the first computing service, and its request parameter x is the Merkle root of the previous block or the block Hash (in the case of non-Merkle tree), to obtain the first block proof including the creation start time of the new block.
[0094] Next, the on-chain node n selects several transactions from the transaction pool to initiate packaging; among them, the on-chain node needs to first package all random number submission transactions that reply to accept_submit, and at the same time, package them according to the tpr in each transaction. orderId In addition, the on-chain nodes can still package non-random number upload transactions without time proof credentials, but all packaged random number upload transactions must include valid time proof credentials.
[0095] Furthermore, the on-chain node n calls the second computing service to obtain the lower half of the time proof credential for block generation, i.e., the second block proof including the creation end time of the new block, and then synthesizes the first block proof and the second block proof into a complete time proof credential and writes it into the time proof credential field tpr of the current block header. The specific example is shown in Table 1:
[0096] Table 1. Block instance
[0097]
[0098] Among them, the start_time of the time proof credential in the block header of a legal block must be less than the start_time of all transactions, and its end_time must be greater than the end_time of all transactions.
[0099] Step S50, the consensus node verifies the new block according to the transaction start time, the transaction end time, the block creation time and the block packaging time, and writes the new block into the blockchain when the verification passes.
[0100] It should be noted that when the on-chain node n initiates on-chain consensus to other consensus nodes, other consensus nodes, in addition to performing regular blockchain verification (verifying the Merkle tree root of the block, block hash, transaction signature, etc.), also need to verify this block according to the following steps:
[0101] (1) Confirm that the start_time of each random number submission transaction must be greater than the end_time of the previous block, and must be greater than the start_time of the time proof credential of this block.
[0102] (2) For each random number submission transaction in the block, the random number is verified to be credible according to the verification process of the random number submission transaction received by the on-chain node n from the random number generator i, and its time proof credentials are verified.
[0103] (3) Verify the time proof of this block.
[0104] After verification, the block is written into the blockchain history, otherwise the consensus node can reject the consensus.
[0105] Step S60: When the block creation time of the new block in the blockchain is greater than the random number collection termination time in the random number collection request, the random number collection contract aggregates the collected sub-random numbers according to the random number aggregation method to generate a target random number.
[0106] It should be noted that the process of steps S20 to S50 above continues until the start_time of a certain block exceeds the random number collection termination time rand_collect_termination defined in the random number collection request. At this time, the random number collection contract automatically aggregates all the collected sub-random numbers according to the pre-defined aggregation method to generate the target random number, and sends the target random number to the random number user.
[0107] In addition, the random number collection contract deployed on the blockchain only accepts the following two types of transactions, both of which must be accompanied by time proof credentials: (1) a collection transaction initiated by a random number user; (2) a random number upload transaction request initiated by an external account; the contract collects and stores the locally generated random numbers in the contract and makes them available for query by all system participants; after the collection is completed, the contract aggregates them.
[0108] In summary, the present application provides a reliable time proof credential generation service through the constructed first computing service and second computing service, so that each block includes the block creation time and the block packaging time, and each random number transaction includes the transaction start time and the transaction end time. The on-chain node verifies the time of each submitted transaction when packaging, and the consensus node verifies the time of each on-chain block. This ensures that there is a valid time proof for each random number submission and block generation process. For situations where blockchain nodes may maliciously delay or ignore transactions, any participant on the blockchain can perform autonomous verification through the on-chain time proof credential, thereby enhancing the credibility of random number generation.
[0109] In another embodiment of the present application, after the random number collection contract aggregates the collected sub-random numbers according to the random number aggregation method to generate a target random number, the method also includes: the random number generator obtains the new block packaged by the on-chain node from the blockchain; when it is determined that the new block does not contain the random number submission transaction submitted by it and the block creation time of the new block is greater than the transaction end time of the random number submission transaction, the random number generator sends a random number package review to the consensus node, so that the consensus node reviews the packaged transaction of the on-chain node.
[0110] The main purpose of this embodiment is to allow the random number generator to identify and report malicious behavior of its own on-chain nodes. This includes but is not limited to the following scenarios:
[0111] 1. The on-chain node intentionally ignored a random number submission transaction s from the random number generator and did not package it.
[0112] Judgment condition: Generator i has received accept_submit from node n, and has not received reject_submit before the block is generated; however, transaction s is not seen in the latest block, and there is a transaction whose start_time is greater than the end_time of this transaction s. In this case, it means that the packaging node intentionally ignored its own random number submission result and selected the updated transaction to enter the block, so the packaging node may be malicious. Further distinction:
[0113] (1) The packaging node is node n: At this time, the generator can directly initiate a review of node n.
[0114] (2) The packaging node is node m, and m is not n: At this time, the generator can initiate a review of nodes n and m at the same time (it may be because n did not broadcast the transaction, or m intentionally ignored the node broadcast).
[0115] 2. The on-chain node is unwilling to submit a transaction response for a certain random number.
[0116] Judgment conditions: Generator i received accept_claim from node n and submitted transaction s, but did not receive accept_submit or reject_submit before the block was generated, and there is a transaction in the latest block whose start_time is greater than the end_time of this transaction s. This situation is similar to the above situation, when node n deliberately delays, the generator can directly initiate a reconsideration against node n.
[0117] 3. The node maliciously rejects a random number submission transaction reply.
[0118] Judgment condition: Generator i received accept_claim from node n and submitted transaction s, but received reject_submit for no reason. In this case, regardless of whether a new block has been generated, as long as generator i confirms that there is no problem with his local calculation, it can be considered that node n has maliciously rejected it. At this time, the generator can directly initiate a reconsideration against node n.
[0119] It should be noted that the reconsideration initiated by the random number generator against the on-chain node will be jointly reviewed by the consensus nodes to decide whether to exclude this node from the power to submit random number transactions; this application raises the threshold for a few nodes to maliciously manipulate the random number generation process to the point where the entire group of packaging nodes needs to be destroyed; therefore, this application is based on a non-interactive time-delay proof of credentials implemented by two computing services. While ensuring the credibility of the random number generation and aggregation processes, it also ensures that random number collection is difficult to be interfered with by malicious blockchain nodes within a specified time limit; once malicious behavior occurs, the generator can clearly identify the specific method of the malicious behavior.
[0120] Figure 6 FIG. 1 is a schematic diagram of the structure of a random number generating device provided in an embodiment of the present application; Figure 6 As shown, the device comprises:
[0121] A computing service construction module 610, configured to construct a first computing service for generating a start time certificate and a second computing service for generating an end time certificate;
[0122] A time voucher generation module 620, configured to, when there is a random number collection request in the random number collection contract on the blockchain, generate a transaction start time corresponding to the random number collection request according to the first computing service, generate a sub-random number according to a verifiable random function, and generate a transaction end time corresponding to the random number collection request according to the second computing service by at least two random number generators;
[0123] The transaction generation module 630 is used for the random number generator to generate a random number submission transaction according to the transaction start time, the sub-random number and the transaction end time and submit it to the on-chain node, so that the on-chain node writes the random number submission transaction into the local transaction pool after the trustworthy verification of the sub-random number is successful;
[0124] The block packaging module 640 is used for the on-chain node to generate a block creation time corresponding to the new block according to the first computing service when creating a new block, and to obtain a random number to be packaged from the local transaction pool and submit a transaction, and then generate a block packaging time corresponding to the new block according to the second computing service;
[0125] The block verification module 650 is used for the consensus node to verify the new block according to the transaction start time, the transaction end time, the block creation time and the block packaging time, and write the new block into the blockchain when the verification passes;
[0126] The random number aggregation module 660 is used for aggregating the collected sub-random numbers according to the random number aggregation method to generate a target random number when the block creation time of the new block in the blockchain is greater than the random number collection termination time in the random number collection request.
[0127] Figure 7 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.
[0128] It should be noted that Figure 7 The computer system 1000 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0129] like Figure 7 As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1002 or the program loaded from the storage part 1008 to the random access memory (RAM) 1003, such as executing the method described in the above embodiment. In the RAM 1003, various programs and data required for system operation are also stored. The CPU 1001, the ROM 1002 and the RAM 1003 are connected to each other through the bus 1004. The input / output (I / O) interface 1005 is also connected to the bus 1004.
[0130] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0131] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1009, and / or installed from a removable medium 1011. When the computer program is executed by a central processing unit (CPU) 1001, various functions defined in the system of the present application are executed.
[0132] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium can include a data signal propagated in a baseband or as a part of a carrier wave, wherein a computer-readable computer program is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0133] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0134] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0135] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. A person skilled in the art can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.
Claims
1. A random number generation method, characterized in that: The method comprises: Constructing a first computing service for generating a proof of a start time and a second computing service for generating a proof of an end time; When there is a random number collection request in the random number collection contract on the blockchain, at least two random number generators generate a transaction start time corresponding to the random number collection request according to the first computing service, generate a sub-random number according to a verifiable random function, and generate a transaction end time corresponding to the random number collection request according to the second computing service; The random number generator generates a random number submission transaction based on the transaction start time, the sub-random number and the transaction end time and submits it to the on-chain node, so that the on-chain node writes the random number submission transaction into the local transaction pool after the trustworthy verification of the sub-random number is successful; When creating a new block, the on-chain node generates a block creation time corresponding to the new block according to the first computing service, obtains a random number to be packaged from the local transaction pool, and generates a block packaging time corresponding to the new block according to the second computing service after submitting a transaction; The consensus node verifies the new block according to the transaction start time, the transaction end time, the block creation time and the block packaging time, and writes the new block into the blockchain when the verification passes; When the block creation time of a new block in the blockchain is greater than the random number collection termination time in the random number collection request, the random number collection contract aggregates the collected sub-random numbers according to the random number aggregation method to generate a target random number.
2. The method according to claim 1, characterized in that Building the first computation service for generating proof of start time includes: Generate a computing process based on the received request parameters; Taking the current time as the start time of the calculation process, and generating a calculation order number according to the start time; Generate a start time signature according to the start time of the computing process, the computing order number and the private key of the computing service; The computing order number, the start time and the start time signature are used as outputs of the first computing service.
3. The method according to claim 2, characterized in that The second computing service for generating the end time proof includes: According to the received calculation order number, obtaining the calculation process corresponding to the calculation order number; End the calculation process and obtain output calculation results and calculation proof; Taking the current time as the end time of the calculation process; Generate an end time signature according to the calculation result, the calculation proof, the end time, and the private key of the computing service; The calculation result, the calculation proof, the end time and the end time signature are used as outputs of the second computing service.
4. The method according to claim 1, characterized in that Before a random number collection request exists in the random number collection contract on the blockchain, the method further includes: The random number user uses the random number collection end time and the random number aggregation method as request parameters, and sequentially calls the first computing service and the second computing service, so that the first computing service and the second computing service generate time proof credentials according to the request parameters; The random number user initiates a random number collection request to the random number collection contract on the blockchain; When the random number collection contract verifies the time proof credential in the random number collection request as qualified, the random number collection request is displayed.
5. The method according to claim 3, characterized in that: At least two random number generators generate a transaction start time corresponding to the random number collection request according to the first computing service, generate a sub-random number according to a verifiable random function, and generate a transaction end time corresponding to the random number collection request according to the second computing service, including: The random number generator uses the transaction hash value corresponding to the random number collection request as a request parameter, and calls the first computing service, so that the first computing service generates a first certification certificate according to the transaction hash value; wherein the first certification certificate includes the transaction start time; The random number generator generates a declaration request according to the transaction hash value, the random identifier and the first certification certificate, so that the on-chain node performs declaration verification according to the declaration request; After receiving the consent statement sent by the on-chain node, the random number generator uses the transaction hash value, the random identifier, the calculation order number in the first proof certificate, and the start time in the first proof certificate as seeds of the random number generation algorithm, and generates a sub-random number and a random number certificate through the random number generation algorithm and the random number certification algorithm; The random number generator calls the second computing service according to the computing order number in the first certification certificate, so that the second computing service generates a second certification certificate according to the computing order number; wherein the second certification certificate includes the transaction end time.
6. The method according to claim 5, characterized in that The random number generator generates a random number submission transaction according to the transaction start time, the sub-random number and the transaction end time and submits it to the on-chain node, so that the on-chain node writes the random number submission transaction into the local transaction pool after the trustworthy verification of the sub-random number is successful, including: The random number generator generates a target certification certificate by using the first certification certificate and the second certification certificate; The random number generator submits the target proof voucher, the sub-random number and the random number generated by the random number proof to a transaction; When the on-chain node determines that the transaction start time in the target proof voucher is less than the transaction end time, the calculation proof and the calculation result are verified; When it is determined that the computation proof and the computation result are generated by the request parameters, verifying the end time signature in the target proof credential by using the on-chain public key; When it is determined that the end time signature is a string concatenated from the calculation result, the calculation proof, the start time, and the end time, the sub-random number and the random number proof are verified by a random number verification algorithm; When the random number verification algorithm successfully verifies the sub-random number and the random number proof, the on-chain node writes the random number submission transaction into the local transaction pool.
7. The method according to claim 5, characterized in that When creating a new block, the on-chain node generates a block creation time corresponding to the new block according to the first computing service, obtains a random number to be packaged from the local transaction pool and submits a transaction, and then generates a block packaging time corresponding to the new block according to the second computing service, including: When creating a new block, the on-chain node calls the first computing service according to the hash value of the last packaged block as a request parameter, so that the first computing service generates a first block certificate according to the hash value of the last packaged block, and the first block certificate includes the creation start time of the new block; The on-chain node obtains the random number to be packaged from the local transaction pool and submits the transaction, and calls the second computing service to obtain the second block certificate; the second block certificate includes the creation end time of the new block; The on-chain node writes the first block proof and the second block proof into the time proof voucher field of the new block header; The on-chain node initiates an on-chain consensus, allowing the consensus node to verify the new block.
8. The method according to any one of claims 1 to 7, characterized in that: After the random number collection contract aggregates the collected sub-random numbers according to the random number aggregation method to generate a target random number, the method further includes: The random number generator obtains the new block packaged by the on-chain node from the blockchain; When it is determined that the new block does not contain the random number submission transaction submitted by it and the block creation time of the new block is greater than the transaction end time of the random number submission transaction, the random number generator sends a random number package review to the consensus node, so that the consensus node reviews the package transaction of the on-chain node.
9. A random number generating device, characterized in that: The device comprises: A computing service construction module, used to construct a first computing service for generating a start time proof and a second computing service for generating an end time proof; A time voucher generation module, configured to, when there is a random number collection request in the random number collection contract on the blockchain, generate a transaction start time corresponding to the random number collection request according to the first computing service, generate a sub-random number according to a verifiable random function, and generate a transaction end time corresponding to the random number collection request according to the second computing service by at least two random number generators; A transaction generation module, which is used for the random number generator to generate a random number submission transaction according to the transaction start time, the sub-random number and the transaction end time and submit it to the on-chain node, so that the on-chain node writes the random number submission transaction into the local transaction pool after the trustworthy verification of the sub-random number is successful; A block packaging module, used for the on-chain node to generate a block creation time corresponding to the new block according to the first computing service when creating a new block, and to obtain a random number to be packaged from the local transaction pool and submit a transaction, and then generate a block packaging time corresponding to the new block according to the second computing service; A block verification module is used for the consensus node to verify the new block according to the transaction start time, the transaction end time, the block creation time and the block packaging time, and write the new block into the blockchain when the verification passes; The random number aggregation module is used for a random number collection contract to aggregate the collected sub-random numbers according to the random number aggregation method to generate a target random number when the block creation time of the new block in the blockchain is greater than the random number collection termination time in the random number collection request.
10. An electronic device, characterized in that: include: processor; as well as A memory for storing executable instructions of the processor; wherein the processor is configured to execute the executable instructions to enable the electronic device to implement the random number generation method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Blockchain random number generation method and device, equipment and computer storage medium
CN112631550A
Random number generation method and device, computer equipment and medium
CN115085909A
Random number generation method and device of block chain network service platform, and storage medium
CN115694802A
Block chain generation method and system applied to real-time storage data and storage medium
CN116962058A
Data processing method and device based on block chain, equipment and medium
CN116996331A