Lottery random number issuing method and device applying block chainTechnical Field
The invention relates to the technical field of combination of a block chain and lottery ticket number issuing, in particular to a lottery ticket random number issuing method and equipment applying the block chain.
Background
Lottery numbers may be provided in lottery markets around the world with mechanical shake or random number generators to draw the lottery. The mechanical shaking needs manpower and a mechanical device, and the working condition and the manpower of the mechanical device can influence the randomness of lottery number issuing. The random number generator is opaque in the process of recording the prize, so that the situation that a specific ticket number is generated according to a statistical result may exist, the possibility that data is tampered by insiders or hackers cannot be avoided, and the problems of no disclosure and no credibility exist.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm. The consensus mechanism is a mathematical algorithm for establishing trust and obtaining rights and interests among different nodes in a blockchain system. The blockchain is the underlying technology of bitcoin, like a database ledger, which records all transaction records. The system is characterized in that a plurality of nodes are arranged at different parts of the world, and each node maintains a set of same databases. The data is maliciously tampered and difficult to tamper, and the data loss is extremely rare, so that a platform which is fair and transparent and solves the trust crisis is realized.
Disclosure of Invention
Aiming at the defects of the prior art, the invention aims to solve the technical problems that the number output result of the prior lottery ticket is possibly not random, and the number output process is not transparent, so that the lottery ticket is not public and is not credible.
In order to achieve the above object, in a first aspect, the present invention provides a lottery random number issuing method using a block chain, including the following steps:
the lottery client initiates a transfer request on the block chain, wherein the transfer request comprises: an initiator address, a receiver address, and a transfer amount; the transfer request is used as a lottery number;
the lottery client performs hash operation on the transfer request to obtain a first hash value;
the lottery client side obtains the number n of transfer strokes in a block corresponding to the lottery client side currently; n is a positive integer;
the lottery client divides the first hash value by the number n of the transfer strokes to obtain a corresponding first remainder m; m is a positive integer less than n;
the lottery client side obtains the mth transfer account in the block corresponding to the lottery client side currently, and carries out Hash operation on the mth transfer account to obtain a second Hash value;
the lottery client divides the second hash value by a preset integer to obtain a corresponding second remainder; the second remainder is the number of the lottery; the preset integer determines the numerical value change interval of the lottery number.
Specifically, the transfer request is sent to the lottery client, and the receiver may be other nodes in the blockchain or the lottery client itself.
Optionally, the first hash value is hexadecimal data;
the lottery client divides the first hash value by the number n of the transfer strokes to obtain a corresponding first remainder m, and the method specifically comprises the following steps:
the lottery client converts the first hash value into corresponding decimal data;
and the lottery client divides the first hash value converted into decimal data by the number n of the transfer strokes to obtain a corresponding first remainder m.
Optionally, the second hash value is hexadecimal data;
the lottery client divides the second hash value by a preset integer to obtain a corresponding second remainder, and the method specifically comprises the following steps:
the lottery client converts the second hash value into corresponding decimal data;
and the lottery client divides the second hash value converted into decimal data by a preset integer to obtain a corresponding second remainder.
Optionally, when the preset integer is 10, the lottery number is changed within a range of 0-9.
Optionally, when the preset integer is 100, the lottery number is changed within a range of 00-99, and if the second remainder is less than 10, the tens of the lottery number is output after being zero-padded.
In a second aspect, the present invention provides a lottery random number issuing apparatus using a block chain, comprising:
the lottery number issuing initiating unit is used for initiating a transfer request on the block chain, and the transfer request comprises: an initiator address, a receiver address, and a transfer amount; the transfer request is used as a lottery number;
the first hash operation unit is used for carrying out hash operation on the transfer request to obtain a first hash value;
the transfer information acquisition unit is used for acquiring the number n of transfer notes in the current corresponding block; n is a positive integer;
a first remainder determining unit, configured to divide the first hash value by the number n of transfer strokes to obtain a corresponding first remainder m; m is a positive integer less than n;
the transfer information acquisition unit is used for acquiring the mth transfer in the current corresponding block;
the second hash operation unit is used for carrying out hash operation on the mth transfer to obtain a second hash value;
the lottery number output unit is used for dividing the second hash value by a preset integer to obtain a corresponding second remainder; the second remainder is the number of the lottery; the preset integer determines the numerical value change interval of the lottery number.
It is understood that the lottery random number issuing device to which the blockchain is applied may be a lottery client or other lottery devices.
Optionally, the first hash value is hexadecimal data; the first remainder determining unit converts the first hash value into corresponding decimal data; and dividing the first hash value converted into decimal data by the transfer stroke number n to obtain a corresponding first remainder m.
Optionally, the second hash value is hexadecimal data; the lottery number issuing unit converts the second hash value into corresponding decimal data; and dividing the second hash value converted into the decimal data by a preset integer to obtain a corresponding second remainder.
Optionally, when the preset integer is 10, the lottery number is changed within a range of 0-9.
Optionally, when the preset integer is 100, the lottery number is changed within a range of 00-99, and if the second remainder is less than 10, the tens of the lottery number is output after being zero-padded.
Generally, compared with the prior art, the above technical solution conceived by the present invention has the following beneficial effects:
the invention provides a lottery random number issuing method and equipment applying a block chain. And finally, the remainder is obtained by dividing the result of the two random hash operations into a whole number to obtain the final lottery number, so that the randomness of the lottery number issuing process is ensured.
The invention provides a lottery random number issuing method and equipment applying a block chain. In addition, data in the block chain can be found, so that the lottery number issuing process can be supervised by the public, the lottery number issuing process based on the block chain is guaranteed to be open, reliable and searchable, and the block chain lottery number issuing method has a good application prospect.
Drawings
Fig. 1 is a flow chart of a lottery random number issuing method using a block chain according to the present invention;
fig. 2 is a lottery random number issuing equipment architecture diagram of the application block chain provided by the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. In addition, the technical features involved in the embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
Fig. 1 is a flow chart of a lottery random number issuing method using a block chain according to the present invention; as shown in fig. 1, the method comprises the following steps:
s101, the lottery client initiates a transfer request on the block chain, wherein the transfer request comprises: an initiator address, a receiver address, and a transfer amount; the transfer request is used as a lottery number;
s102, the lottery client performs hash operation on the transfer request to obtain a first hash value;
s103, the lottery client acquires the number n of transfer strokes in the block corresponding to the lottery client at present; n is a positive integer;
s104, dividing the first hash value by the number n of the transfer strokes by the lottery client to obtain a corresponding first remainder m; m is a positive integer less than n;
s105, the lottery client side obtains the mth transfer account in the block corresponding to the lottery client side at present, and carries out Hash operation on the mth transfer account to obtain a second Hash value;
s106, the lottery client divides the second hash value by a preset integer to obtain a corresponding second remainder; the second remainder is the number of the lottery; the preset integer determines the numerical value change interval of the lottery number.
Optionally, the first hash value is hexadecimal data;
the lottery client divides the first hash value by the number n of the transfer strokes to obtain a corresponding first remainder m, and the method specifically comprises the following steps:
the lottery client converts the first hash value into corresponding decimal data;
and the lottery client divides the first hash value converted into decimal data by the number n of the transfer strokes to obtain a corresponding first remainder m.
Optionally, the second hash value is hexadecimal data;
the lottery client divides the second hash value by a preset integer to obtain a corresponding second remainder, and the method specifically comprises the following steps:
the lottery client converts the second hash value into corresponding decimal data;
and the lottery client divides the second hash value converted into decimal data by a preset integer to obtain a corresponding second remainder.
Optionally, when the preset integer is 10, the lottery number is changed within a range of 0-9.
Optionally, when the preset integer is 100, the lottery number is changed within a range of 00-99, and if the second remainder is less than 10, the tens of the lottery number is output after being zero-padded.
Specifically, when the preset integer is 10, a lottery number issuing operation is performed once, and a number which changes within the range of 0-9 is output. When the preset integer is 100, carrying out lottery number output operation once, and outputting numbers with two digits changing in the range of 00-99. It should be noted that, in the lottery number issuing scheme provided by the present invention, the preset integer may be set according to actual needs. Not limited to only 10 or 100. For example, if the predetermined integer is 8, the output random lottery number will vary from 0 to 7. The preset integer can be 50, and the output random lottery number can be changed within the range of 00-49, and the like. The preset integer can be selected by those skilled in the art according to actual needs to meet the requirement of the variation range interval of the corresponding lottery number. The invention is not limited in any way.
It is understood that if a lottery number of 8 is required, the preset integer may be set to 10, and a lottery number of one digit is issued each time, and 8 lottery issuing operations are performed, so as to finally obtain an 8-digit lottery number. Or setting the preset integer as 100, and issuing a lottery number with two digits each time, and issuing the lottery number 4 times to finally obtain a lottery number with 8 digits.
If a 7-digit lottery number needs to be issued, the preset integer is set to 10, a one-digit lottery number is issued each time, 7 times of lottery issuing are carried out, and finally a 7-digit lottery number is obtained. Or the preset integer is set as 100, a two-digit lottery number is played each time, 3 times of lottery number playing is carried out, then the preset integer is set as 10, one time of lottery number playing is carried out, and finally a 7-digit lottery number is obtained through accumulation.
Fig. 2 is a lottery random number issuing equipment architecture diagram applying a block chain provided by the present invention, as shown in fig. 2, including the following units:
a lottery number issuing initiatingunit 201, configured to initiate a transfer request on the blockchain, where the transfer request includes: an initiator address, a receiver address, and a transfer amount; the transfer request is used as a lottery number;
a firsthash operation unit 201, configured to perform a hash operation on the transfer request to obtain a first hash value;
the transferinformation acquisition unit 203 is used for acquiring the number n of transfer notes in the current corresponding block; n is a positive integer;
a firstremainder determining unit 204, configured to divide the first hash value by the number n of transfer strokes to obtain a corresponding first remainder m; m is a positive integer less than n;
the transferinformation acquisition unit 203 is used for acquiring the mth transfer in the current corresponding block;
a secondhash operation unit 205, configured to perform a hash operation on the mth transfer to obtain a second hash value;
a lotterynumber issuing unit 206, configured to divide the second hash value by a preset integer to obtain a corresponding second remainder; the second remainder is the number of the lottery; the preset integer determines the numerical value change interval of the lottery number.
Optionally, the first hash value is hexadecimal data; the firstremainder determination unit 204 converts the first hash value into corresponding decimal data; and dividing the first hash value converted into decimal data by the transfer stroke number n to obtain a corresponding first remainder m.
Optionally, the second hash value is hexadecimal data; thelottery drawing unit 206 converts the second hash value into corresponding decimal data; and dividing the second hash value converted into the decimal data by a preset integer to obtain a corresponding second remainder.
Optionally, when the preset integer is 10, the lottery number is changed within a range of 0-9.
Optionally, when the preset integer is 100, the lottery number is changed within a range of 00-99, and if the second remainder is less than 10, the tens of the lottery number is output after being zero-padded.
It will be understood by those skilled in the art that the foregoing is only a preferred embodiment of the present invention, and is not intended to limit the invention, and that any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the scope of the present invention.