A Method for Generating Random Numbers in Blockchain Smart Contracts
Abstract
A method for generating fair and effective random numbers for smart contracts, which effectively mitigates certain problems associated with conventional methods while achieving verifiable and non-tamperable random number generation is disclosed. The concept behind the disclosed method treats miners as being not trustworthy, and presumes that the number of miners in the blockchain is limited. With sufficient motivation, miners can reach a consensus to manipulate the block. The goal is thus to create a verifiable fair Random Number Generator. Under this condition, as long as at least one of the parties to the smart contract is credible and does not misuse the confidential information, a trusted blockchain random number can be generated. After the last disclosure of the random number, the verification signature submitted by parties to the contract can be used to confirm that the random number calculation process is credible.
Claims
exact text as granted — not AI-modifiedWhat is claimed is:
1 . A method for generating random numbers for a smart contract on a blockchain among a plurality of users, the method comprising:
a) having each user of said plurality of users generate a random seed locally; b) having said each user generate a signature by signing the random seed with a private key having a corresponding public key; c) having each said user submit said signature to the smart contract separately; d) verifying, using the smart contract, said signature of each said user, with said corresponding public key of said each user; e) storing the signature to a current block of the blockchain via the smart contract; f) having said each user wait at least a predefined period and then submit said random seed generated by said each user; g) verifying via the smart contract, each said random seed submitted by said each user, by ensuring a match with the corresponding signature; and h) after all the random seeds from said each user are received, calculating via the smart contract, a random number with a seed obtained from the seeds of said each user and a hash of the current block,
wherein when getting the hash of the current block, all of said seeds have been already generated so that it is not possible to manipulate the seeds or block content anymore, thereby preventing miners from changing the current block.
2 . The method of claim 1 , wherein the predefined period is at least one block period.
3 . The method of claim 1 , wherein said step of having each user of said plurality of users generate a random seed locally, is performed by one or more of a local software and a hardware device of said each user.
4 . The method of claim 1 , further comprising: having each user get a first identifier of a block (first Block ID) from said contract prior to said having each user of said plurality of users generate a random seed locally.
5 . The method of claim 4 , wherein said step of having said each user generate a signature comprises signing the random seed and the first Block ID with said private key.
6 . The method of claim 5 , wherein said step of verifying via the smart contract, each said random seed submitted by said each user, by ensuring a match with the corresponding signature, comprises ensuring said first Block ID is within a predetermined number of blocks from the current block identifier.
7 . The method of claim 6 , wherein said predetermined number of blocks is five (5).
8 . The method of claim 7 , wherein said step of calculating via the smart contract, a random number with a seed obtained from the seeds of said each user and a hash of the current block, comprises setting the random number to:
RAND( N+ 1)=HASH(RAND( N )XOR BLOCKHASH)
where RAND(N)=HASH(RAND (N−1) XOR RandomSeed (USER A));
BLOCKHASH is the hash of the current block;
USER A is a first one of said plurality of users; and
RandomSeed (USER A) is the random seed generated by said first one of said plurality of users.
9 . The method of claim 8 , wherein RAND(0)=HASH(RandomSeed (USER A)).
10 . The method of claim 1 , wherein said step of having said each user wait at least a predefined period and then submit said each user's random seed, ensures that said random see of said each user will not appear in the current block as said each user's signature.
11 . The method of claim 1 , wherein said signing the random seed with a local private key comprises utilizing an encryption program that uses one or more of: the random seed and an identifier of the current block as an input.
12 . The method of claim 1 , wherein any one of said plurality of users can obtain the random number seed and the signature contributed by each of said plurality of users through the data on the blockchain.
13 . The method of claim 11 , wherein the encryption program is Pretty Good Privacy (PGP).
14 . The method of claim 2 , wherein said predefined period is at least one (1) block period but no more than six (6) block periods.
15 . The method of claim 1 , wherein said plurality of users include a first user, a second user and a banker.
16 . A method of verifying a first random number generated by a smart contract on a blockchain among a plurality of users, the method comprising:
a) obtaining a first random number generated by the smart contract; b) receiving a last block hash of the blockchain; c) calculating a second random number; and d) comparing the first random number with the second random number.
17 . The method of claim 16 , wherein said plurality of users include a first user, a second user and a banker.
18 . The method of claim 16 , wherein any one of said plurality of users can obtain the random number seed and the signature contributed by each of said plurality of users through the data on the blockchain.Join the waitlist — get patent alerts
Track US2022123947A1 — get alerts on status changes and closely related new filings.
We store only your email — no account needed. See our privacy policy.