CN114782109A - Anti-cheating lottery drawing method and device - Google Patents
Anti-cheating lottery drawing method and device Download PDFInfo
- Publication number
- CN114782109A CN114782109A CN202210499541.8A CN202210499541A CN114782109A CN 114782109 A CN114782109 A CN 114782109A CN 202210499541 A CN202210499541 A CN 202210499541A CN 114782109 A CN114782109 A CN 114782109A
- Authority
- CN
- China
- Prior art keywords
- lottery
- character string
- shuffling
- algorithm
- cheating
- Prior art date
- Legal status (The legal status 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 status listed.)
- Withdrawn
Links
- 238000000034 method Methods 0.000 title claims abstract description 39
- 238000004364 calculation method Methods 0.000 claims description 6
- 238000004891 communication Methods 0.000 claims description 3
- 238000012163 sequencing technique Methods 0.000 abstract description 4
- 230000002265 prevention Effects 0.000 abstract 1
- 238000011161 development Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION 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
- G06Q30/00—Commerce
- G06Q30/02—Marketing; Price estimation or determination; Fundraising
- G06Q30/0207—Discounts or incentives, e.g. coupons or rebates
- G06Q30/0225—Avoiding frauds
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION 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
- G06Q30/00—Commerce
- G06Q30/02—Marketing; Price estimation or determination; Fundraising
- G06Q30/0207—Discounts or incentives, e.g. coupons or rebates
- G06Q30/0212—Chance discounts or incentives
-
- G—PHYSICS
- G07—CHECKING-DEVICES
- G07C—TIME OR ATTENDANCE REGISTERS; REGISTERING OR INDICATING THE WORKING OF MACHINES; GENERATING RANDOM NUMBERS; VOTING OR LOTTERY APPARATUS; ARRANGEMENTS, SYSTEMS OR APPARATUS FOR CHECKING NOT PROVIDED FOR ELSEWHERE
- G07C15/00—Generating random numbers; Lottery apparatus
- G07C15/006—Generating random numbers; Lottery apparatus electronically
Landscapes
- Business, Economics & Management (AREA)
- Engineering & Computer Science (AREA)
- Accounting & Taxation (AREA)
- Development Economics (AREA)
- Finance (AREA)
- Strategic Management (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Game Theory and Decision Science (AREA)
- Marketing (AREA)
- Economics (AREA)
- General Business, Economics & Management (AREA)
- Entrepreneurship & Innovation (AREA)
- Theoretical Computer Science (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
The invention relates to an anti-cheating lottery drawing method, which comprises the following steps: creating a new lottery and creating a string storage variable; anyone can add any string to a variable; adding a time stamp, the number participating in the lottery and the number of winning numbers to be drawn to variables at the moment of starting the lottery; locking and disclosing the final character string variable; obtaining a hash value using a hash algorithm; then, performing equal probability sequencing of lottery drawing numbers by using a Fisher-Yates forward shuffling algorithm; a plurality of winning numbers are obtained from the sorted result set. The method replaces randomness with discreteness, anyone can participate in mathematical operation to influence the hash value but cannot forge the hash result, and the problem of collision possibly caused by multiple drawing is avoided by adopting a shuffling algorithm. The method has the characteristics of simple algorithm, transparent data disclosure and cheat prevention; the device or system supporting the algorithm has the characteristics of simple structure, easy realization and low software and hardware cost.
Description
Technical Field
The invention relates to the technical field of lottery drawing, in particular to an anti-cheating lottery drawing method and an anti-cheating lottery drawing device.
Background
Software lotteries are a widely used form of lotteries, but the opaqueness of the software lotteries process can easily lead to people questioning the credibility. The main reasons are generally: 1. the lottery algorithm is easily implanted into the back door by the software designer; 2. random factors used by a random algorithm which is generally adopted at present are difficult to detect whether the random factors are truly random or artificially set; 3. after the lottery is drawn, the user cannot reversely verify the lottery drawing result and process; 4. the user can not perform any supervision, participation and the like in the whole lottery drawing process.
The fairness of software lottery using the stochastic algorithm depends on the credibility of the program code. However, the operation process inside the software is generally unknown to users, and even impossible to know whether the lottery process is manually intervened, because the operation process is not public and opaque, the operation process is easy to cheat and difficult to detect in the lottery process.
The currently commonly used random lottery algorithm mainly comprises:
random factor method
In the process of generating random numbers by a computer, it is a random factor that is relied upon to achieve true randomness. Some current online lottery systems publish that use, for example, real-time stock trading information as a random factor to prove that the online lottery system is truly random, but still have difficulty in eliminating concerns.
(II) block chain type lottery drawing
With the development of the blockchain technology, a lottery system based on the blockchain technology is currently presented, and the principle of the lottery system is to rely on the hash value of the block and calculate the winning number by using the hash value. This mode credibility is higher, but utilizes block chain technique to draw a lottery and need rely on the new block that constantly produces, is used for non-real-time lottery usually, and system cost is higher, and the development degree of difficulty is great, verifies loaded down with trivial details.
Therefore, aiming at the problems of the current lottery software, a random lottery algorithm and a system combining a hash algorithm and a Fisher-Yates forward shuffling algorithm are designed. The data and algorithm of the lottery process are completely disclosed, people can participate in the operation in the lottery process, and the result is easy to verify. Programmers can easily program software according to the algorithm flow, and even if the codes are not disclosed, the programmers cannot cheat the programs by people.
Disclosure of Invention
The invention aims to provide a cheat-proof lottery drawing method and a cheat-proof lottery drawing device, which are used for solving the problems in the background technology.
In order to achieve the purpose, the invention provides the following technical scheme: an anti-cheating lottery method comprising the steps of:
s1, creating a new lottery and creating a character string storage variable T, wherein the number of the elements of the array A is the total lottery number;
s2, adding a time stamp, the number N of lottery participation and the number of winning numbers to be drawn into T at the moment before lottery drawing, and locking and disclosing the final character string T;
s3, sequencing the lottery array A by using a Fisher-Yates forward shuffling algorithm, and taking the hash value M of T as a dividend for remainder in the shuffling algorithm;
s4, publishing the winning number and the final character string T.
Preferably, in step S1, each participant may add a new arbitrary character string to T.
Preferably, in step S3, the hash value is used to replace the random value to perform the remainder operation of the shuffling algorithm, and the shuffling algorithm is used to avoid lottery collision.
Preferably, in step S4, the winning number and the final string T are published, and the winning number is contained in the string T and is allowed to be downloaded and saved.
Preferably, in step S3, after the number in the current round is added to the character string T after each shuffling, the number is used for recalculating M for the next round of shuffling; the card shuffling times are the number of lotteries required to draw.
The invention discloses an anti-cheating lottery drawing device which comprises a database storage system, a service component and a client component, wherein the database storage system is used for storing lottery drawing result data and is connected with the service component;
the service component is used for creating a new lottery, receiving and splicing the character strings sent by the client component, synchronously distributing the latest character strings to all the client components, and performing lottery calculation;
the client component can communicate with the service component through a TCP (transmission control protocol), a Bluetooth protocol or serial communication and the like, can upload any character string to be spliced as original data for hash operation, and can check the lottery process in real time.
Preferably, the service component is responsible for creating a lottery, receiving and splicing the character string information sent from the client component in real time, and being responsible for the operation of lottery results; and synchronously distributing data in real time, and synchronously disclosing the latest spliced character strings, the lottery drawing process and the result to all client side components.
Preferably, the client component can send any character string to the service component, participate in hash operation and Fisher-Yates forward shuffling operation, receive public information of the service component in real time, and download and store the public information.
Preferably, the database storage system is responsible for storing the string information for hash calculation and the lottery result.
Compared with the prior art, the invention has the following beneficial effects:
the algorithm process of the invention is completely open and transparent, the lottery drawing process is open and fair, and a software producer cannot artificially forge lottery drawing results. By using the original character string that anyone can modify as the data source of the hash operation, it is known from the principle of hash operation that any modification of the original character string results in a great change and non-reversibility of the hash result, so that the original character string cannot be forged by obtaining the desired hash result. The hash result is adopted to replace the random result, so that the occurrence of pseudo-random can be effectively avoided, and the possible pseudo-random faking is avoided. And the Fisher-Yates forward shuffling algorithm is combined to randomly shuffle in equal probability, so that the collision of pure random lottery drawing can be effectively avoided. The device supporting the algorithm has simple structure and low implementation cost, and ensures that software and hardware designers cannot cheat. The process data is fully published and the results are easily verified.
Drawings
FIG. 1 is a schematic flow chart of an anti-cheating lottery drawing method according to the present invention;
fig. 2 is a schematic structural diagram of an anti-cheating lottery drawing method according to the present invention.
In the figure: 1. database storage system, 2, service component, 3, client component.
Detailed Description
The technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. It should be apparent that the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1-2, the present invention provides a technical solution: an anti-cheating lottery method comprising the steps of:
s1, creating a new lottery and creating a character string storage variable T, wherein the number of the elements of the array A is the total lottery number;
and the character string variable T is used for splicing the character strings input by the participants in real time, and the character string variable T is updated and disclosed in real time. The array A is used for storing numbers to be lottery-drawn, and the length of the array A is the number of the numbers participating in lottery drawing;
s2, each participant can add a new arbitrary character string to the T;
any character string can contain numbers, upper and lower case letters, special characters, Chinese characters and the like, and the length is not limited or can be limited to a certain extent.
The method enables each participant to participate in the hash operation, and according to the principle of the hash operation, any change of T can cause great change of the hash result, and the original character string T can not be deduced backwards through the specific hash result.
S3, adding the time stamp, the lottery participation quantity and the number of the lottery numbers to be drawn into the T at the moment before lottery drawing, and locking and disclosing the final character string T;
the time stamp is added at the moment before the lottery so as to further strengthen the randomness of T, and the character string T is disclosed to ensure the reliability of the lottery.
S4, sorting the lottery drawing array A by using Fisher-Yates forward shuffling algorithm, and using the hashed value M of T as a dividend for remainder in the shuffling algorithm;
s5, publishing the winning number and the final character string T.
The invention discloses an anti-cheating lottery drawing algorithm, which comprises the steps of firstly obtaining and locking a character string, and then randomly sequencing lottery drawing numbers by using a hash algorithm and a Fisher-Yates forward shuffling algorithm.
Further, in step S4, the hash value is used to replace the random value to perform the remainder operation of the shuffling algorithm, and the shuffling algorithm is used to avoid lottery collision.
The hash algorithm is a message digest, and any change in T results in a large change in the hash result, which is used in the present algorithm to replace the random result.
Further, in step S5, the winning number and the final string T are published, and the string T contains the winning number and is allowed to be downloaded and saved.
Further, in step S4, after the number in the current round is added to the character string T after each shuffling, the number is used for recalculating M for the next round of shuffling; the shuffling times are the number N of the lottery required.
And sequencing the lottery drawing array A by adopting a Fisher-Yates forward shuffling algorithm, taking M as a dividend for remainder in the shuffling algorithm, taking the number of the remaining unshuffled drawing in the array A as a divisor, and shuffling for N times under the assumption that N lottery drawing numbers are obtained. And adding the remainder of the round to the character string T after each card shuffling.
The invention discloses an anti-cheating lottery drawing device, which comprises a database storage system 1, a service component 2 and a client component 3, wherein the database storage system 1 is used for storing lottery drawing result data and is connected with the service component 2;
the service component 2 is used for creating a new lottery, receiving and splicing the character strings sent by the client component 3, synchronously distributing the latest character strings to all the client components 3, and performing lottery calculation;
the client component 3 can communicate with the service component 2 through a TCP (transmission control protocol), a Bluetooth protocol or serial communication and the like, can upload any character string to be spliced as original data for hash operation, and can check the lottery process in real time.
Further, the service component 2 is responsible for creating a lottery, receiving and splicing the character string information sent from the client component 3 in real time, being responsible for computing lottery results, synchronously distributing data in real time, and synchronously showing the latest spliced character string, lottery process and result to all the client components 3.
Furthermore, the client component 3 can send any character string to the service component 2, participate in hash operation and Fisher-Yates forward shuffling operation, and simultaneously can receive public information of the service component 2 in real time and download and store the public information.
Further, the database storage system 1 is responsible for storing string information for hash calculation and lottery results.
In a specific implementation, assuming that the total number of people participating in the lottery is N-10, two winning numbers are drawn. The persons participating in the drawing are numbered before the drawing starts, starting with 1 and going up to 10.
Firstly, a new lottery is created by the service component, a character string variable T of the lottery is initialized to be an empty character string, an array A is initialized, the length of the array A is equal to the number N of participating in the lottery, the corresponding relation of the array A is A [0] … A [9] corresponding personnel number 1 … 10, and J is equal to 3 winning numbers to be extracted;
in the second step, before drawing, anyone can access the drawing service component through a client component (a mobile phone APP or a browser or a terminal device) to submit any character string. Assuming that the client component 1 submits the string "ABC" and the client component 2 submits the string "123", T is updated to "ABC 123" in real time. The result is dynamically updated, and each person can add a new character string before drawing a lottery and synchronously release the new character string to all clients in real time;
thirdly, adding a time stamp, the number participating in lottery drawing and the number of winning numbers to be drawn to the tail part of the character string T at the moment of lottery drawing, wherein T is updated to be ABC123#2020-03-1112:23:25#10# 3;
fourth, sort lottery array A using Fisher-Yates forward shuffling algorithm, with hash value M of T as the dividend to remainder in shuffling algorithm, in this example we use MD5 hashing, and then extract the Arabic numbers of the hash value as the dividend to remainder:
MD5(T)=“A2F48254713B0DD398EED55FDCA42CB8”
M=248254713039855428
fifthly, shuffling the cards in the first round by subtracting the shuffled times U from the total length N of the arrays:
calculating remainder: m MOD (N-U) 248254713039855428MOD (10-0) 8, i.e., the array element a [0] is interchanged with a [8], the first winning number is a [8], whose value is 9;
and sixthly, updating the character string T to be ABC123#2020-03-1112:23:25#10#3#9, and repeating the fourth step to the sixth step twice when U is 1, thereby completing the drawing of 3 winning numbers.
Seventhly, publishing the winning numbers and the final character string T:
T=“ABC123#2020-03-1112:23:25#10#3#9#6#4”
at this point, the random lottery drawing of 3 numbers is completed, and the results are 9, 6 and 4. Finally, the character strings are synchronously disclosed and saved in a database storage system, and can be downloaded by anyone.
The anti-cheating algorithm is simple, anyone can participate in operation, a program cannot be falsified by a single party, verification is easy, software implementation is easy, and development cost is low.
Although the present invention has been described in detail with reference to the foregoing embodiments, it will be apparent to those skilled in the art that various changes in the form and details may be made therein without departing from the spirit and scope of the invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (9)
1. An anti-cheating lottery method comprising the steps of:
s1, creating a new lottery and creating a character string storage variable T, wherein the number of the elements of the array A is the total lottery number;
s2, adding a time stamp, the number participating in lottery drawing and the number of winning numbers to be drawn into T at the moment before lottery drawing, and locking and disclosing the final character string T;
s3, sorting the lottery drawing array A by using Fisher-Yates forward shuffling algorithm, and using the hashed value M of T as a dividend for remainder in the shuffling algorithm;
s4, publishing the winning number and the final character string T.
2. The cheat-proof lottery method of claim 1, wherein: in step S1, each participant can add a new arbitrary character string to T.
3. The anti-cheating lottery method according to claim 1, wherein: in step S3, the hash value is used to replace the random value to perform the remainder operation of the shuffling algorithm, and the shuffling algorithm is used to avoid lottery collision.
4. The cheat-proof lottery method of claim 1, wherein: in step S4, the winning number and the final string T are published, and the string T contains the winning number and is allowed to be downloaded and saved.
5. The cheat-proof lottery method of claim 1, wherein: in the step S3, after the number in the current round of shuffling is added to the character string T after each shuffling, the number is used for recalculating M in the next round of shuffling; the shuffling times are the number of lottery draws required.
6. An anti-cheating lottery drawing device is characterized by comprising a database storage system (1), a service component (2) and a client component (3), wherein the database storage system (1) is used for storing lottery drawing result data and is connected with the service component (2);
the service component (2) is used for creating a new lottery, receiving and splicing the character strings sent by the client components (3), synchronously distributing the latest character strings to all the client components (3), and performing lottery calculation;
the client component (3) can communicate with the service component (2) through a TCP protocol, a Bluetooth protocol serial communication and the like, upload any character string to be spliced as original data for hash operation, and check the lottery drawing process in real time.
7. The anti-cheating lottery device of claim 6, wherein: the service component (2) is responsible for creating a lottery, receiving and splicing character string information sent from the client components (3) in real time, being responsible for computing lottery results, synchronously distributing data in real time, and synchronously showing the latest spliced character strings, lottery processes and results to all the client components (3).
8. The cheat-resistant lottery device of claim 6, wherein: the client component (3) can send any character string to the service component (2) to participate in hash operation and Fisher-Yates forward shuffling operation, and meanwhile can receive public information of the service component (2) in real time and download and store the public information.
9. An anti-cheating lottery device according to claim 6, wherein: the database storage system (1) is responsible for storing character string information used for hash calculation and lottery results.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210499541.8A CN114782109A (en) | 2022-05-09 | 2022-05-09 | Anti-cheating lottery drawing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210499541.8A CN114782109A (en) | 2022-05-09 | 2022-05-09 | Anti-cheating lottery drawing method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114782109A true CN114782109A (en) | 2022-07-22 |
Family
ID=82436260
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210499541.8A Withdrawn CN114782109A (en) | 2022-05-09 | 2022-05-09 | Anti-cheating lottery drawing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114782109A (en) |
-
2022
- 2022-05-09 CN CN202210499541.8A patent/CN114782109A/en not_active Withdrawn
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107566124B (en) | Hash operation-based consensus establishing method, block chain system and storage medium | |
CN107103097A (en) | Drawing method and terminal device based on block chain technology | |
CN108900382B (en) | Test method and device thereof | |
CN114281888A (en) | Block chain consensus method, device, equipment and storage medium | |
CN105224662A (en) | Worksheet method and apparatus | |
CN108335208B (en) | Method and apparatus for processing information | |
CN110647311A (en) | Uncontrollable random number generation method and system | |
CN114519198A (en) | Block chain consensus method and computer-readable storage medium | |
CN113343089A (en) | User recall method, device and equipment | |
CN113342838A (en) | Data processing method, device and equipment based on block chain and readable storage medium | |
CN114205087B (en) | Block chain random number generation method | |
CN114782109A (en) | Anti-cheating lottery drawing method and device | |
CN111352832B (en) | Method and device for automatically testing page | |
CN116570928A (en) | Information processing method, device and server based on NFT | |
CN116846583A (en) | Finite state security man-machine verification system based on set differencing and method thereof | |
KR102251485B1 (en) | Method and device for a transparent lottery system by using a blockchain network | |
CN116244164A (en) | Test data packet generation method and device, electronic equipment and storage medium | |
Adhar et al. | Application of the Fisher-Yates Shuffle Algorithm in the Game Matching the World Monument Picture | |
CN113987328A (en) | Topic recommendation method, equipment, server and storage medium | |
US20200171390A1 (en) | Methods for provisioning and management of gamer accounts for e-tournaments | |
CN112657189A (en) | Data processing method and device, server and storage medium | |
CN111714894A (en) | Game data acquisition method and device, electronic equipment and storage medium | |
CN108320400A (en) | Sports formula lottery system based on wechat platform | |
CN115001751B (en) | Dynamic verification method and device, electronic equipment and storage medium | |
CN117560161B (en) | Method and device for rotating consensus nodes of block chain and readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WW01 | Invention patent application withdrawn after publication | ||
WW01 | Invention patent application withdrawn after publication |
Application publication date: 20220722 |