WO2023109520A1 - Random number generation method and apparatus based on blockchain - Google Patents

Random number generation method and apparatus based on blockchain Download PDF

Info

Publication number
WO2023109520A1
WO2023109520A1 PCT/CN2022/135838 CN2022135838W WO2023109520A1 WO 2023109520 A1 WO2023109520 A1 WO 2023109520A1 CN 2022135838 W CN2022135838 W CN 2022135838W WO 2023109520 A1 WO2023109520 A1 WO 2023109520A1
Authority
WO
WIPO (PCT)
Prior art keywords
random number
signature
smart contract
generating
seed
Prior art date
Application number
PCT/CN2022/135838
Other languages
French (fr)
Chinese (zh)
Inventor
赵文强
冯禺豪
李彤
李艳鹏
陆旭明
Original Assignee
支付宝(杭州)信息技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 支付宝(杭州)信息技术有限公司 filed Critical 支付宝(杭州)信息技术有限公司
Publication of WO2023109520A1 publication Critical patent/WO2023109520A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3825Use of electronic signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/58Random or pseudo-random number generators
    • G06F7/588Random number generators, i.e. based on natural stochastic processes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3829Payment protocols; Details thereof insuring higher security of transaction involving key management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/40Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
    • G06Q20/401Transaction verification

Definitions

  • This document relates to the field of blockchain technology, and in particular to a method and device for generating random numbers based on blockchain.
  • Blockchain is a decentralized distributed ledger that stores data in units of blocks and connects them in chronological order to form a chain structure. At the same time, it uses cryptography to ensure that it cannot be tampered with, cannot be forged, and data transmission and access are secure. Due to the characteristics of decentralization of blockchain technology, each computing node can participate in data recording, and fast data synchronization between computing nodes, blockchain is widely used in many fields.
  • One or more embodiments of this specification provide a random number generation method based on blockchain, which is applied to blockchain nodes, and the method includes: receiving a transaction carrying a request for generating a random number, and the request for generating a random number Carries a random number seed; calls the corresponding smart contract based on the transaction, and executes the corresponding smart contract through the virtual machine, the smart contract includes generating a number of participants for triggering participation in random number generation.
  • a signature instruction for performing multi-party cooperative signature ; obtaining an aggregate signature obtained by multiple participants responding to the signature instruction to perform multi-party cooperative signature on the random number seed, and generating a random number based on the obtained multiple aggregate signatures.
  • One or more embodiments of this specification provide a block chain-based random number generation device running on a block chain node, the device includes: a transaction receiving module configured to receive a transaction carrying a request for generating a random number , the request for generating a random number carries a random number seed; the smart contract calling module is configured to call a corresponding smart contract based on the transaction, and execute the corresponding smart contract through a virtual machine, the smart contract includes generating a trigger for triggering Multiple participants participating in the random number generation perform a multi-party cooperative signature instruction on the random number seed; obtain an aggregate signature obtained by multiple participants responding to the signature instruction to perform a multi-party cooperative signature on the random number seed, and Generate a random number based on the obtained multiple aggregated signatures.
  • One or more embodiments of this specification provide a block chain-based random number generation device, including: a processor; and a memory configured to store computer-executable instructions, and the computer-executable instructions when executed Make the processor: receive a transaction carrying a request for generating a random number, the request for generating a random number carries a random number seed; call a corresponding smart contract based on the transaction, and execute the corresponding smart contract through a virtual machine, the The smart contract includes generating a signature instruction for triggering multiple participants participating in random number generation to perform multi-party collaborative signature on the random number seed; obtaining multiple participants to respond to the signature instruction to perform multi-party coordination on the random number seed Sign the obtained aggregated signature, and generate a random number based on the obtained multiple aggregated signatures.
  • One or more embodiments of this specification provide a storage medium for storing computer-executable instructions.
  • the computer-executable instructions When the computer-executable instructions are executed by a processor, the following process is implemented: a transaction carrying a request for generating a random number is received, and the The random number generation request mentioned above carries a random number seed; the corresponding smart contract is invoked based on the transaction, and the corresponding smart contract is executed through the virtual machine.
  • the random number seed performs a multi-party cooperative signature signature instruction; obtains an aggregate signature obtained by multiple participants responding to the signature instruction to perform a multi-party cooperative signature on the random number seed, and generates a random number based on the obtained multiple aggregate signatures. number.
  • Fig. 1 is a processing flowchart of a block chain-based random number generation method provided by one or more embodiments of this specification;
  • FIG. 2 is a flowchart of a blockchain-based random number generation method applied to a lottery scenario provided by one or more embodiments of this specification;
  • FIG. 3 is a schematic diagram of a block chain-based random number generator provided by one or more embodiments of this specification;
  • Fig. 4 is a schematic structural diagram of a block chain-based random number generation device provided by one or more embodiments of this specification.
  • An embodiment of a block chain-based random number generation method provided in this specification starts from the transaction for random number generation, calls the corresponding smart contract, and passes Execute smart contracts for random number generation, so as to reach a consensus on multi-party collaborative generation of random numbers with the help of blockchain, specifically generate aggregate signatures through multi-party collaborative signatures on random number seeds, and generate random numbers on the basis of aggregate signatures, so that participants
  • the multiple parties that generate the random number reach a consensus on the aggregated signature, ensuring that the random number generated on the basis of the aggregated signature also undergoes a multi-party consensus, thereby improving the correctness of the random number generation.
  • the smart contract for random number generation it improves Traceability of the random number generation process.
  • the blockchain-based random number generation method provided in this embodiment is applied to blockchain nodes, and specifically includes steps S102 to S104.
  • Step S102 receiving a transaction carrying a request to generate a random number.
  • the transaction carrying the random number generation request can be sent by the trusted execution environment.
  • the trusted execution environment After receiving the random number generation request submitted by the client, the trusted execution environment generates a random number seed for the random number generation request. And send the transaction carrying the random number seed in the random number generation request to the block chain node; in addition, the client connected to the block chain node can also send the transaction carrying the random number generation request.
  • the request for generating a random number carries a random number seed, and the random number seed refers to reference data for generating a random number.
  • the random number seed is generated by the trusted execution environment according to the random number generation request.
  • Step S104 calling the corresponding smart contract based on the transaction, and executing the corresponding smart contract through the virtual machine.
  • the smart contract includes the contract logic included in the smart contract, or the business process realized by executing the smart contract.
  • the smart contract includes: generating a signature instruction for triggering a plurality of participants participating in random number generation to perform a multi-party cooperative signature on the random number seed; obtaining a plurality of participants responding to the signature instruction to The above random number seeds are used to perform multi-party cooperative signatures to obtain aggregated signatures, and generate random numbers based on the obtained multiple aggregated signatures.
  • the multi-party cooperative signature refers to the random number signatures obtained by signing the random number seeds by multiple participants participating in the random number generation, and combining the random number signatures obtained by their own signatures with the random number signatures obtained by other participants' signatures.
  • the participating parties participating in random number generation are multiple parties.
  • multiple participating parties participating in random number generating are block chain nodes.
  • each participating party (block chain node) is the same, the following takes the processing of any one of the multiple participants in the random number generation process as an example to illustrate the random number generation process in which multiple participants participate.
  • the processing process of any participant in the random number generation process provided below, and will not repeat them here.
  • the participants involved in random number generation may not be blockchain nodes.
  • multiple participants involved in random number generation must also be blockchain users. That is, it has a corresponding blockchain account, so that a consensus can be reached on the basis of the blockchain account to generate random numbers with the help of multiple parties.
  • any one or more of the multiple participants responding to the signature instruction to perform a multi-party cooperative signature on the random number seed includes: using private key fragmentation Sign the random number seed to obtain a first random number signature, and the private key fragment is pre-generated by the participant and other participants based on the distributed key agreement; send the first random number signature to the other participants Participants, and receive the first random number signature from other participants as the second random number signature; when the received second random number signature meets the aggregation condition, the received second random number signature together with the first random number Aggregation of signatures results in aggregated signatures.
  • the i-th participant (blockchain node) participating in the random number generation uses the following algorithm for signature processing:
  • p_i is the signature share of the i-th participant, which is also the random number signature of the i-th participant;
  • the i-th participant aggregates the signature share p_i generated by itself and the signature shares synchronized by t participants into an aggregated signature p in the following way:
  • p_1, ...., p_t are the received signature shares of t participants synchronized in turn;
  • the distributed key agreement is implemented to generate the encryption of each participant involved in random number generation.
  • Key sharding specifically, the private key sharding used by the participants to sign the random number seed is pre-generated by all participants based on the distributed key agreement, and the key is generated in the following way:
  • KenGen(n, t) (pk, pk_1, pk_2, ..., pk_n)
  • n is the total number of all participants
  • t is the number of untrusted nodes
  • the pk output by the algorithm KenGen() is the shared public key
  • pk_1, pk_2, ..., pk_n are the 1st to nth participants in turn Private key sharding.
  • the number of nodes is configured to ensure the data security of the random number generation process. For example, if the number of nodes of untrusted nodes is configured as 0, it indicates that the current data scene does not accept untrusted nodes; if the number of nodes of untrusted nodes is configured as 2, then It shows that the current data scenario can accept two untrusted nodes in the blockchain, that is, random numbers can still be generated even if there are two untrusted nodes in the blockchain, so as to improve the efficiency of the random number generation process. robustness.
  • the trusted execution environment uses the private key to pair the The random number seed is signed, and the digital signature of the random number seed is obtained.
  • the blockchain node performs signature verification in the process of calling the smart contract to generate the random number, so as to detect whether the random number seed has been tampered with during the sending process.
  • the smart contract also includes: The authenticity of the random number seed; after the verification is passed, a signature instruction for triggering the participants participating in the random number generation to perform a multi-party cooperative signature on the random number seed is generated.
  • the random number seed carried in the random number generation request has a private key signature obtained by signing with the trusted execution environment, and the verifying the authenticity of the random number seed includes using the trusted execution environment Signature verification with the public key corresponding to the private key.
  • generating random numbers based on the obtained multiple aggregated signatures includes: when the same number of multiple acquired aggregated signatures meets certain conditions, based on the same The aggregated signature generates random numbers; wherein, the same number in multiple aggregated signatures meets certain conditions, including the same number in multiple aggregated signatures is greater than or equal to the number of untrusted nodes.
  • the same aggregated signature can be used as a random number.
  • the data form of the random number may be a character string, or other data forms other than the character string.
  • the authenticity of the aggregated signatures is verified by means of signature verification.
  • the shared public key obtained after the execution of the distributed key The aggregated signature is verified, so as to ensure that the participants who perform the random number signature, signature aggregation, and aggregated signature synchronization are the participants who reach a consensus.
  • the smart contract also includes: using the shared public key to verify the multiple An aggregated signature, the shared public key is pre-generated collaboratively by the multiple participants based on the distributed key agreement; and the random number is generated based on the multiple aggregated signatures after the verification is passed.
  • the generation of random numbers in many business scenarios often serves the actual business.
  • the generation of random numbers serves the demand for random numbers in lottery or lottery scenarios. Therefore, after the random number is generated, the generated random number Request to return the generated random number so that the business can access the random number.
  • the identifier carried in the random number generation request record the random number and use it as the random number corresponding to the identifier.
  • the request to generate a random number returns a request response carrying the random number. For example, if the transaction for generating a random number request is sent by the client, according to the task ID carried in the request for generating a random number, record the generated random number as the random number corresponding to the task ID, and return the transaction carrying the random number to the client. Number of request responses.
  • the block chain-based random number generation method on the basis of the received transaction carrying the request to generate a random number, calls the corresponding smart contract based on the transaction and executes the called smart contract to perform Random number generation, specifically in the random number generation process, starting from the random number seed carried in the random number generation request, generating a signature instruction for multi-party cooperative signature on the random number seed, and multiple participants
  • the aggregated signatures obtained by collaborative signatures are aggregated into random numbers, so as to reach the consensus of multiple participants on random number generation, which effectively improves the correctness and legitimacy of random number generation.
  • random number generation is performed by executing smart contracts.
  • the random number generation process is traceable, which improves the security of the random number generation process; further, by executing the distributed key agreement, the private key fragments for signing the random number seeds are generated, and the authenticity of the aggregated signature is verified
  • the shared public key ensures that the random number seed and aggregate signature are consensused by multiple parties, which helps to further improve the security of the random number generation process and the legitimacy of random number generation.
  • Step S202 receiving a transaction carrying a request for generating a random number sent by the Trusted Execution Environment.
  • the random number generation request carries a random number seed
  • the random number seed is generated by the trusted execution environment according to the random number generation request submitted by the lottery client, and has a private key signature obtained by signing the trusted execution environment.
  • Step S204 call the corresponding smart contract based on the transaction.
  • Sub-step S204-2 using the public key corresponding to the private key of the trusted execution environment to perform signature verification on the random number seed.
  • Sub-step S204-4 after the verification is passed, generate a signature instruction for triggering the participants participating in the random number generation to perform a multi-party cooperative signature on the random number seed.
  • Sub-step S204-6 using the private key fragment to sign the random number seed to obtain the first random number signature.
  • the private key fragment is pre-generated by the participant and other participants based on the distributed key agreement.
  • Sub-step S204-8 sending the first random number signature to the remaining participants, and receiving the first random number signature from the remaining participants as the second random number signature.
  • Sub-step S204-10 when the received second random number signature satisfies the aggregation condition, aggregate the received second random number signature together with the first random number signature to obtain an aggregated signature.
  • sub-step S204-12 when the same number among the obtained multiple aggregated signatures meets a certain condition, the same aggregated signature is used as a target signature, and a random number is generated based on the target signature.
  • An embodiment of a block chain-based random number generation device provided in this specification is as follows: In the above-mentioned embodiment, a block chain-based random number generation method is provided, and correspondingly, a A block chain-based random number generating device, which will be described below with reference to the accompanying drawings.
  • FIG. 3 it shows a schematic diagram of a block chain-based random number generating device provided in this embodiment.
  • the description is relatively simple. For relevant parts, please refer to the corresponding description of the method embodiment provided above.
  • the device embodiments described below are illustrative only.
  • This embodiment provides a block chain-based random number generating device, including: a transaction receiving module 302 configured to receive a transaction carrying a request for generating a random number, the request for generating a random number carries a random number seed; a smart contract
  • the calling module 304 is configured to call a corresponding smart contract based on the transaction, and execute the corresponding smart contract through a virtual machine, the smart contract includes: generating a pair of random A signature instruction for performing multi-party cooperative signature on the number seed; obtaining an aggregate signature obtained by multiple participants responding to the signature instruction to perform multi-party cooperative signature on the random number seed, and generating a random number based on the obtained multiple aggregate signatures.
  • An embodiment of a block chain-based random number generation device provided in this specification is as follows: Corresponding to a block chain-based random number generation method described above, based on the same technical concept, one or more embodiments of this specification also Provide a block chain-based random number generation device, the block chain-based random number generation device is used to implement the block chain-based random number generation method provided above, Figure 4 shows one or more embodiments of this specification A schematic structural diagram of a block chain-based random number generation device is provided.
  • a block chain-based random number generating device includes: as shown in FIG. or more than one processor 401 and memory 402, and one or more storage application programs or data may be stored in the memory 402.
  • the storage 402 may be a short-term storage or a persistent storage.
  • the application program stored in the memory 402 may include one or more modules (not shown in the figure), and each module may include a series of computer-executable instructions in the block chain-based random number generating device.
  • the processor 401 can be configured to communicate with the memory 402, and execute a series of computer-executable instructions in the memory 402 on the blockchain-based random number generating device.
  • the block chain-based random number generating device may also include one or more power sources 403, one or more wired or wireless network interfaces 404, one or more input/output interfaces 405, one or more keyboards 406, and the like.
  • the block chain-based random number generating device includes a memory, and one or more programs, wherein one or more programs are stored in the memory, and one or more programs may include one or more More than one module, and each module may include a series of computer-executable instructions in the block chain-based random number generating device, and is configured to be executed by one or more processors.
  • the one or more programs include for Performing the following computer-executable instructions: receiving a transaction carrying a request for generating a random number, the request for generating a random number carrying a random number seed; calling a corresponding smart contract based on the transaction, and executing the corresponding smart contract through a virtual machine,
  • the smart contract includes: generating a signature instruction for triggering a plurality of participants participating in random number generation to perform a multi-party cooperative signature on the random number seed; The aggregated signature obtained by multi-party cooperative signature, and the random number is generated based on the obtained multiple aggregated signatures.
  • An example of a storage medium provided in this specification is as follows: Corresponding to a block chain-based random number generation method described above, based on the same technical concept, one or more embodiments of this specification also provide a storage medium.
  • the storage medium provided in this embodiment is used to store computer-executable instructions, and when the computer-executable instructions are executed by a processor, the following process is implemented: receiving a transaction carrying a request for generating a random number, and the request for generating a random number carries a A random number seed; calling a corresponding smart contract based on the transaction, and executing the corresponding smart contract through a virtual machine, the smart contract includes: generating a plurality of participants used to trigger participation in random number generation to perform random number seed A signature command signed by multiple parties; obtaining an aggregated signature obtained by multiple parties responding to the signature command to perform multiple collaborative signatures on the random number seed, and generating a random number based on the multiple aggregated signatures obtained.
  • the improvement of a technology can be clearly distinguished as an improvement in hardware (for example, improvements in circuit structures such as diodes, transistors, switches, etc.) or improvements in software (improvement in method flow).
  • improvements in many current method flows can be regarded as the direct improvement of the hardware circuit structure.
  • Designers almost always get the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be realized by hardware physical modules.
  • a Programmable Logic Device such as a Field Programmable Gate Array (FPGA)
  • FPGA Field Programmable Gate Array
  • HDL Hardware Description Language
  • the controller may be implemented in any suitable way, for example the controller may take the form of a microprocessor or processor and a computer readable medium storing computer readable program code (such as software or firmware) executable by the (micro)processor , logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controllers, and embedded microcontrollers, examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the control logic of the memory.
  • ASIC Application Specific Integrated Circuit
  • controller in addition to realizing the controller in a purely computer-readable program code mode, it is entirely possible to make the controller use logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded The same function can be realized in the form of a microcontroller or the like. Therefore, such a controller can be regarded as a hardware component, and the devices included in it for realizing various functions can also be regarded as structures within the hardware component. Or even, means for realizing various functions can be regarded as a structure within both a software module realizing a method and a hardware component.
  • a typical implementing device is a computer.
  • the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or Combinations of any of these devices.
  • one or more embodiments of this specification may be provided as a method, system or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions
  • the device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
  • a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • Memory may include non-permanent storage in computer readable media, in the form of random access memory (RAM) and/or nonvolatile memory such as read-only memory (ROM) or flash RAM. Memory is an example of computer readable media.
  • RAM random access memory
  • ROM read-only memory
  • flash RAM flash random access memory
  • Computer-readable media including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information.
  • Information may be computer readable instructions, data structures, modules of a program, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, A magnetic tape cartridge, disk storage or other magnetic storage device or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
  • computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.
  • program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types.
  • program modules may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network.
  • program modules may be located in both local and remote computer storage media including storage devices.

Landscapes

  • Business, Economics & Management (AREA)
  • Engineering & Computer Science (AREA)
  • Accounting & Taxation (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Finance (AREA)
  • General Business, Economics & Management (AREA)
  • Strategic Management (AREA)
  • Computer Security & Cryptography (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

Provided are a random number generation method and apparatus based on a blockchain. The method is applied to a blockchain node, and comprises: receiving a transaction carrying a random number generation request, wherein the random number generation request carries a random number seed; and calling a corresponding smart contract on the basis of the transaction, and executing the corresponding smart contract by means of a virtual machine. The smart contract comprises: generating a signing instruction for triggering a plurality of participants, which participate in random number generation, to perform multi-party collaborative signing on the random number seed; and acquiring aggregated signatures obtained by means of the plurality of participants performing multi-party collaborative signing on the random number seed in response to the signing instruction, and generating a random number on the basis of the plurality of acquired aggregated signatures.

Description

[根据细则37.2由ISA制定的发明名称] 基于区块链的随机数生成方法及装置[Title of the invention made by the ISA under Rule 37.2] Blockchain-based random number generation method and device 技术领域technical field
本文件涉及区块链技术领域,尤其涉及一种基于区块链的随机数生成方法及装置。This document relates to the field of blockchain technology, and in particular to a method and device for generating random numbers based on blockchain.
背景技术Background technique
区块链是一种数据以区块为单位进行存储,并按照时间顺序收尾相连形成链式结构,同时通过密码学保证不可篡改、不可伪造以及数据传输访问安全的去中心化分布式账本。由于区块链技术具有去中心化、各计算节点可以参与数据记录、并且各计算节点之间可以快速的进行数据同步的特性,使得区块链在众多的领域中广泛的进行应用。Blockchain is a decentralized distributed ledger that stores data in units of blocks and connects them in chronological order to form a chain structure. At the same time, it uses cryptography to ensure that it cannot be tampered with, cannot be forged, and data transmission and access are secure. Due to the characteristics of decentralization of blockchain technology, each computing node can participate in data recording, and fast data synchronization between computing nodes, blockchain is widely used in many fields.
发明内容Contents of the invention
本说明书一个或多个实施例提供了一种基于区块链的随机数生成方法,应用于区块链节点,所述方法包括:接收携带有生成随机数请求的交易,所述生成随机数请求携带有随机数种子;基于所述交易调用相应的智能合约,并通过虚拟机执行该相应的智能合约,该智能合约包括生成用于触发参与随机数生成的多个参与方对所述随机数种子进行多方协同签名的签名指令;获取多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名得到的聚合签名,并基于获取到的多个聚合签名生成随机数。One or more embodiments of this specification provide a random number generation method based on blockchain, which is applied to blockchain nodes, and the method includes: receiving a transaction carrying a request for generating a random number, and the request for generating a random number Carries a random number seed; calls the corresponding smart contract based on the transaction, and executes the corresponding smart contract through the virtual machine, the smart contract includes generating a number of participants for triggering participation in random number generation. A signature instruction for performing multi-party cooperative signature; obtaining an aggregate signature obtained by multiple participants responding to the signature instruction to perform multi-party cooperative signature on the random number seed, and generating a random number based on the obtained multiple aggregate signatures.
本说明书一个或多个实施例提供了一种基于区块链的随机数生成装置,运行于区块链节点,所述装置包括:交易接收模块,被配置为接收携带有生成随机数请求的交易,所述生成随机数请求携带有随机数种子;智能合约调用模块,被配置为基于所述交易调用相应的智能合约,并通过虚拟机执行该相应的智能合约,该智能合约包括生成用于触发参与随机数生成的多个参与方对所述随机数种子进行多方协同签名的签名指令;获取多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名得到的聚合签名,并基于获取到的多个聚合签名生成随机数。One or more embodiments of this specification provide a block chain-based random number generation device running on a block chain node, the device includes: a transaction receiving module configured to receive a transaction carrying a request for generating a random number , the request for generating a random number carries a random number seed; the smart contract calling module is configured to call a corresponding smart contract based on the transaction, and execute the corresponding smart contract through a virtual machine, the smart contract includes generating a trigger for triggering Multiple participants participating in the random number generation perform a multi-party cooperative signature instruction on the random number seed; obtain an aggregate signature obtained by multiple participants responding to the signature instruction to perform a multi-party cooperative signature on the random number seed, and Generate a random number based on the obtained multiple aggregated signatures.
本说明书一个或多个实施例提供了一种基于区块链的随机数生成设备,包括:处理器;以及,被配置为存储计算机可执行指令的存储器,所述计算机可执行指令在被执行时使所述处理器:接收携带有生成随机数请求的交易,所述生成随机数请求携带有随机数种子;基于所述交易调用相应的智能合约,并通过虚拟机执行该相应的智能合约,该智能合约包括生成用于触发参与随机数生成的多个参与方对所述随机数种子进行多方 协同签名的签名指令;获取多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名得到的聚合签名,并基于获取到的多个聚合签名生成随机数。One or more embodiments of this specification provide a block chain-based random number generation device, including: a processor; and a memory configured to store computer-executable instructions, and the computer-executable instructions when executed Make the processor: receive a transaction carrying a request for generating a random number, the request for generating a random number carries a random number seed; call a corresponding smart contract based on the transaction, and execute the corresponding smart contract through a virtual machine, the The smart contract includes generating a signature instruction for triggering multiple participants participating in random number generation to perform multi-party collaborative signature on the random number seed; obtaining multiple participants to respond to the signature instruction to perform multi-party coordination on the random number seed Sign the obtained aggregated signature, and generate a random number based on the obtained multiple aggregated signatures.
本说明书一个或多个实施例提供了一种存储介质,用于存储计算机可执行指令,所述计算机可执行指令在被处理器执行时实现以下流程:接收携带有生成随机数请求的交易,所述生成随机数请求携带有随机数种子;基于所述交易调用相应的智能合约,并通过虚拟机执行该相应的智能合约,该智能合约包括生成用于触发参与随机数生成的多个参与方对所述随机数种子进行多方协同签名的签名指令;获取多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名得到的聚合签名,并基于获取到的多个聚合签名生成随机数。One or more embodiments of this specification provide a storage medium for storing computer-executable instructions. When the computer-executable instructions are executed by a processor, the following process is implemented: a transaction carrying a request for generating a random number is received, and the The random number generation request mentioned above carries a random number seed; the corresponding smart contract is invoked based on the transaction, and the corresponding smart contract is executed through the virtual machine. The random number seed performs a multi-party cooperative signature signature instruction; obtains an aggregate signature obtained by multiple participants responding to the signature instruction to perform a multi-party cooperative signature on the random number seed, and generates a random number based on the obtained multiple aggregate signatures. number.
附图说明Description of drawings
为了更清楚地说明本说明书一个或多个实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate one or more embodiments of this specification or the technical solutions in the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, in the following description The accompanying drawings are only some embodiments described in this specification, and those skilled in the art can also obtain other drawings according to these drawings without any creative work.
图1为本说明书一个或多个实施例提供的一种基于区块链的随机数生成方法处理流程图;Fig. 1 is a processing flowchart of a block chain-based random number generation method provided by one or more embodiments of this specification;
图2为本说明书一个或多个实施例提供的一种应用于抽签场景的基于区块链的随机数生成方法处理流程图;FIG. 2 is a flowchart of a blockchain-based random number generation method applied to a lottery scenario provided by one or more embodiments of this specification;
图3为本说明书一个或多个实施例提供的一种基于区块链的随机数生成装置示意图;FIG. 3 is a schematic diagram of a block chain-based random number generator provided by one or more embodiments of this specification;
图4为本说明书一个或多个实施例提供的一种基于区块链的随机数生成设备的结构示意图。Fig. 4 is a schematic structural diagram of a block chain-based random number generation device provided by one or more embodiments of this specification.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本说明书一个或多个实施例中的技术方案,下面将结合本说明书一个或多个实施例中的附图,对本说明书一个或多个实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本说明书的一部分实施例,而不是全部的实施例。基于本说明书一个或多个实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本文件的保护范围。In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the following will describe the technical solutions in one or more embodiments of this specification in conjunction with the drawings in one or more embodiments of this specification The technical solution is clearly and completely described, and obviously, the described embodiments are only a part of the embodiments in this specification, rather than all the embodiments. Based on one or more embodiments in this specification, all other embodiments obtained by persons of ordinary skill in the art without creative efforts shall fall within the scope of protection of this document.
本说明书提供的一种基于区块链的随机数生成方法实施例:本实施例提供的基于区块链的随机数生成方法,从进行随机数生成的交易出发,调用相应的智能合约,并通过执行智能合约进行随机数生成,以此借助区块链达成多方协同生成随机数的共识,具体通过对随机数种子进行多方协同签名生成聚合签名,在聚合签名的基础上进行随机数生成,使参与随机数生成的多方达成对聚合签名的共识,确保在聚合签名基础上生成的随机数同样经过多方共识,从而提升了随机数生成的正确性,同时,通过执行智能合约进行随机数生成,提升了随机数生成过程的可追溯性。An embodiment of a block chain-based random number generation method provided in this specification: The block chain-based random number generation method provided in this embodiment starts from the transaction for random number generation, calls the corresponding smart contract, and passes Execute smart contracts for random number generation, so as to reach a consensus on multi-party collaborative generation of random numbers with the help of blockchain, specifically generate aggregate signatures through multi-party collaborative signatures on random number seeds, and generate random numbers on the basis of aggregate signatures, so that participants The multiple parties that generate the random number reach a consensus on the aggregated signature, ensuring that the random number generated on the basis of the aggregated signature also undergoes a multi-party consensus, thereby improving the correctness of the random number generation. At the same time, by executing the smart contract for random number generation, it improves Traceability of the random number generation process.
参照图1,本实施例提供的基于区块链的随机数生成方法,应用于区块链节点,具体包括步骤S102至步骤S104。Referring to FIG. 1 , the blockchain-based random number generation method provided in this embodiment is applied to blockchain nodes, and specifically includes steps S102 to S104.
步骤S102,接收携带有生成随机数请求的交易。Step S102, receiving a transaction carrying a request to generate a random number.
具体实施时,携带所述生成随机数请求的交易,可由可信执行环境发送,比如可信执行环境在接收到客户端提交的生成随机数请求之后,针对该生成随机数请求生成随机数种子,并向区块链节点发送生成随机数请求中携带随机数种子的交易;除此之外,也可由区块链节点连接的客户端发送携带所述生成随机数请求的交易。所述生成随机数请求携带有随机数种子,所述随机数种子,是指用于生成随机数的基准数据。为保证随机数种子的随机性,可选的,所述随机数种子由可信执行环境针对所述生成随机数请求生成。During specific implementation, the transaction carrying the random number generation request can be sent by the trusted execution environment. For example, after receiving the random number generation request submitted by the client, the trusted execution environment generates a random number seed for the random number generation request. And send the transaction carrying the random number seed in the random number generation request to the block chain node; in addition, the client connected to the block chain node can also send the transaction carrying the random number generation request. The request for generating a random number carries a random number seed, and the random number seed refers to reference data for generating a random number. To ensure the randomness of the random number seed, optionally, the random number seed is generated by the trusted execution environment according to the random number generation request.
步骤S104,基于所述交易调用相应的智能合约,并通过虚拟机执行该相应的智能合约。Step S104, calling the corresponding smart contract based on the transaction, and executing the corresponding smart contract through the virtual machine.
本实施例中,所述该智能合约包括实际上可以理解为该智能合约所包含的合约逻辑,或者执行该智能合约所实现的业务流程。具体的,所述该智能合约包括:生成用于触发参与随机数生成的多个参与方对所述随机数种子进行多方协同签名的签名指令;获取多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名得到的聚合签名,并基于获取到的多个聚合签名生成随机数。In this embodiment, the smart contract includes the contract logic included in the smart contract, or the business process realized by executing the smart contract. Specifically, the smart contract includes: generating a signature instruction for triggering a plurality of participants participating in random number generation to perform a multi-party cooperative signature on the random number seed; obtaining a plurality of participants responding to the signature instruction to The above random number seeds are used to perform multi-party cooperative signatures to obtain aggregated signatures, and generate random numbers based on the obtained multiple aggregated signatures.
其中,所述多方协同签名,是指参与随机数生成的多个参与方,分别对随机数种子进行签名得到的随机数签名,并将自身签名获得的随机数签名与其余参与方签名获得的随机数签名进行聚合得到聚合签名的过程。Wherein, the multi-party cooperative signature refers to the random number signatures obtained by signing the random number seeds by multiple participants participating in the random number generation, and combining the random number signatures obtained by their own signatures with the random number signatures obtained by other participants' signatures. The process of aggregating digital signatures to obtain aggregated signatures.
本实施例中,参与随机数生成的参与方为多方,可选的,参与随机数生成的多个参与方均为区块链节点,在随机数生成过程中,每个参与方(区块链节点)执行的处理过 程是相同的,下述以多个参与方中的任意一个参与方在随机数生成过程中的处理为例,对多个参与方参与的随机数生成过程进行说明,该参与方之外的其余参与方进行随机数生成的过程,参照下述提供的任意一个参与方在随机数生成过程中的处理过程即可,此处不再一一赘述。In this embodiment, the participating parties participating in random number generation are multiple parties. Optionally, multiple participating parties participating in random number generating are block chain nodes. In the process of generating random numbers, each participating party (block chain node) is the same, the following takes the processing of any one of the multiple participants in the random number generation process as an example to illustrate the random number generation process in which multiple participants participate. For the process of random number generation by the other participants other than the party, just refer to the processing process of any participant in the random number generation process provided below, and will not repeat them here.
此外,参与随机数生成的参与方还可不为区块链节点,在这种情况下,要实现多方协同生成随机数的共识,参与随机数生成的多个参与方还需为区块链用户,即具有相应的区块链账户,从而能够在区块链账户的基础上借助区块链达成多方协同生成随机数的共识。In addition, the participants involved in random number generation may not be blockchain nodes. In this case, in order to realize the consensus of multi-party collaborative generation of random numbers, multiple participants involved in random number generation must also be blockchain users. That is, it has a corresponding blockchain account, so that a consensus can be reached on the basis of the blockchain account to generate random numbers with the help of multiple parties.
本实施例提供的一种可选实施方式中,所述多个参与方中任意一个或多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名包括:采用私钥分片对所述随机数种子进行签名得到第一随机数签名,所述私钥分片由该参与方与其余参与方基于分布式密钥协议预先协同生成;将所述第一随机数签名发送给其余参与方,并接收来自其余参与方的第一随机数签名作为第二随机数签名;当接收到的第二随机数签名满足聚合条件时,将接收到的第二随机数签名连同第一随机数签名聚合得到聚合签名。In an optional implementation manner provided in this embodiment, any one or more of the multiple participants responding to the signature instruction to perform a multi-party cooperative signature on the random number seed includes: using private key fragmentation Sign the random number seed to obtain a first random number signature, and the private key fragment is pre-generated by the participant and other participants based on the distributed key agreement; send the first random number signature to the other participants Participants, and receive the first random number signature from other participants as the second random number signature; when the received second random number signature meets the aggregation condition, the received second random number signature together with the first random number Aggregation of signatures results in aggregated signatures.
例如,参与随机数生成的第i个参与方(区块链节点),在生成随机数请求携带的随机数种子r的基础上,根据随机数种子r以及执行分布式密钥协议生成的密钥sk_i,采用如下算法进行签名处理:For example, the i-th participant (blockchain node) participating in the random number generation, on the basis of the random number seed r carried in the random number generation request, according to the random number seed r and the key generated by executing the distributed key agreement sk_i uses the following algorithm for signature processing:
Partialsign(sk_i,r)=p_iPartialsign(sk_i, r) = p_i
p_i为第i个参与方的签名份额,该签名份额也即是第i个参与方的随机数签名;p_i is the signature share of the i-th participant, which is also the random number signature of the i-th participant;
进一步,第i个参与方在接收到t个参与方同步的签名份额之后,采用如下方式将自身生成的签名份额p_i与t个参与方同步的签名份额聚合为聚合签名p:Further, after receiving the signature shares synchronized by t participants, the i-th participant aggregates the signature share p_i generated by itself and the signature shares synchronized by t participants into an aggregated signature p in the following way:
Combine(p_1,....,p_t,p_i)=pCombine(p_1,...., p_t, p_i)=p
p_1,....,p_t依次为接收到的t个参与方同步的签名份额;p_1, ...., p_t are the received signature shares of t participants synchronized in turn;
为保证参与随机数生成的参与方在随机数生成过程中处理一致性,同时也为了增强随机数生成过程中数据安全,通过执行分布式密钥协议来生成参与随机数生成的各参与方的密钥分片,具体的,参与方对随机数种子进行签名所采用的私钥分片,由所有参与方基于分布式密钥协议预先协同生成,采用如下方式进行密钥生成:In order to ensure the consistency of the participants involved in random number generation in the process of random number generation, and to enhance data security in the process of random number generation, the distributed key agreement is implemented to generate the encryption of each participant involved in random number generation. Key sharding, specifically, the private key sharding used by the participants to sign the random number seed is pre-generated by all participants based on the distributed key agreement, and the key is generated in the following way:
KenGen(n,t)=(pk,pk_1,pk_2,....,pk_n)KenGen(n, t) = (pk, pk_1, pk_2, ..., pk_n)
n为所有参与方的总数目,t为不可信节点的数目,算法KenGen()输出的pk为共享公钥,pk_1,pk_2,....,pk_n依次为第1至第n个参与方的私钥分片。n is the total number of all participants, t is the number of untrusted nodes, the pk output by the algorithm KenGen() is the shared public key, pk_1, pk_2, ..., pk_n are the 1st to nth participants in turn Private key sharding.
考虑到实际中很多场景下区块链中会存在不可信节点,因此,为了增强随机数生成过程对不同数据场景的鲁棒性,上述通过在分布式密钥协议执行过程中对不可信节点的节点数目的配置,来保证随机数生成过程的数据安全性,比如不可信节点的节点数目的配置为0,表明当前数据场景不接受不可信节点;若不可信节点的节点数目配置为2,则表明当前数据场景能够接受区块链中存在两个不可信节点,即:在区块链中存在2个不可信节点的情况下仍然能够进行随机数的生成,以此来提升随机数生成过程的鲁棒性。Considering that there will be untrusted nodes in the blockchain in many scenarios in practice, in order to enhance the robustness of the random number generation process to different data scenarios, the above-mentioned untrusted nodes during the execution of the distributed key agreement The number of nodes is configured to ensure the data security of the random number generation process. For example, if the number of nodes of untrusted nodes is configured as 0, it indicates that the current data scene does not accept untrusted nodes; if the number of nodes of untrusted nodes is configured as 2, then It shows that the current data scenario can accept two untrusted nodes in the blockchain, that is, random numbers can still be generated even if there are two untrusted nodes in the blockchain, so as to improve the efficiency of the random number generation process. robustness.
在具体执行过程中,为避免随机数种子在传输过程中被篡改,通过签名以及签名验证机制来保证随机数种子的正确性和安全性,具体由所述可信执行环境利用私钥对所述随机数种子进行签名,获得所述随机数种子的数字签名。相应的,区块链节点在调用智能合约进行随机数生成的过程中进行签名验证,以此来检测随机数种子在发送过程中是否被篡改,可选的,所述智能合约还包括:验证所述随机数种子的真实性;在验证通过后生成用于触发参与随机数生成的参与方对所述随机数种子进行多方协同签名的签名指令。In the specific execution process, in order to prevent the random number seed from being tampered with during the transmission process, the correctness and security of the random number seed are guaranteed through the signature and signature verification mechanism. Specifically, the trusted execution environment uses the private key to pair the The random number seed is signed, and the digital signature of the random number seed is obtained. Correspondingly, the blockchain node performs signature verification in the process of calling the smart contract to generate the random number, so as to detect whether the random number seed has been tampered with during the sending process. Optionally, the smart contract also includes: The authenticity of the random number seed; after the verification is passed, a signature instruction for triggering the participants participating in the random number generation to perform a multi-party cooperative signature on the random number seed is generated.
可选的,所述生成随机数请求携带的随机数种子具有由所述可信执行环境进行签名获得的私钥签名,所述验证所述随机数种子的真实性包括采用所述可信执行环境的私钥对应的公钥进行签名验证。Optionally, the random number seed carried in the random number generation request has a private key signature obtained by signing with the trusted execution environment, and the verifying the authenticity of the random number seed includes using the trusted execution environment Signature verification with the public key corresponding to the private key.
本实施例中,通过检测进行随机数签名且进行签名聚合的参与方的数目是否满足一定条件,来检测多个参与方进行随机数签名以及签名聚合的同步性,以确保参与随机数生成的多个参与方就随机数的生成达成共识,具体的,所述基于获取到的多个聚合签名生成随机数包括:当获取到的多个聚合签名中相同的数量达到一定的条件时,基于该相同的聚合签名生成随机数;其中,多个聚合签名中相同的数量达到一定的条件,包括多个聚合签名中相同的数量大于或者等于不可信节点的节点数目。In this embodiment, by detecting whether the number of participants performing random number signing and signature aggregation meets certain conditions, the synchronization of multiple participants performing random number signatures and signature aggregation is detected, so as to ensure that the number of participants participating in random number generation Participants reach a consensus on the generation of random numbers. Specifically, generating random numbers based on the obtained multiple aggregated signatures includes: when the same number of multiple acquired aggregated signatures meets certain conditions, based on the same The aggregated signature generates random numbers; wherein, the same number in multiple aggregated signatures meets certain conditions, including the same number in multiple aggregated signatures is greater than or equal to the number of untrusted nodes.
除此之外,也可在获取到所述多个聚合签名的基础上,在获取到的多个聚合签名中相同的数量达到一定的条件时,将该相同的聚合签名作为随机数。所述随机数的数据形式可以是字符串,也可以是字符串之外的其他数据形式。In addition, on the basis of obtaining the plurality of aggregated signatures, when the same number of the obtained multiple aggregated signatures meets a certain condition, the same aggregated signature can be used as a random number. The data form of the random number may be a character string, or other data forms other than the character string.
具体实施时,在接收到多个聚合签名之后,通过签名验证的方式对聚合签名进行真实性验证,具体在验证过程中采用分布式密钥协议执行后获得的共享公钥对接收到的多 个聚合签名进行验证,以此来确保进行随机数签名、签名聚合以及聚合签名同步的参与方为达成共识的参与方,可选的,所述智能合约还包括:采用共享公钥验证所述多个聚合签名,所述共享公钥由所述多个参与方基于分布式密钥协议预先协同生成;在验证通过后基于所述多个聚合签名生成所述随机数。During the specific implementation, after receiving multiple aggregated signatures, the authenticity of the aggregated signatures is verified by means of signature verification. Specifically, in the verification process, the shared public key obtained after the execution of the distributed key The aggregated signature is verified, so as to ensure that the participants who perform the random number signature, signature aggregation, and aggregated signature synchronization are the participants who reach a consensus. Optionally, the smart contract also includes: using the shared public key to verify the multiple An aggregated signature, the shared public key is pre-generated collaboratively by the multiple participants based on the distributed key agreement; and the random number is generated based on the multiple aggregated signatures after the verification is passed.
实际应用中,很多业务场景下随机数的生成往往服务于实际的业务,比如随机数的生成服务于抽签或者抽签场景对随机数的需求,因此,在生成随机数之后,针对所述生成随机数请求返回生成的随机数,以便于业务对随机数进行访问,可选的,根据所述生成随机数请求中携带的标识,记录所述随机数并作为所述标识对应的随机数,针对所述生成随机数请求返回携带所述随机数的请求响应。比如,若生成随机数请求的交易由客户端发送,则根据生成随机数请求中携带的任务标识,记录生成的随机数并作为该任务标识对应的随机数,以及,向客户端返回携带该随机数的请求响应。In practical applications, the generation of random numbers in many business scenarios often serves the actual business. For example, the generation of random numbers serves the demand for random numbers in lottery or lottery scenarios. Therefore, after the random number is generated, the generated random number Request to return the generated random number so that the business can access the random number. Optionally, according to the identifier carried in the random number generation request, record the random number and use it as the random number corresponding to the identifier. For the The request to generate a random number returns a request response carrying the random number. For example, if the transaction for generating a random number request is sent by the client, according to the task ID carried in the request for generating a random number, record the generated random number as the random number corresponding to the task ID, and return the transaction carrying the random number to the client. Number of request responses.
综上所述,所述基于区块链的随机数生成方法,在接收的携带有生成随机数请求的交易的基础上,基于所述交易调用相应的智能合约并执行调用的智能合约,以进行随机数生成,具体在随机数生成过程中,从所述生成随机数请求中携带的随机数种子出发,生成对所述随机数种子进行多方协同签名的签名指令,并将多个参与方进行多方协同签名获得的聚合签名聚合为随机数,以此达成多个参与方对随机数生成的共识,有效提升了随机数生成的正确性、合法性,同时,通过执行智能合约进行随机数生成,使随机数的生成过程可追溯,提升了随机数生成过程的安全性;进一步,通过执行分布式密钥协议生成对所述随机数种子进行签名的私钥分片,以及对聚合签名进行真实性验证的共享公钥,保证了随机数种子和聚合签名是经过多个参与方共识的,从而有助于进一步提升随机数生成过程的安全性以及随机数生成的合法性。To sum up, the block chain-based random number generation method, on the basis of the received transaction carrying the request to generate a random number, calls the corresponding smart contract based on the transaction and executes the called smart contract to perform Random number generation, specifically in the random number generation process, starting from the random number seed carried in the random number generation request, generating a signature instruction for multi-party cooperative signature on the random number seed, and multiple participants The aggregated signatures obtained by collaborative signatures are aggregated into random numbers, so as to reach the consensus of multiple participants on random number generation, which effectively improves the correctness and legitimacy of random number generation. At the same time, random number generation is performed by executing smart contracts. The random number generation process is traceable, which improves the security of the random number generation process; further, by executing the distributed key agreement, the private key fragments for signing the random number seeds are generated, and the authenticity of the aggregated signature is verified The shared public key ensures that the random number seed and aggregate signature are consensused by multiple parties, which helps to further improve the security of the random number generation process and the legitimacy of random number generation.
下述以本实施例提供的一种基于区块链的随机数生成方法在抽签场景的应用为例,对本实施例提供的基于区块链的随机数生成方法进行进一步说明,参见图2,应用于抽签场景的基于区块链的随机数生成方法,具体包括如下步骤。The following takes the application of a blockchain-based random number generation method provided in this embodiment in the lottery scene as an example to further explain the blockchain-based random number generation method provided in this embodiment. See Figure 2. Application A block chain-based random number generation method for lottery scenarios, specifically including the following steps.
步骤S202,接收可信执行环境发送的携带有生成随机数请求的交易。Step S202, receiving a transaction carrying a request for generating a random number sent by the Trusted Execution Environment.
其中,生成随机数请求携带有随机数种子,随机数种子由可信执行环境根据抽签客户端提交的生成随机数请求生成,且具有由可信执行环境进行签名获得的私钥签名。Wherein, the random number generation request carries a random number seed, and the random number seed is generated by the trusted execution environment according to the random number generation request submitted by the lottery client, and has a private key signature obtained by signing the trusted execution environment.
步骤S204,基于交易调用相应的智能合约。Step S204, call the corresponding smart contract based on the transaction.
在调用相应的智能合约后,通过虚拟机执行该相应的智能合约,具体的,在智能合 约在=被虚拟机执行时进行下述子步骤S204-2至子步骤S204-12处理。After invoking the corresponding smart contract, execute the corresponding smart contract through the virtual machine. Specifically, when the smart contract is executed by the virtual machine, perform the following substep S204-2 to substep S204-12.
子步骤S204-2,采用可信执行环境的私钥对应的公钥对随机数种子进行签名验证。Sub-step S204-2, using the public key corresponding to the private key of the trusted execution environment to perform signature verification on the random number seed.
子步骤S204-4,在验证通过后生成用于触发参与随机数生成的参与方对随机数种子进行多方协同签名的签名指令。Sub-step S204-4, after the verification is passed, generate a signature instruction for triggering the participants participating in the random number generation to perform a multi-party cooperative signature on the random number seed.
子步骤S204-6,采用私钥分片对随机数种子进行签名得到第一随机数签名。Sub-step S204-6, using the private key fragment to sign the random number seed to obtain the first random number signature.
其中,私钥分片由该参与方与其余参与方基于分布式密钥协议预先协同生成。Among them, the private key fragment is pre-generated by the participant and other participants based on the distributed key agreement.
子步骤S204-8,将第一随机数签名发送给其余参与方,并接收来自其余参与方的第一随机数签名作为第二随机数签名。Sub-step S204-8, sending the first random number signature to the remaining participants, and receiving the first random number signature from the remaining participants as the second random number signature.
子步骤S204-10,当接收到的第二随机数签名满足聚合条件时,将接收到的第二随机数签名连同第一随机数签名聚合得到聚合签名。Sub-step S204-10, when the received second random number signature satisfies the aggregation condition, aggregate the received second random number signature together with the first random number signature to obtain an aggregated signature.
子步骤S204-12,当获取到的多个聚合签名中相同的数量达到一定的条件时,将该相同的聚合签名作为目标签名,基于该目标签名生成随机数。In sub-step S204-12, when the same number among the obtained multiple aggregated signatures meets a certain condition, the same aggregated signature is used as a target signature, and a random number is generated based on the target signature.
本说明书提供的一种基于区块链的随机数生成装置实施例如下:在上述的实施例中,提供了一种基于区块链的随机数生成方法,与之相对应的,还提供了一种基于区块链的随机数生成装置,下面结合附图进行说明。An embodiment of a block chain-based random number generation device provided in this specification is as follows: In the above-mentioned embodiment, a block chain-based random number generation method is provided, and correspondingly, a A block chain-based random number generating device, which will be described below with reference to the accompanying drawings.
参照图3,其示出了本实施例提供的一种基于区块链的随机数生成装置示意图。Referring to FIG. 3 , it shows a schematic diagram of a block chain-based random number generating device provided in this embodiment.
由于装置实施例对应于方法实施例,所以描述得比较简单,相关的部分请参见上述提供的方法实施例的对应说明即可。下述描述的装置实施例仅仅是示意性的。Since the device embodiment corresponds to the method embodiment, the description is relatively simple. For relevant parts, please refer to the corresponding description of the method embodiment provided above. The device embodiments described below are illustrative only.
本实施例提供一种基于区块链的随机数生成装置,包括:交易接收模块302,被配置为接收携带有生成随机数请求的交易,所述生成随机数请求携带有随机数种子;智能合约调用模块304,被配置为基于所述交易调用相应的智能合约,并通过虚拟机执行该相应的智能合约,该智能合约包括:生成用于触发参与随机数生成的多个参与方对所述随机数种子进行多方协同签名的签名指令;获取多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名得到的聚合签名,并基于获取到的多个聚合签名生成随机数。This embodiment provides a block chain-based random number generating device, including: a transaction receiving module 302 configured to receive a transaction carrying a request for generating a random number, the request for generating a random number carries a random number seed; a smart contract The calling module 304 is configured to call a corresponding smart contract based on the transaction, and execute the corresponding smart contract through a virtual machine, the smart contract includes: generating a pair of random A signature instruction for performing multi-party cooperative signature on the number seed; obtaining an aggregate signature obtained by multiple participants responding to the signature instruction to perform multi-party cooperative signature on the random number seed, and generating a random number based on the obtained multiple aggregate signatures.
本说明书提供的一种基于区块链的随机数生成设备实施例如下:对应上述描述的一种基于区块链的随机数生成方法,基于相同的技术构思,本说明书一个或多个实施例还提供一种基于区块链的随机数生成设备,该基于区块链的随机数生成设备用于执行上述 提供的基于区块链的随机数生成方法,图4为本说明书一个或多个实施例提供的一种基于区块链的随机数生成设备的结构示意图。An embodiment of a block chain-based random number generation device provided in this specification is as follows: Corresponding to a block chain-based random number generation method described above, based on the same technical concept, one or more embodiments of this specification also Provide a block chain-based random number generation device, the block chain-based random number generation device is used to implement the block chain-based random number generation method provided above, Figure 4 shows one or more embodiments of this specification A schematic structural diagram of a block chain-based random number generation device is provided.
本实施例提供的一种基于区块链的随机数生成设备,包括:如图4所示,基于区块链的随机数生成设备可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上的处理器401和存储器402,存储器402中可以存储有一个或一个以上存储应用程序或数据。其中,存储器402可以是短暂存储或持久存储。存储在存储器402的应用程序可以包括一个或一个以上模块(图示未示出),每个模块可以包括基于区块链的随机数生成设备中的一系列计算机可执行指令。更进一步地,处理器401可以设置为与存储器402通信,在基于区块链的随机数生成设备上执行存储器402中的一系列计算机可执行指令。基于区块链的随机数生成设备还可以包括一个或一个以上电源403,一个或一个以上有线或无线网络接口404,一个或一个以上输入/输出接口405,一个或一个以上键盘406等。A block chain-based random number generating device provided in this embodiment includes: as shown in FIG. or more than one processor 401 and memory 402, and one or more storage application programs or data may be stored in the memory 402. Wherein, the storage 402 may be a short-term storage or a persistent storage. The application program stored in the memory 402 may include one or more modules (not shown in the figure), and each module may include a series of computer-executable instructions in the block chain-based random number generating device. Furthermore, the processor 401 can be configured to communicate with the memory 402, and execute a series of computer-executable instructions in the memory 402 on the blockchain-based random number generating device. The block chain-based random number generating device may also include one or more power sources 403, one or more wired or wireless network interfaces 404, one or more input/output interfaces 405, one or more keyboards 406, and the like.
在一个具体的实施例中,基于区块链的随机数生成设备包括有存储器,以及一个或一个以上的程序,其中一个或者一个以上程序存储于存储器中,且一个或者一个以上程序可以包括一个或一个以上模块,且每个模块可以包括对基于区块链的随机数生成设备中的一系列计算机可执行指令,且经配置以由一个或者一个以上处理器执行该一个或者一个以上程序包含用于进行以下计算机可执行指令:接收携带有生成随机数请求的交易,所述生成随机数请求携带有随机数种子;基于所述交易调用相应的智能合约,并通过虚拟机执行该相应的智能合约,该智能合约包括:生成用于触发参与随机数生成的多个参与方对所述随机数种子进行多方协同签名的签名指令;获取多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名得到的聚合签名,并基于获取到的多个聚合签名生成随机数。In a specific embodiment, the block chain-based random number generating device includes a memory, and one or more programs, wherein one or more programs are stored in the memory, and one or more programs may include one or more More than one module, and each module may include a series of computer-executable instructions in the block chain-based random number generating device, and is configured to be executed by one or more processors. The one or more programs include for Performing the following computer-executable instructions: receiving a transaction carrying a request for generating a random number, the request for generating a random number carrying a random number seed; calling a corresponding smart contract based on the transaction, and executing the corresponding smart contract through a virtual machine, The smart contract includes: generating a signature instruction for triggering a plurality of participants participating in random number generation to perform a multi-party cooperative signature on the random number seed; The aggregated signature obtained by multi-party cooperative signature, and the random number is generated based on the obtained multiple aggregated signatures.
本说明书提供的一种存储介质实施例如下:对应上述描述的一种基于区块链的随机数生成方法,基于相同的技术构思,本说明书一个或多个实施例还提供一种存储介质。An example of a storage medium provided in this specification is as follows: Corresponding to a block chain-based random number generation method described above, based on the same technical concept, one or more embodiments of this specification also provide a storage medium.
本实施例提供的存储介质,用于存储计算机可执行指令,所述计算机可执行指令在被处理器执行时实现以下流程:接收携带有生成随机数请求的交易,所述生成随机数请求携带有随机数种子;基于所述交易调用相应的智能合约,并通过虚拟机执行该相应的智能合约,该智能合约包括:生成用于触发参与随机数生成的多个参与方对所述随机数种子进行多方协同签名的签名指令;获取多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名得到的聚合签名,并基于获取到的多个聚合签名生成随机数。The storage medium provided in this embodiment is used to store computer-executable instructions, and when the computer-executable instructions are executed by a processor, the following process is implemented: receiving a transaction carrying a request for generating a random number, and the request for generating a random number carries a A random number seed; calling a corresponding smart contract based on the transaction, and executing the corresponding smart contract through a virtual machine, the smart contract includes: generating a plurality of participants used to trigger participation in random number generation to perform random number seed A signature command signed by multiple parties; obtaining an aggregated signature obtained by multiple parties responding to the signature command to perform multiple collaborative signatures on the random number seed, and generating a random number based on the multiple aggregated signatures obtained.
需要说明的是,本说明书中关于存储介质的实施例与本说明书中关于基于区块链的随机数生成方法的实施例基于同一发明构思,因此该实施例的具体实施可以参见前述对应方法的实施,重复之处不再赘述。It should be noted that the embodiment of the storage medium in this specification and the embodiment of the block chain-based random number generation method in this specification are based on the same inventive concept, so the specific implementation of this embodiment can refer to the implementation of the aforementioned corresponding method , the repetitions will not be repeated.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of this specification. Other implementations are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. Multitasking and parallel processing are also possible or may be advantageous in certain embodiments.
在20世纪30年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable Gate Array,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字***“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby Hardware Description Language)等,目前最普遍使用的是VHDL(Very-High-Speed Integrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。In the 1930s, the improvement of a technology can be clearly distinguished as an improvement in hardware (for example, improvements in circuit structures such as diodes, transistors, switches, etc.) or improvements in software (improvement in method flow). However, with the development of technology, the improvement of many current method flows can be regarded as the direct improvement of the hardware circuit structure. Designers almost always get the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose logic function is determined by programming the device by the user. It is programmed by the designer to "integrate" a digital system on a PLD, instead of asking a chip manufacturer to design and make a dedicated integrated circuit chip. Moreover, nowadays, instead of making integrated circuit chips by hand, this kind of programming is mostly realized by "logic compiler (logic compiler)" software, which is similar to the software compiler used when program development and writing, but before compiling The original code of the computer must also be written in a specific programming language, which is called a hardware description language (Hardware Description Language, HDL), and there is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language) , AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., are currently the most commonly used The most popular are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. It should also be clear to those skilled in the art that only a little logical programming of the method flow in the above-mentioned hardware description languages and programming into an integrated circuit can easily obtain a hardware circuit for realizing the logic method flow.
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、 可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。The controller may be implemented in any suitable way, for example the controller may take the form of a microprocessor or processor and a computer readable medium storing computer readable program code (such as software or firmware) executable by the (micro)processor , logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controllers, and embedded microcontrollers, examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that, in addition to realizing the controller in a purely computer-readable program code mode, it is entirely possible to make the controller use logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded The same function can be realized in the form of a microcontroller or the like. Therefore, such a controller can be regarded as a hardware component, and the devices included in it for realizing various functions can also be regarded as structures within the hardware component. Or even, means for realizing various functions can be regarded as a structure within both a software module realizing a method and a hardware component.
上述实施例阐明的***、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules, or units described in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementing device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or Combinations of any of these devices.
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本说明书实施例时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, when describing the above devices, functions are divided into various units and described separately. Of course, when implementing the embodiments of this specification, the functions of each unit can be implemented in one or more software and/or hardware.
本领域内的技术人员应明白,本说明书一个或多个实施例可提供为方法、***或计算机程序产品。因此,本说明书一个或多个实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本说明书可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that one or more embodiments of this specification may be provided as a method, system or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本说明书是参照根据本说明书实施例的方法、设备(***)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The specification is described with reference to flowcharts and/or block diagrams of methods, devices (systems), and computer program products according to embodiments of the specification. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或 多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-permanent storage in computer readable media, in the form of random access memory (RAM) and/or nonvolatile memory such as read-only memory (ROM) or flash RAM. Memory is an example of computer readable media.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information. Information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, A magnetic tape cartridge, disk storage or other magnetic storage device or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus comprising a set of elements includes not only those elements, but also includes Other elements not expressly listed, or elements inherent in the process, method, commodity, or apparatus are also included. Without further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising said element.
本说明书一个或多个实施例可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本说明书的一个或多个实施例,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和 远程计算机存储介质中。One or more embodiments of this specification may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including storage devices.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于***实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a progressive manner, the same and similar parts of each embodiment can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for relevant parts, refer to part of the description of the method embodiment.
以上所述仅为本文件的实施例而已,并不用于限制本文件。对于本领域技术人员来说,本文件可以有各种更改和变化。凡在本文件的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本文件的权利要求范围之内。The above description is only an embodiment of this document, and is not intended to limit this document. Various modifications and changes to this document will occur to those skilled in the art. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this document shall be included within the scope of the claims of this document.

Claims (12)

  1. 一种基于区块链的随机数生成方法,应用于区块链节点,所述方法包括:A block chain-based random number generation method applied to block chain nodes, the method comprising:
    接收携带有生成随机数请求的交易,所述生成随机数请求携带有随机数种子;receiving a transaction that carries a request for generating a random number, and the request for generating a random number carries a random number seed;
    基于所述交易调用相应的智能合约,并通过虚拟机执行该相应的智能合约,该智能合约包括:Call the corresponding smart contract based on the transaction, and execute the corresponding smart contract through the virtual machine, the smart contract includes:
    生成用于触发参与随机数生成的多个参与方对所述随机数种子进行多方协同签名的签名指令;Generate a signature instruction for triggering multiple parties participating in the random number generation to perform a multi-party cooperative signature on the random number seed;
    获取多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名得到的聚合签名,并基于获取到的多个聚合签名生成随机数。Acquiring an aggregated signature obtained by multiple participants responding to the signature instruction to perform multi-party cooperative signing of the random number seed, and generating a random number based on the acquired multiple aggregated signatures.
  2. 根据权利要求1所述的基于区块链的随机数生成方法,所述随机数种子由可信执行环境针对所述生成随机数请求生成。According to the block chain-based random number generation method according to claim 1, the random number seed is generated by a trusted execution environment in response to the request for generating random numbers.
  3. 根据权利要求2所述的基于区块链的随机数生成方法,所述智能合约还包括:According to the block chain-based random number generation method according to claim 2, the smart contract also includes:
    验证所述随机数种子的真实性;Verify the authenticity of the random number seed;
    在验证通过后生成用于触发参与随机数生成的参与方对所述随机数种子进行多方协同签名的签名指令。After the verification is passed, a signature instruction for triggering a participant participating in random number generation to perform a multi-party cooperative signature on the random number seed is generated.
  4. 根据权利要求3所述的基于区块链的随机数生成方法,所述生成随机数请求携带的随机数种子具有由所述可信执行环境进行签名获得的私钥签名,所述验证所述随机数种子的真实性包括采用所述可信执行环境的私钥对应的公钥进行签名验证。According to the block chain-based random number generation method according to claim 3, the random number seed carried in the random number generation request has a private key signature obtained by signing the trusted execution environment, and the verification of the random number The authenticity of several seeds includes performing signature verification using the public key corresponding to the private key of the trusted execution environment.
  5. 根据权利要求1所述的基于区块链的随机数生成方法,所述基于获取到的多个聚合签名生成随机数包括:According to the block chain-based random number generation method according to claim 1, said generation of random numbers based on a plurality of aggregated signatures obtained comprises:
    当获取到的多个聚合签名中相同的数量达到一定的条件时,将该相同的聚合签名作为目标签名,基于该目标签名生成随机数。When the same number of multiple aggregated signatures obtained reaches a certain condition, the same aggregated signature is used as a target signature, and a random number is generated based on the target signature.
  6. 根据权利要求1所述的基于区块链的随机数生成方法,所述智能合约还包括:According to the block chain-based random number generation method according to claim 1, the smart contract also includes:
    采用共享公钥验证所述多个聚合签名,所述共享公钥由所述多个参与方基于分布式密钥协议预先协同生成;verifying the plurality of aggregated signatures by using a shared public key, the shared public key is collaboratively generated in advance by the plurality of participants based on a distributed key agreement;
    在验证通过后基于所述多个聚合签名生成所述随机数。The random number is generated based on the plurality of aggregated signatures after the verification is passed.
  7. 根据权利要求1所述的基于区块链的随机数生成方法,所述智能合约还包括:According to the block chain-based random number generation method according to claim 1, the smart contract also includes:
    根据所述生成随机数请求中携带的标识,记录所述随机数并作为所述标识对应的随机数,针对所述生成随机数请求返回携带所述随机数的请求响应。According to the identifier carried in the request to generate a random number, record the random number as a random number corresponding to the identifier, and return a request response carrying the random number to the request to generate a random number.
  8. 根据权利要求1所述的基于区块链的随机数生成方法,所述多个参与方均为区块链节点。According to the block chain-based random number generation method according to claim 1, the plurality of participants are all block chain nodes.
  9. 根据权利要求1至8任意一项所述的基于区块链的随机数生成方法,所述多个参与方中任意一个或多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名包括:According to the block chain-based random number generation method according to any one of claims 1 to 8, any one or more participants in the plurality of participants respond to the signature instruction to multi-party to the random number seed Cosignatures include:
    采用私钥分片对所述随机数种子进行签名得到第一随机数签名,所述私钥分片由该参与方与其余参与方基于分布式密钥协议预先协同生成;signing the random number seed by using a private key fragment to obtain a first random number signature, and the private key fragment is pre-cooperatively generated by the participant and other participants based on a distributed key agreement;
    将所述第一随机数签名发送给其余参与方,并接收来自其余参与方的第一随机数签名作为第二随机数签名;sending the first random number signature to the remaining participants, and receiving the first random number signature from the remaining participants as the second random number signature;
    当接收到的第二随机数签名满足聚合条件时,将接收到的第二随机数签名连同第一随机数签名聚合得到聚合签名。When the received second random number signature satisfies the aggregation condition, the received second random number signature is aggregated together with the first random number signature to obtain an aggregated signature.
  10. 一种基于区块链的随机数生成装置,运行于区块链节点,所述装置包括:A block chain-based random number generating device running on a block chain node, said device comprising:
    交易接收模块,被配置为接收携带有生成随机数请求的交易,所述生成随机数请求携带有随机数种子;The transaction receiving module is configured to receive a transaction carrying a request for generating a random number, and the request for generating a random number carries a random number seed;
    智能合约调用模块,被配置为基于所述交易调用相应的智能合约,并通过虚拟机执行该相应的智能合约,该智能合约包括:生成用于触发参与随机数生成的多个参与方对所述随机数种子进行多方协同签名的签名指令;获取多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名得到的聚合签名,并基于获取到的多个聚合签名生成随机数。The smart contract calling module is configured to call a corresponding smart contract based on the transaction, and execute the corresponding smart contract through a virtual machine. A signature instruction for performing multi-party cooperative signature on the random number seed; obtaining an aggregate signature obtained by multiple participants responding to the signature instruction to perform multi-party cooperative signature on the random number seed, and generating a random number based on the obtained multiple aggregate signatures.
  11. 一种基于区块链的随机数生成设备,包括:A random number generation device based on blockchain, including:
    处理器;以及,被配置为存储计算机可执行指令的存储器,所述计算机可执行指令在被执行时使所述处理器:a processor; and, a memory configured to store computer-executable instructions that, when executed, cause the processor to:
    接收携带有生成随机数请求的交易,所述生成随机数请求携带有随机数种子;receiving a transaction that carries a request for generating a random number, and the request for generating a random number carries a random number seed;
    基于所述交易调用相应的智能合约,并通过虚拟机执行该相应的智能合约,该智能合约包括:Call the corresponding smart contract based on the transaction, and execute the corresponding smart contract through the virtual machine, the smart contract includes:
    生成用于触发参与随机数生成的多个参与方对所述随机数种子进行多方协同签名的签名指令;Generate a signature instruction for triggering multiple parties participating in the random number generation to perform a multi-party cooperative signature on the random number seed;
    获取多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名得到的聚合签名,并基于获取到的多个聚合签名生成随机数。Acquiring an aggregated signature obtained by multiple participants responding to the signature instruction to perform multi-party cooperative signing of the random number seed, and generating a random number based on the acquired multiple aggregated signatures.
  12. 一种存储介质,用于存储计算机可执行指令,所述计算机可执行指令在被处理器执行时实现以下流程:A storage medium for storing computer-executable instructions that, when executed by a processor, implement the following processes:
    接收携带有生成随机数请求的交易,所述生成随机数请求携带有随机数种子;receiving a transaction that carries a request for generating a random number, and the request for generating a random number carries a random number seed;
    基于所述交易调用相应的智能合约,并通过虚拟机执行该相应的智能合约,该智能 合约包括:Call the corresponding smart contract based on the transaction, and execute the corresponding smart contract through the virtual machine, the smart contract includes:
    生成用于触发参与随机数生成的多个参与方对所述随机数种子进行多方协同签名的签名指令;Generate a signature instruction for triggering multiple parties participating in the random number generation to perform a multi-party cooperative signature on the random number seed;
    获取多个参与方响应所述签名指令以对所述随机数种子进行多方协同签名得到的聚合签名,并基于获取到的多个聚合签名生成随机数。Acquiring an aggregated signature obtained by multiple participants responding to the signature instruction to perform multi-party cooperative signing of the random number seed, and generating a random number based on the acquired multiple aggregated signatures.
PCT/CN2022/135838 2021-12-15 2022-12-01 Random number generation method and apparatus based on blockchain WO2023109520A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111534310.8A CN113935737B (en) 2021-12-15 2021-12-15 Random number generation method and device based on block chain
CN202111534310.8 2021-12-15

Publications (1)

Publication Number Publication Date
WO2023109520A1 true WO2023109520A1 (en) 2023-06-22

Family

ID=79289083

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/135838 WO2023109520A1 (en) 2021-12-15 2022-12-01 Random number generation method and apparatus based on blockchain

Country Status (2)

Country Link
CN (1) CN113935737B (en)
WO (1) WO2023109520A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113935737B (en) * 2021-12-15 2022-10-25 支付宝(杭州)信息技术有限公司 Random number generation method and device based on block chain
CN114666068B (en) * 2022-05-25 2022-10-11 南京金宁汇科技有限公司 Credible random number generation method and device based on alliance chain

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110599173A (en) * 2019-09-20 2019-12-20 腾讯科技(深圳)有限公司 Block chain consensus node determination method, device, equipment and storage medium
CN112182612A (en) * 2020-09-28 2021-01-05 平安科技(深圳)有限公司 Random number generation method and device, terminal equipment and storage medium
US20210286595A1 (en) * 2020-03-11 2021-09-16 Acer Incorporated Blockchain random number generating system and blockchain random number generating method
CN113935737A (en) * 2021-12-15 2022-01-14 支付宝(杭州)信息技术有限公司 Random number generation method and device based on block chain

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113853578A (en) * 2019-01-18 2021-12-28 泽乌科技公司 Method for generating random numbers in a blockchain intelligent contract
CN111628862B (en) * 2020-05-22 2023-09-12 杭州溪塔科技有限公司 Multi-party participated random number generation method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110599173A (en) * 2019-09-20 2019-12-20 腾讯科技(深圳)有限公司 Block chain consensus node determination method, device, equipment and storage medium
US20210286595A1 (en) * 2020-03-11 2021-09-16 Acer Incorporated Blockchain random number generating system and blockchain random number generating method
CN112182612A (en) * 2020-09-28 2021-01-05 平安科技(深圳)有限公司 Random number generation method and device, terminal equipment and storage medium
CN113935737A (en) * 2021-12-15 2022-01-14 支付宝(杭州)信息技术有限公司 Random number generation method and device based on block chain

Also Published As

Publication number Publication date
CN113935737A (en) 2022-01-14
CN113935737B (en) 2022-10-25

Similar Documents

Publication Publication Date Title
TWI705350B (en) Method and device for processing transaction request
CN110032883B (en) Method, system and node for realizing privacy protection in block chain
TWI671699B (en) Method and device for processing transaction request
CN112184222B (en) Service processing method, device and equipment based on block chain
WO2023109520A1 (en) Random number generation method and apparatus based on blockchain
TWI737107B (en) Data processing method, device, blockchain client and blockchain node
US10790971B1 (en) Preventing misrepresentation of input data by participants in a secure multi-party computation
CN110008735B (en) Method, node and storage medium for realizing contract calling in block chain
CN110245942B (en) Receipt storage method and node combining user type and judgment condition
TW201835803A (en) Method and apparatus for consensus verification
EP3811232A1 (en) Data processing method, apparatus, and device
CN110245947B (en) Receipt storage method and node combining conditional restrictions of transaction and user types
WO2020238248A1 (en) Data storage method, apparatus and device
TW201822033A (en) Resource processing method and apparatus
CN111339565B (en) Business service providing method, device, equipment and system based on block chain
WO2020220744A1 (en) Blockchain-based data processing method and apparatus, and blockchain node
US11270004B2 (en) Blockchain-based transaction privacy
CN113821817B (en) Data processing method, device, equipment and system based on block chain
TW201937425A (en) Transaction processing method, server, client, and system
CN111669434B (en) Method, system, device and equipment for establishing communication group
CN114281893A (en) Processing method, device and equipment for block chain transaction
CN113761496B (en) Identity verification method and device based on blockchain and electronic equipment
CN112418857B (en) Hidden transaction method and device based on UTXO model and related products
WO2024092932A1 (en) Transaction execution method and blockchain node
CN115134136B (en) System, method, device, storage medium and computing device for socializing based on blockchain

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22906270

Country of ref document: EP

Kind code of ref document: A1