# US 12,603,760 B2 · Method and apparatus for generating random number in blockchain

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,603,760 B2
- Document ID: US12603760B2
- Status: Granted
- Kind: B2
- Application number: 18/280,202
- Filed: 2022-03-03
- Published: 2024-05-02
- Granted: 2026-04-14
- Earliest claimed: 2021-03-03
- Assignees: Digital Currency Institute, the People's Bank of China
- Applicants: Digital Currency Institute, The People's Bank of China
- Inventors: Changchun Mu; Gang Di; Youcai Qian; Qingjie Chen; Jinzhao Du
- Web page: https://patentgrep.com/patent/US12603760B2

## CPC

- H04L 9/0816: {Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use}
- H04L 9/50: {using hash chains, e.g. blockchains or hash trees}
- H04L 9/0869: {involving random numbers or seeds}
- H04L 63/123: {received data contents, e.g. message integrity}
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)

## Abstract

Provided are a method and apparatus for generating a random number in a blockchain, wherein the method includes: a first random number and a first digest value of the first random number are locally generated by a first node in a blockchain; the first node submits the first digest value to a smart contract; the smart contract broadcasts a first service; the smart contract determines a second node from the at least one blockchain node; when the first service ends, the first node submits the first random number to the smart contract; when the smart contract verifies that the first random number corresponds to the first digest value, the smart contract generates a second random number based on a second digest value of the second node and the first random number; and a second service is started based on the second random number.

## Claims

### Claim 1

A method for generating a random number in a blockchain, comprising:
locally generating, by a first node in the blockchain, a first random number and a first digest value of the first random number;
submitting, by the first node, the first digest value to a smart contract;
broadcasting, by the smart contract, a first service, so that at least one blockchain node in the blockchain submits participation information about the first service;
determining, by the smart contract, a second node from the at least one blockchain node based on an order of submission of participation information by the at least one blockchain node;
when the first service ends, submitting, by the first node, the first random number to the smart contract;
when the smart contract verifies that the first random number corresponds to the first digest value, generating a second random number based on a second digest value of the second node and the first random number; and
starting a second service based on the second random number.

### Claim 2 (depends on 1)

The method as claimed in claim 1, wherein determining the second node from the at least one blockchain node comprises:
determining the second node based on a preset target value and the order of submission of participation information by the at least one blockchain node, wherein the preset target value is a last one in the order.

### Claim 3 (depends on 1)

The method as claimed in claim 1, wherein,
generating, by the smart contract, a third digest value based on the first random number, wherein an algorithm for generating the first digest value is the same as an algorithm for generating the third digest value; and
when the third digest value is the same as the first digest value, determining that the first random number corresponds to the first digest value.

### Claim 4 (depends on 1)

The method as claimed in claim 1, wherein,
a blockchain node corresponding to a provider of the first service is taken as the first node.

### Claim 5 (depends on 1)

The method as claimed in claim 1, wherein after generating the second random number, the method further comprises:
the smart contract sending a virtual resource to the first node.

### Claim 6 (depends on 1)

The method as claimed in claim 1, wherein starting the second service based on the second random number comprises:
receiving options submitted by the at least one blockchain node respectively; and
starting a selection service to determine, based on the second random number, a target option from the options submitted by the at least one blockchain node respectively.

### Claim 7 (depends on 6)

The method as claimed in claim 6, further comprising:
sending a virtual resource to a blockchain node that submits the target option.

### Claim 8

A method for generating a random number in a blockchain, comprising:
locally generating, by at least one blockchain node, a first random number and a first digest value of the first random number;
respectively submitting, by the at least one blockchain node, the first digest value to a smart contract of the blockchain within a first preset duration;
submitting, by the at least one blockchain node, the first random number to the smart contract within a second preset duration that is started after the first preset duration ends;
verifying, by the smart contract, the received at least one first digest value and the first random number corresponding to the first digest value;
generating a second random number based on a successfully verified first random number; and
starting a service based on the second random number;
wherein generating the second random number based on the successfully verified first random number comprises: determining, by the smart contract, from the at least one blockchain node, a blockchain node that submits the first random number at last; and calculating, according to a preset operation rule, a digest value of the blockchain node that submits the first random number at last, and the successfully verified first random number, so as to generate the second random number.

### Claim 9 (depends on 8)

The method as claimed in claim 8, wherein,
when it is determined that the number of the successfully verified first random number is not less than a preset number threshold value, generating, by the smart contract, the second random number based on the successfully verified first random number.

### Claim 10 (depends on 9)

The method as claimed in claim 9, wherein the preset number threshold value is determined based on the number of the at least one blockchain node.

### Claim 11 (depends on 8)

The method as claimed in claim 8, wherein,
verifying, by the smart contract, the first random number and the corresponding first digest value, if within the second preset duration, every time upon receiving one first random number, the smart contract determines the first digest value corresponding to the first random number has been received, and the first digest value is received within the first preset duration;
if verifying successfully, progressively increasing the number of the successfully verified first random number; and
if verifying unsuccessfully, sending prompt information by the smart contract, so that the blockchain node submitting the first random number resubmits the first random number within the second preset duration according to the prompt information.

### Claim 12 (depends on 8)

The method as claimed in claim 8, wherein verifying, by the smart contract, the received at least one first digest value and the first random number corresponding to the first digest value, comprises:
for each pair of the first digest value and the first random number, generating, by the smart contract, a second digest value based on the first random number, wherein an algorithm for generating the first digest value is the same as an algorithm for generating the second digest value; and
if the second digest value is the same as the first digest value, determining that the first digest value and the corresponding first random number are successfully verified.

### Claim 13 (depends on 8)

The method as claimed in claim 8, further comprising:
determining, by the smart contract, a blockchain node corresponding to the successfully verified first random number, and sending a virtual resource to the determined blockchain node.

### Claim 14 (depends on 8)

The method as claimed in claim 8, wherein starting the service based on the second random number comprises:
receiving options submitted by the at least one blockchain node respectively; and
starting a selection service to determine, based on the second random number, a target option from the options submitted by the at least one blockchain node respectively.

### Claim 15 (depends on 14)

The method as claimed in claim 14, further comprising:
sending a virtual resource to a blockchain node that submits the target option.

### Claim 16

An electronic device for generating a random number in a blockchain, comprising:
one or more processors; and
a storage apparatus, configured to store one or more programs, wherein,
when the one or more programs are executed by the one or more processors, the one or more processors implement following actions:
locally generating, by a first node in the blockchain, a first random number and a first digest value of the first random number;
submitting, by the first node, the first digest value to a smart contract;
broadcasting, by the smart contract, a first service, so that at least one blockchain node in the blockchain submits participation information about the first service;
determining, by smart contract, a second node from the at least one blockchain node based on the order of submission of participation information by the at least one blockchain node;
when the first service ends, submitting, by the first node, the first random number to the smart contract;
when the smart contract verifies that the first random number corresponds to the first digest value, generating a second random number based on a second digest value of the second node and the first random number; and
starting a second service based on the second random number.

### Claim 17

A non-transitory computer-readable storage medium, on which a computer program is stored, wherein when executed by a processor, the program implements following actions:
locally generating, by a first node in the blockchain, a first random number and a first digest value of the first random number;
submitting, by the first node, the first digest value to a smart contract;
broadcasting, by the smart contract, a first service, so that at least one blockchain node in the blockchain submits participation information about the first service;
determining, by smart contract, a second node from the at least one blockchain node based on the order of submission of participation information by the at least one blockchain node;
when the first service ends, submitting, by the first node, the first random number to the smart contract;
when the smart contract verifies that the first random number corresponds to the first digest value, generating a second random number based on a second digest value of the second node and the first random number; and
starting a second service based on the second random number.

### Claim 18

An electronic device for generating a random number in a blockchain, comprising:
one or more processors; and
a storage apparatus, configured to store one or more programs, wherein,
when the one or more programs are executed by the one or more processors, the one or more processors implement following actions:
at least one blockchain node locally generating a first random number and a first digest value of the first random number;
the at least one blockchain node respectively submitting the first digest value to a smart contract of the blockchain within a first preset duration;
the at least one blockchain node submitting the first random number to the smart contract within a second preset duration that is started after the first preset duration ends;
the smart contract verifying the received at least one first digest value and the first random number corresponding to the first digest value;
generating a second random number based on a successfully verified first random number; and
starting a service based on the second random number;
wherein generating the second random number based on the successfully verified first random number comprises: determining, by the smart contract, from the at least one blockchain node, a blockchain node that submits the first random number at last; and calculating, according to a preset operation rule, a digest value of the blockchain node that submits the first random number at last, and the successfully verified first random number, so as to generate the second random number.

### Claim 19

A non-transitory computer-readable storage medium, on which a computer program is stored, wherein when executed by a processor, the program implements following actions:
at least one blockchain node locally generating a first random number and a first digest value of the first random number;
the at least one blockchain node respectively submitting the first digest value to a smart contract of the blockchain within a first preset duration;
the at least one blockchain node submitting the first random number to the smart contract within a second preset duration that is started after the first preset duration ends;
the smart contract verifying the received at least one first digest value and the first random number corresponding to the first digest value;
generating a second random number based on a successfully verified first random number; and
starting a service based on the second random number;
wherein generating the second random number based on the successfully verified first random number comprises: determining, by the smart contract, from the at least one blockchain node, a blockchain node that submits the first random number at last; and calculating, according to a preset operation rule, a digest value of the blockchain node that submits the first random number at last, and the successfully verified first random number, so as to generate the second random number.
