A random number generation method, apparatus and electronic device

By constructing the first and second computing services to generate time proof credentials, the problem of low credibility of random number generation on the blockchain is solved, the time consistency and fairness of blockchain transactions are ensured, and the credibility of random number generation is enhanced.

CN119512504BActive Publication Date: 2025-10-10WEBANK (CHINA)
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411662593.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-20
Publication Date
2025-10-10
Estimated Expiration
2044-11-20

AI Technical Summary

Technical Problem

The existing method of generating random numbers based on verifiable random functions (VRFs) cannot effectively prevent nodes from committing malicious acts on the blockchain, resulting in low credibility of random number generation and affecting the fairness of blockchain transactions.

Method used

Build a first computing service for generating proof of start time and a second computing service for generating proof of end time. Generate time proof credentials through these services to ensure the time verification of each random number transaction and block generation process on the blockchain, and enhance the credibility of random number generation.

Benefits of technology

By verifying the time proof credentials, blockchain nodes and consensus nodes are able to independently verify the time consistency of blockchain transactions, preventing nodes from maliciously delaying or ignoring transactions, and improving the credibility of random number generation and the fairness of the blockchain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512504B_ABST
    Figure CN119512504B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a random number generation method, device and electronic equipment, 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; a random number generator generates a transaction start time corresponding to a random number collection request according to the first computing service, generates a sub-random number according to a verifiable random function, and generates a transaction end time corresponding to the random number collection request according to the second computing service; the on-chain node generates a block creation time corresponding to the new block according to the first computing service, and generates a block packaging time corresponding to the new block according to the second computing service; a random number collection contract aggregates the collected sub-random numbers according to a random number aggregation mode to generate a target random number; the present application ensures that there is an effective time proof in each random number submission and block generation process, and enhances the credibility of random number generation.
Need to check novelty before this filing date? Find Prior Art

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, while the current VRF-based method of generating random data solves the reliability of the random data source, it cannot address 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. However, in this case, blockchain nodes or validators can abandon transactions that are unfavorable to them, or delay their packaging and inclusion in blocks, ultimately affecting the random number generation results.

[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] 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 certificate and a second computing service for generating an end time certificate; when a random number collection request exists 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. Then the random number submission transaction is written into the local transaction pool; when the on-chain node creates a new block, it generates a block creation time corresponding to the new block according to the first computing service, and 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; 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 is passed; when the block creation time of the new block in the blockchain is greater than the random number collection end 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 the 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 based on the first computing service, generate a sub-random number based on a verifiable random function, and generate a transaction end time corresponding to the random number collection request based on 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 causes the first computing service to generate a first proof certificate based on the transaction hash value; wherein the first proof certificate includes the transaction start time; the random number generator generates a declaration request based on the transaction hash value, the random identifier, and the first proof certificate, and causes the on-chain node to perform declaration verification based on the declaration request; upon 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 proof through the random number generation algorithm and the random number proof algorithm; the random number generator calls the second computing service based on the calculation order number in the first proof certificate, and causes the second computing service to generate a second proof certificate based on the calculation order number; wherein the second proof certificate 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 certificate using the first proof certificate and the second proof certificate; the random number generator generates a random number submission transaction using the target proof certificate, the sub-random number and the random number proof; the on-chain node determines that the transaction start time in the target proof certificate 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 certificate is verified by the on-chain public key; when it is determined that the end time signature is composed of the string splicing 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 based on the hash value of the previous packaged block as a request parameter, so that the first computing service generates a first block certificate according to the hash value of the previous 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 certificate 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 the 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 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 certificate and a second computing service for generating an end time certificate; a time certificate 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; the 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; the 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 is passed; the 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 end 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 the random number generation method 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, which implements the random number generation method in the above technical solution when executed by a processor.

[0018] The technical solution provided by this application has at least the following beneficial effects:

[0019] This application provides a trusted 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 block on the chain. 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 independent verification through the on-chain time proof credential, thereby enhancing the credibility of random number generation. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The accompanying drawings are incorporated into and constitute a part of the specification, illustrating embodiments consistent with the present application and, together with the specification, serving to explain the principles of the present application. It is obvious that the drawings described below are merely some embodiments of the present application, and a person of ordinary skill in the art can derive other drawings based on these drawings without inventive effort. In the drawings:

[0021] Figure 1 FIG2 is a flow chart of a random number generation method provided in an embodiment of the present application;

[0022] Figure 2 The figure shows 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;

[0024] Figure 4 FIG2 is 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;

[0026] Figure 6 FIG2 is a schematic structural diagram 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 according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0028] Detailed description will be given to the exemplary embodiments here, and examples thereof are shown in the drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of apparatuses and methods consistent with some aspects of the present application as detailed in the appended claims.

[0029] The block diagrams shown in the drawings are merely functional entities, and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0030] The flowcharts shown in the drawings are merely exemplary illustrations, and do not necessarily include all contents and operations / steps, nor are they necessarily executed in the order described. For example, some operations / steps can be further divided, and some operations / steps can be combined or partially combined, so the actual execution order can be changed according to actual conditions.

[0031] It should also be noted that "multiple" as mentioned in the present application means two or more. The association relationship of "and / or" describes the associated objects, which means that there can be three relationships, for example, A and / or B can represent the three cases of A alone, A and B together, and B alone. The character " / " generally represents an "or" relationship between the associated objects before and after it.

[0032] Figure 1 A flowchart of a random number generation method provided by an embodiment of the present application is shown. As shown in Figure 1 The method specifically includes the following steps:

[0033] Step S10, constructing a first computing service for generating a start time proof and a second computing service for generating an end time proof.

[0034] The application scenario of the random number generation method of the present embodiment is shown in Figure 2 The application scenario includes the following roles and services:

[0035] 1. Blockchain node: only nodes with read and write permissions can be considered for transaction packaging in the present embodiment.

[0036] 2. Random number generator: an externally owned account (EOA, Externally Owned Address) of the blockchain, responsible for generating random numbers and proofs locally, and writing them into the chain random number collection contract 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 and is deployed with a first computing service for generating proof of start time and a second computing service for generating proof of end time. It is a public capability and any role can call the services on the computing server.

[0039] 5. Blockchain: Not limited to specific public chains or consortium chains, with smart contract functions, and a random number collection contract 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 must 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 a 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. A computing order number orderId is generated locally, and the computing start_time and the computing order number orderId are concatenated as the original text. The private key of the computing service is used 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 half of the time proof credential - the end time; the calculation order number orderId of the previously applied time proof credential is used as an input parameter, and after passing through the second computing service, it needs to return the calculation result y of the deferred 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. Then, it 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 will upload the above information to the chain through node consensus.

[0045] The computation service in this embodiment generally includes three steps: initialization (Setup), computation (Eval), and verification (Verify). The initialization phase accepts a security parameter λ and a time parameter (actual time) τ, determining the computation parameters ek and verification parameters vk. The computation phase accepts the computation parameters ek and input x, and after a sufficiently long computation time, generates the output y and proof π (i.e., (y, π) = Eval(ek, x)). The verification phase accepts vk, x, y, and π, quickly verifies and outputs a pass or fail (i.e., accept / reject = Verify(vk, x, y, π)). Specifically, the fully squared modulo computation process is as follows: square the input x, square the result T times (a total of τ), and finally take the result modulo N. Repeated squaring cannot be parallelized, and the result is not known until the last computation, thus meeting the algorithm's time and uniqueness requirements. Generally speaking, the larger the value of T, the more difficult the problem, and the longer the average computation time.

[0046]

[0047] To ensure that computing services meet verification requirements, the computer must provide a proof π. This proof π can take many forms, including the multiplicative group of integers N based on Euler functions, Boneh interactive verification, and the Wislowski verification protocol. The proof π is sent along with y, x, and vk to the verifier for verification. Generally speaking, the time spent verifying the result should be much less than the Eval computation time and can be negligible compared to it. The following is a comparison of proofs based on repeated square Eval and the multiplicative group of integers N:

[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, verification of the proof-of-time credential can be performed by any participant, even the smart contract itself. The specific verification steps are as follows, and all three verifications must pass:

[0051] (1) Verify start_time <end_time;

[0052] (2) Using the verification algorithm, the verification calculation proves that 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, calculation proof p, start time start_time and end time end_time.

[0054] It can be seen from this 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 a random number collection request exists 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.

[0056] In one embodiment, before a random number collection request exists in a random number collection contract on a 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, sequentially calling 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.

[0057] It should be noted that the random number user locally determines the random number collection termination time rand_collect_termination and the aggregation method of the collected random numbers, concatenates the two into a string as the request parameter x, and continuously calls the first computing service and the second computing service interface to the computing server to obtain a time proof credential; wherein, the time proof credential includes the calculation order number, request parameters, calculation results, calculation proof, start time, end time and end time signature.

[0058] Next, the random number user initiates a random number collection transaction (i.e., a random number collection request) to the random number collection contract, wherein the random number collection request includes the random number collection end time, the random number aggregation method, and the time proof certificate; the random number collection contract verifies whether the time proof certificate is correct, and if so, displays the collection request in the contract; the specific verification methods include: (1) verifying the start_time <end_time;(2)使用验证算法,验证计算证明p和计算结果y确实由请求参数x生成;(3)验证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; among them, it is considered correct only after all three steps are verified.

[0059] In one embodiment, if 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 in the figure, when the random number generator i listens to a new random number collection request, it starts to prepare to generate a random number locally, which is the sub-random number that constitutes 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 starting 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 the first proof voucher at this time 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 based on the transaction hash value, the random identifier, and the first certification certificate, so that the on-chain node performs declaration verification based on the declaration request.

[0064] It should be noted that the random number generator i will use the transaction hash value txHash, random identifier nonce and the orderId, start_time, sig returned in the previous step. start The first proof certificate generates a claim request and sends it to the on-chain node n that is on-chaining its own 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 from start_time and orderId as the original text.

[0067] (2) The start_time in the verification claim request 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 that the random number generator i has been successfully uploaded to the chain, it will send a reply containing the consent statement "accept_claim"; otherwise, it will send a rejection statement "reject_claim". In any case, the random number generator can continue to seek other nodes to agree to the claim.

[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 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 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 certificate, and the calculation start time start_time in the first proof certificate 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 result of the VRF operation (but only those holding the private key can calculate it); (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 can a valid output and corresponding proof be generated. The main process of VRF in this embodiment includes the following three steps: (1) Pass in the private key and seed, and generate a random number through the random number generation algorithm VRF VAL Generate a random number; (2) Enter 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 VRF algorithm 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 random number generator i uses the calculation order number in the first proof voucher as a request parameter to call the second computing service, causing the second computing service to output a second proof voucher based on the calculation order number. The second proof voucher specifically includes the calculation result, calculation proof, end time, and end time signature. The processing of the second computing service is the same as in step S10 and 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. After the on-chain node successfully verifies the trustworthiness of the sub-random number, it writes the random number submission transaction into the local transaction pool.

[0076] In one embodiment, the specific steps include: the random number generator generates a target proof certificate using the first proof certificate and the second proof certificate; the random number generator generates a random number submission transaction using the target proof certificate, the sub-random number and the random number proof; when the on-chain node determines that the transaction start time in the target proof certificate is less than the transaction end time, the calculation proof and the calculation result are verified; 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 certificate is verified by the on-chain public key; when it is determined that the end time signature is spliced ​​by the character string of the calculation result, calculation proof, start time and 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 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.

[0077] It should be noted that the random number generator combines the first proof certificate and the second proof certificate into a complete time proof certificate tpr orderId That is, the target proof certificate; at this time, the random number generator has generated the random number on the premise of obtaining the declaration and consent of the upstream node to go on the chain, and obtained the complete time proof certificate.

[0078] Furthermore, the random number generator i sends the random number submission transaction submit again through the on-chain node n that received the consent statement before, requesting that it be written 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 time proof credentials have been completed and need to be uploaded to the chain; after the on-chain node n receives the random number submission transaction from the random number generator i, it needs to verify it. The specific verification process includes:

[0079] (1) Time proof credential tpr orderId Verification, the specific verification steps include: ① Verify start_time <end_time;②使用验证算法,验证计算证明p和计算结果y确实由请求参数x生成;③验证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; among them, it is considered correct only after all three steps are verified.

[0080] (2) Using the random number verification algorithm VRF VER Verify the sub-random number ri and the random number proof pri to confirm that the sub-random number ri is a credible random number.

[0081] If everything is correct, the transaction will be placed in the node's pending transaction pool to be packaged and uploaded to the chain, and the node will reply with "accept_submit" to agree to the package. Otherwise, the transaction will be discarded and a "reject_submit" response will be sent.

[0082] In addition, after the on-chain node n responds to the random number generator i with the accept_submit message, 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 given moment, node n must monitor the latest block on the blockchain to see if its end_time is greater than the start_time of the transaction submitted with the random number in its transaction pool. If so, a new block containing the updated random number has been submitted, and the transaction will no longer be on the blockchain. Node n must then resend a 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 a random number to be packaged from the local transaction pool, submits a transaction, and then 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 previous packaged block as a request parameter, so that the first computing service generates a first block certificate based on the hash value of the previous 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 the 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; wherein the block header is the metadata storage part of the block, which is mainly used to identify, verify and describe the block content. The following are the main fields contained 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 RLP-encoded hash value 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 dictionary tree, calculated by the transaction hash 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 and provides evidence of the transaction execution result; (5) Time: The Unix timestamp generated by the block. It records the time when the block was mined; (6) Number: The block number. Indicates the location of the block in the blockchain; (7) Bloom: Bloom filter, quickly locates whether a log is in this block. It provides an efficient way to check whether a piece of data exists in a set without providing a complete data set. The block body contains all transactions packaged in the block. Each transaction on the blockchain is stored in a block and is verified and packaged using a specific data structure and algorithm.

[0092] In this embodiment, the block header has a new field: tpr, which contains the time proof credential generated by the first computing service and the second computing service. For blocks without this credential, the random number collection contract transactions packaged in the block are invalid and not counted in the random number aggregation. For different blocks A and B, if there is a block with high BHA <BHB,则必须要求end_timeA<start_timeB。

[0093] In this embodiment, the on-chain node needs to have a valid time proof credential written into the tpr field of the block header for each newly created block, which is used as a non-interactive global trusted timestamp for random number collection. Therefore, each on-chain node needs to call the first computing service immediately after the previous block is packaged, and its request parameter x is the Merkle tree root or block hash (in the case of non-Merkle tree) of the previous block 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 second half of the time proof credential for block generation, namely the second block proof including the end time of the creation of the new block. Then, the first block proof and the second block proof are combined into a complete time proof credential and written into the time proof credential field tpr of the current block header. The specific example is shown in Table 1:

[0096] Table 1. Block instances

[0097]

[0098] Among them, the start_time of the time proof certificate in the block header of a valid 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, in addition to performing regular blockchain verification (verifying the Merkle tree root, block hash, transaction signature, etc. of the block), other consensus nodes 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 certificate of this block.

[0102] (2) For each random number transaction in the block, the verification process of the random number transaction submitted by the on-chain node n from the random number generator i is used to check whether the random number is credible and verify its time proof credentials.

[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 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, and both must be accompanied by time proof credentials: (1) the collection transaction initiated by the random number user; (2) the upload random number transaction request initiated by an external account; the contract collects and stores its 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] To summarize, this application provides a trusted 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 block on the chain. 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 independent 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 the 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.

[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 with a start_time greater than the end_time of transaction s. In this case, it means that the packaging node intentionally ignored its own random number submission result and selected the newer transaction to be included in 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 (perhaps 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 condition: Producer i receives accept_claim from node n and submits transaction s, but does not receive accept_submit or reject_submit before the block is mined, and there is a transaction in the latest block with a start_time greater than the end_time of transaction s. This situation is similar to the above case, where node n is intentionally delaying. In this case, the producer can directly initiate a reconsideration against node n.

[0117] 3. The node maliciously rejects a random number submission transaction reply.

[0118] Judgment condition: Producer i receives accept_claim from node n and submits transaction s, but receives a reject_submit for no apparent reason. In this case, regardless of whether a new block has been produced, as long as producer i confirms that its local computation is correct, it can be considered that node n has maliciously rejected the request. In this case, the producer can directly initiate a reconsideration against node n.

[0119] It should be noted that the review 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 attack 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 the non-interactive time-delayed proof of credentials implemented by two computing services. On the premise of ensuring the credibility of the random number generation and aggregation processes, it also ensures that the random number collection within the specified time limit is difficult to be interfered with by malicious blockchain nodes; 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; FIG. Figure 6 As shown, the device includes:

[0121] A computing service construction module 610 is 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 is configured to, when a random number collection request is received in a random number collection contract on a blockchain, generate a transaction start time corresponding to the random number collection request using the first computing service, generate a sub-random number using a verifiable random function, and generate a transaction end time corresponding to the random number collection request using the second computing service by at least two random number generators;

[0123] Transaction generation module 630, configured for the random number generator to generate a random number submission transaction based on the transaction start time, the sub-random number, and the transaction end time, and submit the transaction 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;

[0124] The block packaging module 640 is configured to generate a block creation time corresponding to the new block according to the first computing service when the on-chain node creates a new block, obtain a random number to be packaged from the local transaction pool, and then generate a block packaging time corresponding to the new block according to the second computing service after submitting a transaction;

[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 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 end 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 according to 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 into the random access memory (RAM) 1003, such as executing the method described in the above embodiment. Various programs and data required for system operation are also stored in the RAM 1003. The CPU 1001, ROM 1002 and RAM 1003 are connected to each other via a bus 1004. An 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, and the like; an output section 1007 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 1008 including a hard disk and the like; and a communication section 1009 including a network interface card such as a LAN (Local Area Network) card or a modem. 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. Removable media 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 1010 as needed, so that computer programs read therefrom can be 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 via the communication section 1009, and / or installed from a removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, the 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 embodiments 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 that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable computer program. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. A computer program embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, or any suitable combination thereof.

[0133] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. Among them, each box in the flowchart or block diagram can represent a module, program segment, or part of the code, and the above-mentioned module, program segment, or part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that 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 the 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. In some cases, the names of these units do not 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. Ordinary technicians in this field can easily make corresponding changes or modifications based on the main ideas 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 start time and a second computing service for generating a proof of end time; When a random number collection request is present 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 based on the transaction start time, the sub-random number, and the transaction end time, submits the transaction to the on-chain node, and writes the random number submission transaction into the local transaction pool after the on-chain node successfully verifies the trustworthiness of the sub-random number; 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, submits a transaction, and then generates a block packaging time corresponding to the new block according to the second computing service; The consensus node verifies the new block based on 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 computational service for generating proof of start time includes: Generate a calculation process based on the received request parameters; Using the current time as the start time of the calculation process and generating a calculation order number based on the start time; Generate 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; 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: Obtaining a calculation process corresponding to the calculation order number according to the received 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 based on 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, wherein 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 calls the first computing service and the second computing service in sequence, 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 certificate in the random number collection request is 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 to call the first computing service, causing the first computing service to generate a first certification certificate based on the transaction hash value; wherein the first certification certificate includes the transaction start time; The random number generator generates a declaration request based on the transaction hash value, the random identifier, and the first certification certificate, and enables the on-chain node to perform declaration verification based on 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 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 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 based on the transaction start time, the sub-random number, and the transaction end time, and submits it to the on-chain node. After the on-chain node successfully verifies the trustworthiness of the sub-random number, it writes the random number submission transaction into the local transaction pool, including: The random number generator generates a target certification certificate using the first certification certificate and the second certification certificate; The random number generator submits the target certification certificate, the sub-random number and the random number generated by the random number certification 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 on-chain node verifies the calculation proof and the calculation result; When it is determined that the calculation proof and the calculation result are generated by the request parameters, verifying the end time signature in the target proof certificate using the on-chain public key; When it is determined that the end time signature is a concatenation of the calculation result, the calculation proof, the start time, and the end time character strings, verifying the sub-random number and the random number proof using 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, 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 based on the hash value of the previous packaged block as a request parameter, so that the first computing service generates a first block certificate based on the hash value of the previous packaged block. 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 end time of the creation 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, causing 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 random number submission transaction submitted by it does not exist in the new block 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 can review 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, configured 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 a random number collection request is present in a random number collection contract on a blockchain, generate a transaction start time corresponding to the random number collection request using the first computing service, generate a sub-random number using a verifiable random function, and generate a transaction end time corresponding to the random number collection request using the second computing service by at least two random number generators; A transaction generation module is configured for the random number generator to generate a random number submission transaction based on the transaction start time, the sub-random number, and the transaction end time, and submit the random number submission transaction 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; A block packaging module, configured to generate a block creation time corresponding to the new block according to the first computing service when the on-chain node creates a new block, obtain a random number to be packaged from the local transaction pool, and generate a block packaging time corresponding to the new block according to the second computing service after submitting a transaction; 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 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 end 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 according to 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 of block chain network service platform, and storage medium

    CN115694802A