CN111008863A - Lottery drawing method and system based on block chain - Google Patents
Lottery drawing method and system based on block chain Download PDFInfo
- Publication number
- CN111008863A CN111008863A CN201911191570.2A CN201911191570A CN111008863A CN 111008863 A CN111008863 A CN 111008863A CN 201911191570 A CN201911191570 A CN 201911191570A CN 111008863 A CN111008863 A CN 111008863A
- Authority
- CN
- China
- Prior art keywords
- hash value
- intelligent contract
- ciphertext
- lottery
- private key
- 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.)
- Granted
Links
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/0212—Chance discounts or incentives
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/602—Providing cryptographic facilities or services
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/64—Protecting data integrity, e.g. using checksums, certificates or signatures
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Development Economics (AREA)
- General Engineering & Computer Science (AREA)
- General Health & Medical Sciences (AREA)
- Bioethics (AREA)
- Health & Medical Sciences (AREA)
- Accounting & Taxation (AREA)
- Software Systems (AREA)
- Strategic Management (AREA)
- Finance (AREA)
- Game Theory and Decision Science (AREA)
- Entrepreneurship & Innovation (AREA)
- Economics (AREA)
- Marketing (AREA)
- General Business, Economics & Management (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
The embodiment of the invention provides a lottery method and a system based on a block chain, wherein the method comprises the following steps: randomly generating a pair of public key and private key according to an intelligent contract, disclosing the public key on a block chain, and initializing a hash value in the intelligent contract; encrypting and carrying out hash operation on random character strings uploaded to the blockchain by each participant of the lottery activity, and updating a hash value in the intelligent contract according to the operation result; and encrypting the updated hash value in the intelligent contract by using the private key to obtain a private key encrypted ciphertext, further updating the hash value in the intelligent contract according to a result obtained by carrying out hash operation on the private key encrypted ciphertext, and determining the number of the winning participant through the further updated hash value in the intelligent contract. Through the embodiment of the invention, the randomness and the fairness of the lottery can be improved based on the block chain.
Description
Technical Field
The invention belongs to the technical field of block chains, and particularly relates to a lottery drawing method, a lottery drawing system, terminal equipment and a computer readable medium based on a block chain.
Background
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. It is essentially a decentralized database, a string of data blocks associated by cryptography, each data block containing information of a batch of network transactions for verifying the validity (anti-counterfeiting) of the information and generating the next block. In a narrow sense, the blockchain is a distributed account book which is a chain data structure formed by combining data blocks in a sequential connection mode according to a time sequence and is guaranteed in a cryptographic mode and cannot be tampered and forged. Broadly, the blockchain technique is a completely new distributed infrastructure and computing approach that utilizes blockchain data structures to verify and store data, utilizes distributed node consensus algorithms to generate and update data, utilizes cryptography to secure data transmission and access, and utilizes intelligent contracts composed of automated script code to program and manipulate data.
At present, a lottery drawing platform basically adopts a centralized mode to draw a lottery, lottery drawing data is stored at the rear end of a system and has tampering property, a user cannot know the lottery drawing process, and the result cannot be verified. Therefore, the existing method is difficult to ensure fairness and authenticity, and how to use the blockchain technology to carry out lottery activities based on the characteristic that the blockchain cannot be tampered becomes an urgent problem to be solved.
Disclosure of Invention
In view of the above, embodiments of the present invention provide a lottery method, a lottery system, a terminal device, and a computer-readable medium based on a blockchain, which can improve randomness and fairness of a lottery based on the blockchain.
A first aspect of an embodiment of the present invention provides a lottery method based on a blockchain, including:
randomly generating a pair of public key and private key according to an intelligent contract, disclosing the public key on a block chain, and initializing a hash value in the intelligent contract; wherein the intelligent contract corresponds to a lottery activity and is used for ensuring that the lottery method is not falsifiable;
encrypting and carrying out hash operation on random character strings uploaded to the blockchain by each participant of the lottery activity, and updating a hash value in the intelligent contract according to the operation result;
and encrypting the updated hash value in the intelligent contract by using the private key to obtain a private key encrypted ciphertext, further updating the hash value in the intelligent contract according to a result obtained by carrying out hash operation on the private key encrypted ciphertext, and determining the number of the winning participant through the further updated hash value in the intelligent contract. .
A second aspect of an embodiment of the present invention provides a lottery system based on a blockchain, including:
the generating module is used for randomly generating a pair of public key and private key according to the intelligent contract, disclosing the public key on a block chain and initializing a hash value in the intelligent contract; wherein the intelligent contract corresponds to a lottery activity and is used for ensuring that the lottery method is not falsifiable;
the participation module is used for encrypting and carrying out Hash operation on the random character strings uploaded to the block chain by each participant of the lottery activity and updating the Hash value in the intelligent contract according to the operation result;
and the determining module is used for encrypting the updated hash value in the intelligent contract by using the private key to obtain a private key encrypted ciphertext, further updating the hash value in the intelligent contract according to the result obtained by carrying out hash operation on the private key encrypted ciphertext, and determining the number of the winning participant according to the further updated hash value in the intelligent contract.
A third aspect of embodiments of the present invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the above-described lottery method based on a blockchain when executing the computer program.
A fourth aspect of embodiments of the present invention provides a computer-readable medium storing a computer program which, when executed by a processor, implements the steps of the above-described blockchain-based lottery method.
The random number generation method based on the block chain provided by the embodiment of the invention can randomly generate a pair of public key and private key according to an intelligent contract, disclose the public key on the block chain, initialize the hash value in the intelligent contract, encrypt and hash the random character string uploaded to the block chain by each participant of the lottery activity, update the hash value in the intelligent contract according to the operation result, finally encrypt the updated hash value in the intelligent contract by using the private key to obtain the private key encrypted ciphertext, further update the hash value in the intelligent contract according to the result obtained by hash operation on the private key encrypted ciphertext, determine the number of winning participant through the further updated hash value in the intelligent contract, thereby ensuring that all lottery users participate in encrypting the lottery information, and the method for encrypting the lottery drawing information by using the random private key ensures that the lottery drawing has enough randomness and fairness.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart of a lottery method based on a blockchain according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a process of encrypting and performing hash operation on random character strings uploaded by each participant of a lottery activity in the lottery method based on a blockchain according to an embodiment of the present invention, and updating a hash value in the intelligent contract according to a result of the operation;
fig. 3 is a schematic structural diagram of a lottery system based on a blockchain according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a refinement provided by one embodiment of the participation module of FIG. 3;
FIG. 5 is a schematic diagram of a refinement provided by another embodiment of the participation module of FIG. 3;
fig. 6 is a schematic diagram of a terminal device according to an embodiment of the present invention.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
In order to explain the technical means of the present invention, the following description will be given by way of specific examples.
Referring to fig. 1, fig. 1 is a block chain-based lottery method according to an embodiment of the present invention. As shown in fig. 1, the lottery method based on the blockchain of the present embodiment includes the following steps:
s101: randomly generating a pair of public key and private key according to the intelligent contract, disclosing the public key on a block chain, and initializing a hash value in the intelligent contract.
In the embodiment of the invention, a pair of public key pk and private key sk can be generated according to the intelligent contract corresponding to the lottery activity, the public key pk is disclosed on the block chain, and the hash value in the intelligent contract is initialized. The intelligent contract corresponds to the lottery activity and is used for realizing the lottery method based on the block chain provided by the embodiment of the invention and ensuring that the lottery method cannot be tampered. Further, before generating the public key pk and the private key sk, a lottery activity may be initiated and the number m of participants of the lottery activity may be set.
S102: and encrypting and carrying out hash operation on the random character strings uploaded to the blockchain by each participant of the lottery activity, and updating the hash value in the intelligent contract according to the operation result.
In an embodiment of the present invention, according to the time sequence of the participants participating in the lottery activity, the initialized hash value in the intelligent contract may be encrypted by using the random character string S1 uploaded to the blockchain by the first participant to obtain a first ciphertext P1, the first ciphertext P1 is subjected to hash operation, and the initialized hash value in the intelligent contract is replaced by an operation result obtained by performing hash operation on the first ciphertext P1 to obtain a first updated hash value in the intelligent contract; encrypting the ith-1 updated hash value by using a random character string Si uploaded to the block chain by the ith participant to obtain an ith ciphertext Pi, performing hash operation on the ith ciphertext Pi, and replacing the ith-1 updated hash value in the intelligent contract with an operation result obtained by performing hash operation on the ith ciphertext Pi to obtain an ith updated hash value; wherein 1< i < m, m being the total number of people participating in the lottery. For example, encrypting the first updated hash value by using a random character string S2 uploaded to the blockchain by a second participant to obtain a second ciphertext P2, performing hash operation on the second ciphertext P2, and replacing the first updated hash value in the intelligent contract with an operation result obtained by performing hash operation on the second ciphertext P2 to obtain a second updated hash value; and repeating the steps until the m-1 updated hash value is encrypted by using the random character string Sm uploaded to the block chain by the last participant (namely the mth participant) to obtain the mth ciphertext Pm, performing hash operation on the mth ciphertext Pm, and replacing the m-1 updated hash value in the intelligent contract with the operation result obtained by performing the hash operation on the mth ciphertext Pm to obtain the mth updated hash value. As shown in fig. 2, in S1021, the ith participant can transmit its custom string (i.e., custom random string) Si to the blockchain; in S1022, the i-th ciphertext Pi may be obtained by encrypting the hash value in the register H (i.e., the i-1 st updated hash value of the hash value in the intelligent contract, or referred to as the i-1 st updated hash value) by Si; in S1023, carrying out hash operation on Pi to obtain a new hash value and storing the new hash value in a register H to replace the ith-1 to update the hash value; and in S1024, judging whether i is smaller than the set participant number m of the lottery activity, if so, repeatedly executing S1021-S1024 through the random character string transmitted by the i +1 th participant, and circulating until the m-th updated hash value is obtained through the random character string transmitted by the m-th participant.
In another embodiment of the present invention, the random character strings uploaded to the block chain by all participants of the lottery activity may be spliced together, the initialized hash value in the intelligent contract may be encrypted using the spliced random character strings to obtain a ciphertext P, the ciphertext P may be subjected to a hash operation, and the initialized hash value in the intelligent contract may be replaced with an operation result obtained by performing the hash operation on the ciphertext P to obtain an updated hash value in the intelligent contract. It will be appreciated that this approach may reduce some amount of computation, but requires more memory space.
S103: and encrypting the updated hash value in the intelligent contract by using the private key to obtain a private key encrypted ciphertext, further updating the hash value in the intelligent contract according to a result obtained by carrying out hash operation on the private key encrypted ciphertext, and determining the number of the winning participant through the further updated hash value in the intelligent contract.
In the embodiment of the invention, the updated hash value in the intelligent contract can be encrypted by the private key sk to obtain a private key encryption ciphertext D (namely, the ciphertext D encrypted by the private key); then, performing hash operation on the private key encrypted ciphertext D, and further updating the hash value in the intelligent contract by using a result obtained by performing hash operation on the private key encrypted ciphertext D (that is, replacing the updated hash value by using the result obtained by performing hash operation on the private key encrypted ciphertext D, so as to further update the hash value in the intelligent contract); finally, the further updated hash value in the smart contract can be converted into a 256-bit unsigned integer K, by which the number of winning participants is obtained modulo the number m of participants in the lottery. The hash operation may be, for example, a hash operation performed using the SHA2 function. It should be noted that the user on the blockchain may use the public key pk, the hash values of the stages in the smart contract, and the private key encryption ciphertext D to verify whether the private key sk is tampered with.
In the lottery method based on the blockchain provided by the embodiment of the invention, the encryption operation and the hash operation are performed by utilizing the value transmitted by each participant of the lottery activity on the blockchain, so that all the participants can participate in the process of the lottery activity and influence the lottery result. Moreover, the public and private key pair is generated in advance, a public key is disclosed, and the private key is adopted for carrying out encryption operation in the subsequent process, so that the possibility of tampering is avoided, and the fairness and the real randomness of the lottery result can be ensured. In addition, the whole lottery drawing method process links, the process and the result are public and verifiable, and the reality, the randomness and the credibility of the result can be ensured.
Referring to fig. 3, fig. 3 is a block diagram of a lottery system based on a blockchain according to an embodiment of the present invention. As shown in fig. 3, the lottery system 30 based on the blockchain of the present embodiment includes a generation module 301, a participation module 302, and a determination module 303. The generating module 301, the participating module 302 and the determining module 303 are respectively configured to perform the specific methods in S101, S102 and S103 in fig. 1, and details can be referred to in the related introduction of fig. 1 and are only briefly described here:
a generating module 301, configured to randomly generate a pair of a public key and a private key according to an intelligent contract, disclose the public key on a block chain, and initialize a hash value in the intelligent contract; wherein the intelligent contract corresponds to a lottery activity and is used for ensuring that the lottery method is not falsifiable.
A participation module 302, configured to perform encryption and hash operations on the random character strings uploaded to the blockchain by each participant of the lottery activity, and update the hash value in the intelligent contract according to the operation result.
The determining module 303 is configured to encrypt the updated hash value in the intelligent contract using the private key to obtain a private key encrypted ciphertext, further update the hash value in the intelligent contract with a result obtained by performing hash operation on the private key encrypted ciphertext, and determine the number of the winning participant according to the further updated hash value in the intelligent contract.
Further, in an embodiment of the present invention, referring to fig. 4, the participation module 302 may specifically include a first participation unit 3021, an ith participation unit 3022, and an mth participation unit 3023:
a first participating unit 3021, configured to encrypt the initialized hash value in the smart contract by using the random character string S1 uploaded to the blockchain by the first participant according to the time sequence of participation in the lottery activity by the participant, to obtain a first ciphertext P1, perform a hash operation on the first ciphertext P1, and replace the initialized hash value in the smart contract with an operation result obtained by performing the hash operation on the first ciphertext P1, to obtain a first updated hash value in the smart contract.
An ith participation unit 3022, configured to encrypt an ith-1 update hash value using a random string Si uploaded to the block chain by an ith participant to obtain an ith ciphertext Pi, perform hash operation on the ith ciphertext Pi, and replace the ith-1 update hash value in the intelligent contract with an operation result obtained by performing hash operation on the ith ciphertext Pi to obtain an ith update hash value; wherein 1< i < m, m being the total number of people participating in the lottery.
The mth participation unit 3023 is configured to, by analogy, encrypt the mth-1 update hash value using the random character string Sm uploaded to the block chain by the mth participant to obtain a mth ciphertext Pm, perform hash operation on the mth ciphertext Pm, and replace the mth-1 update hash value in the intelligent contract with an operation result obtained by performing hash operation on the mth ciphertext Pm to obtain a mth update hash value.
Further, in another embodiment of the present invention, referring to fig. 5, the participation module 302 may specifically include a splicing encryption unit 3024 and an update unit 3025:
and the splicing encryption unit 3024 is configured to splice the random character strings uploaded to the block chain by all participants of the lottery activity, and encrypt the initialized hash value in the intelligent contract using the spliced random character strings to obtain a ciphertext P.
An updating unit 3025, configured to perform a hash operation on the ciphertext P, and replace the initialized hash value in the intelligent contract with an operation result obtained by performing the hash operation on the ciphertext P, so as to obtain an updated hash value in the intelligent contract.
The lottery system based on blockchain provided in fig. 3 can perform encryption operation and hash operation by using the incoming value of each participant in the lottery on the blockchain, so that all participants can participate in the process of the lottery and influence the result of the lottery. Moreover, the public and private key pair is generated in advance, a public key is disclosed, and the private key is adopted for carrying out encryption operation in the subsequent process, so that the possibility of tampering is avoided, and the fairness and the real randomness of the lottery result can be ensured. In addition, the whole lottery drawing method process links, the process and the result are public and verifiable, and the reality, the randomness and the credibility of the result can be ensured.
Fig. 6 is a schematic diagram of a terminal device according to an embodiment of the present invention. As shown in fig. 6, the terminal device 6 of this embodiment includes: a processor 60, a memory 61 and a computer program 62 stored in said memory 61 and executable on said processor 60, such as a program for performing a blockchain based lottery method. The processor 60, when executing the computer program 62, implements the steps in the above-described method embodiments, e.g., S101 to S103 shown in fig. 1. Alternatively, the processor 60, when executing the computer program 62, implements the functions of the modules/units in the system embodiments, such as the functions of the modules 301 to 303 shown in fig. 3.
Illustratively, the computer program 62 may be partitioned into one or more modules/units that are stored in the memory 61 and executed by the processor 60 to implement the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 62 in the terminal device 6. For example, the computer program 62 may be divided into a generation module 301, a participation module 302, and a determination module 303. (modules in the virtual system), the specific functions of each module are as follows:
a generating module 301, configured to randomly generate a pair of a public key and a private key according to an intelligent contract, disclose the public key on a block chain, and initialize a hash value in the intelligent contract; wherein the intelligent contract corresponds to a lottery activity and is used for ensuring that the lottery method is not falsifiable.
A participation module 302, configured to perform encryption and hash operations on the random character strings uploaded to the blockchain by each participant of the lottery activity, and update the hash value in the intelligent contract according to the operation result.
The determining module 303 is configured to encrypt the updated hash value in the intelligent contract using the private key to obtain a private key encrypted ciphertext, further update the hash value in the intelligent contract with a result obtained by performing hash operation on the private key encrypted ciphertext, and determine the number of the winning participant according to the further updated hash value in the intelligent contract.
The terminal device 6 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. Terminal device 6 may include, but is not limited to, a processor 60, a memory 61. Those skilled in the art will appreciate that fig. 6 is merely an example of a terminal device 6 and does not constitute a limitation of terminal device 6 and may include more or less components than those shown, or some components in combination, or different components, for example, the terminal device may also include input output devices, network access devices, buses, etc.
The Processor 60 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 61 may be an internal storage unit of the terminal device 6, such as a hard disk or a memory of the terminal device 6. The memory 61 may also be an external storage device of the terminal device 6, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) and the like provided on the terminal device 6. Further, the memory 61 may also include both an internal storage unit of the terminal device 6 and an external storage device. The memory 61 is used for storing the computer programs and other programs and data required by the terminal device 6. The memory 61 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the system is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed system/terminal device and method can be implemented in other ways. For example, the above-described system/terminal device embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.
Claims (10)
1. A lottery method based on a blockchain is characterized by comprising the following steps:
randomly generating a pair of public key and private key according to an intelligent contract, disclosing the public key on a block chain, and initializing a hash value in the intelligent contract; wherein the intelligent contract corresponds to a lottery activity and is used for ensuring that the lottery method is not falsifiable;
encrypting and carrying out hash operation on random character strings uploaded to the blockchain by each participant of the lottery activity, and updating a hash value in the intelligent contract according to the operation result;
and encrypting the updated hash value in the intelligent contract by using the private key to obtain a private key encrypted ciphertext, further updating the hash value in the intelligent contract according to a result obtained by carrying out hash operation on the private key encrypted ciphertext, and determining the number of the winning participant through the further updated hash value in the intelligent contract.
2. The blockchain-based lottery method according to claim 1, wherein before randomly generating a pair of a public key and a private key according to a smart contract and publishing the public key on the blockchain and initializing a hash value in the smart contract, the method further comprises:
initiating a lottery activity and setting a number of participants in the lottery activity.
3. The blockchain-based lottery method according to claim 1, wherein the encrypting and hashing random character strings uploaded to the blockchain by each participant of the lottery activity, and updating the hash value in the smart contract with the result of the encrypting and hashing operations comprise:
according to the time sequence of the participants participating in the lottery activity, encrypting the initialized hash value in the intelligent contract by using a random character string S1 uploaded to the blockchain by a first participant to obtain a first ciphertext P1, performing hash operation on the first ciphertext P1, and replacing the initialized hash value in the intelligent contract with an operation result obtained by performing hash operation on the first ciphertext P1 to obtain a first updated hash value in the intelligent contract;
encrypting an ith-1 updating hash value by using a random character string Si uploaded to the block chain by the ith participant to obtain an ith ciphertext Pi, performing hash operation on the ith ciphertext Pi, and replacing the ith-1 updating hash value in the intelligent contract with an operation result obtained by performing hash operation on the ith ciphertext Pi to obtain an ith updating hash value; wherein 1< i < m, m being the total number of people participating in the lottery;
and in the same way, encrypting the m-1 th updated hash value by using the random character string Sm uploaded to the block chain by the mth participant to obtain the mth ciphertext Pm, performing hash operation on the mth ciphertext Pm, and replacing the m-1 th updated hash value in the intelligent contract with the operation result obtained by performing hash operation on the mth ciphertext Pm to obtain the mth updated hash value.
4. The blockchain-based lottery method according to claim 1, wherein the encrypting and hashing random character strings uploaded to the blockchain by each participant of the lottery activity, and updating the hash value in the smart contract with the result of the encrypting and hashing operations comprise:
splicing the random character strings uploaded to the block chain by all participants of the lottery activity, and encrypting the initialized hash value in the intelligent contract by using the spliced random character strings to obtain a ciphertext P;
and performing Hash operation on the ciphertext P, and replacing the initialized Hash value in the intelligent contract with an operation result obtained after the Hash operation is performed on the ciphertext P to obtain an updated Hash value in the intelligent contract.
5. The blockchain-based lottery method according to any one of claims 1 to 4, wherein the encrypting the updated hash value in the intelligent contract by using the private key to obtain a private key encrypted ciphertext, and further updating the hash value in the intelligent contract with a result of performing a hash operation on the private key encrypted ciphertext D, and determining the number of winning participants by the further updated hash value in the intelligent contract, comprises:
encrypting the updated hash value in the intelligent contract by using the private key to obtain a private key encryption ciphertext;
performing hash operation on the private key encrypted ciphertext to further update a hash value in the intelligent contract according to a result obtained by performing hash operation on the private key encrypted ciphertext;
converting the further updated hash value in the smart contract into a 256-bit unsigned integer K, and modulo the number m of the lottery participants by the unsigned integer K to obtain the number of winning participants.
6. A blockchain-based lottery system, comprising:
the generating module is used for randomly generating a pair of public key and private key according to the intelligent contract, disclosing the public key on a block chain and initializing a hash value in the intelligent contract; wherein the intelligent contract corresponds to a lottery activity and is used for ensuring that the lottery method is not falsifiable;
the participation module is used for encrypting and carrying out Hash operation on the random character strings uploaded to the block chain by each participant of the lottery activity and updating the Hash value in the intelligent contract according to the operation result;
and the determining module is used for encrypting the updated hash value in the intelligent contract by using the private key to obtain a private key encrypted ciphertext, further updating the hash value in the intelligent contract according to the result obtained by carrying out hash operation on the private key encrypted ciphertext, and determining the number of the winning participant according to the further updated hash value in the intelligent contract.
7. The blockchain-based lottery system of claim 6, wherein the participation module includes:
a first participation unit, configured to encrypt the initialized hash value in the intelligent contract by using a random character string S1 uploaded to the blockchain by a first participant according to a time sequence of participation in the lottery activity by the participant, to obtain a first ciphertext P1, perform hash operation on the first ciphertext P1, and replace the initialized hash value in the intelligent contract with an operation result obtained by performing hash operation on the first ciphertext P1, to obtain a first updated hash value in the intelligent contract;
the ith participation unit is used for encrypting the ith-1 updating hash value by using a random character string Si uploaded to the block chain by the ith participant to obtain an ith ciphertext Pi, carrying out hash operation on the ith ciphertext Pi, and replacing the ith-1 updating hash value in the intelligent contract with an operation result obtained by carrying out hash operation on the ith ciphertext Pi to obtain an ith updating hash value; wherein 1< i < m, m being the total number of people participating in the lottery;
and the mth participating unit is used for encrypting the mth-1 update hash value by using the random character string Sm uploaded to the block chain by the mth participant to obtain the mth ciphertext Pm, performing hash operation on the mth ciphertext Pm, and replacing the mth-1 update hash value in the intelligent contract with the operation result obtained by performing hash operation on the mth ciphertext Pm to obtain the mth update hash value.
8. The blockchain-based lottery system of claim 6, wherein the participation module includes:
the splicing encryption unit is used for splicing the random character strings uploaded to the block chain by all participants of the lottery activity, and encrypting the initialized hash value in the intelligent contract by using the spliced random character strings to obtain a ciphertext P;
and the updating unit is used for carrying out Hash operation on the ciphertext P and replacing the initialized Hash value in the intelligent contract with an operation result obtained after the Hash operation is carried out on the ciphertext P to obtain an updated Hash value in the intelligent contract.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1-5 when executing the computer program.
10. A computer-readable medium, in which a computer program is stored which, when being processed and executed, carries out the steps of the method according to any one of claims 1 to 5.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911191570.2A CN111008863B (en) | 2019-11-28 | 2019-11-28 | Lottery drawing method and system based on block chain |
CN202310866168.XA CN116739660A (en) | 2019-11-28 | 2019-11-28 | Lottery drawing method and system based on block chain |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911191570.2A CN111008863B (en) | 2019-11-28 | 2019-11-28 | Lottery drawing method and system based on block chain |
Related Child Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310866168.XA Division CN116739660A (en) | 2019-11-28 | 2019-11-28 | Lottery drawing method and system based on block chain |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111008863A true CN111008863A (en) | 2020-04-14 |
CN111008863B CN111008863B (en) | 2023-09-05 |
Family
ID=70112332
Family Applications (2)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911191570.2A Active CN111008863B (en) | 2019-11-28 | 2019-11-28 | Lottery drawing method and system based on block chain |
CN202310866168.XA Pending CN116739660A (en) | 2019-11-28 | 2019-11-28 | Lottery drawing method and system based on block chain |
Family Applications After (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310866168.XA Pending CN116739660A (en) | 2019-11-28 | 2019-11-28 | Lottery drawing method and system based on block chain |
Country Status (1)
Country | Link |
---|---|
CN (2) | CN111008863B (en) |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111865587A (en) * | 2020-08-07 | 2020-10-30 | 腾讯科技(深圳)有限公司 | Data processing method, block link point device, electronic device, and computer program |
CN111884807A (en) * | 2020-07-13 | 2020-11-03 | 腾讯科技(深圳)有限公司 | Article reservation method, apparatus, device and medium based on block chain |
CN112118107A (en) * | 2020-08-12 | 2020-12-22 | 北京大学 | Self-adaptive execution method for realizing data credibility |
CN112527244A (en) * | 2020-12-18 | 2021-03-19 | 上海万向区块链股份公司 | Distributed lottery system and method based on verifiable delay function |
CN112712632A (en) * | 2020-11-17 | 2021-04-27 | 中科扶云(杭州)科技有限公司 | Random shaking number processing method and device, electronic device and storage medium |
CN113269570A (en) * | 2021-06-11 | 2021-08-17 | 深圳番多拉信息科技有限公司 | Extraction result verification method and related device |
CN113761586A (en) * | 2020-06-28 | 2021-12-07 | 北京同邦卓益科技有限公司 | Method and device for randomly sampling and inspecting articles based on block chain |
CN114726534A (en) * | 2022-03-28 | 2022-07-08 | 海南格子山网络科技有限公司 | Method for realizing intelligent contract drawing based on Solana block chain technology |
CN115206018A (en) * | 2022-06-16 | 2022-10-18 | 湖南天河国云科技有限公司 | Lottery drawing method and lottery drawing equipment based on block chain prediction machine |
CN115953199A (en) * | 2023-03-10 | 2023-04-11 | 青岛网信信息科技有限公司 | Marketing campaign method, medium and system for packing prizes by user |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2018104728A1 (en) * | 2016-12-05 | 2018-06-14 | Quanta Technology Ltd | Random number generation |
CN109360091A (en) * | 2018-08-30 | 2019-02-19 | 阿里巴巴集团控股有限公司 | A kind of arbitrary object choosing method and device based on block chain |
US20190057572A1 (en) * | 2018-10-20 | 2019-02-21 | R. Jay Carpenter | Method of selecting a contest winner |
CN109389399A (en) * | 2018-10-18 | 2019-02-26 | 深圳前海乐寻坊区块链科技有限公司 | Lottery industry method, apparatus, computer equipment and storage medium based on block chain |
CN109767271A (en) * | 2019-01-18 | 2019-05-17 | 众安信息技术服务有限公司 | Lottery drawing method and equipment based on block chain |
CN109847365A (en) * | 2019-01-24 | 2019-06-07 | 湖南天河国云科技有限公司 | A kind of anti-cheating method and system towards the application of block chain |
CN110164021A (en) * | 2019-06-13 | 2019-08-23 | 北京艾摩瑞策科技有限公司 | A kind of random lottery drawing method and equipment of application block chain |
CN110445616A (en) * | 2019-07-15 | 2019-11-12 | 杭州复杂美科技有限公司 | A kind of block is packaged the determining method of packing sequence, equipment and the storage medium of node |
CN110445603A (en) * | 2019-06-28 | 2019-11-12 | 成都鹰翔天际科技有限公司 | A kind of decentralization random digit generation method |
-
2019
- 2019-11-28 CN CN201911191570.2A patent/CN111008863B/en active Active
- 2019-11-28 CN CN202310866168.XA patent/CN116739660A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2018104728A1 (en) * | 2016-12-05 | 2018-06-14 | Quanta Technology Ltd | Random number generation |
CN109360091A (en) * | 2018-08-30 | 2019-02-19 | 阿里巴巴集团控股有限公司 | A kind of arbitrary object choosing method and device based on block chain |
CN109389399A (en) * | 2018-10-18 | 2019-02-26 | 深圳前海乐寻坊区块链科技有限公司 | Lottery industry method, apparatus, computer equipment and storage medium based on block chain |
US20190057572A1 (en) * | 2018-10-20 | 2019-02-21 | R. Jay Carpenter | Method of selecting a contest winner |
CN109767271A (en) * | 2019-01-18 | 2019-05-17 | 众安信息技术服务有限公司 | Lottery drawing method and equipment based on block chain |
CN109847365A (en) * | 2019-01-24 | 2019-06-07 | 湖南天河国云科技有限公司 | A kind of anti-cheating method and system towards the application of block chain |
CN110164021A (en) * | 2019-06-13 | 2019-08-23 | 北京艾摩瑞策科技有限公司 | A kind of random lottery drawing method and equipment of application block chain |
CN110445603A (en) * | 2019-06-28 | 2019-11-12 | 成都鹰翔天际科技有限公司 | A kind of decentralization random digit generation method |
CN110445616A (en) * | 2019-07-15 | 2019-11-12 | 杭州复杂美科技有限公司 | A kind of block is packaged the determining method of packing sequence, equipment and the storage medium of node |
Non-Patent Citations (1)
Title |
---|
斯雪明;徐蜜雪;苑超;: "区块链安全研究综述" * |
Cited By (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113761586A (en) * | 2020-06-28 | 2021-12-07 | 北京同邦卓益科技有限公司 | Method and device for randomly sampling and inspecting articles based on block chain |
CN111884807A (en) * | 2020-07-13 | 2020-11-03 | 腾讯科技(深圳)有限公司 | Article reservation method, apparatus, device and medium based on block chain |
CN111884807B (en) * | 2020-07-13 | 2021-10-26 | 腾讯科技(深圳)有限公司 | Article reservation method, apparatus, device and medium based on block chain |
CN111865587A (en) * | 2020-08-07 | 2020-10-30 | 腾讯科技(深圳)有限公司 | Data processing method, block link point device, electronic device, and computer program |
CN112118107B (en) * | 2020-08-12 | 2021-08-27 | 北京大学 | Self-adaptive execution method for realizing data credibility |
CN112118107A (en) * | 2020-08-12 | 2020-12-22 | 北京大学 | Self-adaptive execution method for realizing data credibility |
CN112712632B (en) * | 2020-11-17 | 2022-03-15 | 中科扶云(杭州)科技有限公司 | Random shaking number processing method and device, electronic device and storage medium |
CN112712632A (en) * | 2020-11-17 | 2021-04-27 | 中科扶云(杭州)科技有限公司 | Random shaking number processing method and device, electronic device and storage medium |
CN112527244A (en) * | 2020-12-18 | 2021-03-19 | 上海万向区块链股份公司 | Distributed lottery system and method based on verifiable delay function |
CN113269570A (en) * | 2021-06-11 | 2021-08-17 | 深圳番多拉信息科技有限公司 | Extraction result verification method and related device |
CN113269570B (en) * | 2021-06-11 | 2024-04-09 | 深圳番多拉信息科技有限公司 | Extraction result verification method and related device |
CN114726534A (en) * | 2022-03-28 | 2022-07-08 | 海南格子山网络科技有限公司 | Method for realizing intelligent contract drawing based on Solana block chain technology |
CN115206018A (en) * | 2022-06-16 | 2022-10-18 | 湖南天河国云科技有限公司 | Lottery drawing method and lottery drawing equipment based on block chain prediction machine |
CN115953199A (en) * | 2023-03-10 | 2023-04-11 | 青岛网信信息科技有限公司 | Marketing campaign method, medium and system for packing prizes by user |
Also Published As
Publication number | Publication date |
---|---|
CN116739660A (en) | 2023-09-12 |
CN111008863B (en) | 2023-09-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111008863B (en) | Lottery drawing method and system based on block chain | |
JP6892513B2 (en) | Off-chain smart contract service based on a reliable execution environment | |
WO2021046668A1 (en) | Blockchain system, information transmission method, system and apparatus, and computer medium | |
CN112765268B (en) | Data privacy protection method, device and equipment based on block chain | |
CN112152794A (en) | Efficient post-quantum anonymous attestation with signature-based join protocol and infinite signatures | |
CN111865587B (en) | Data processing method, block link point device, electronic device, and computer program | |
US20210344500A1 (en) | Computer-implemented system and method for transferring access to digital resource | |
CN108833095B (en) | Behavior verification method, node, system and electronic equipment in block chain | |
CN111950030A (en) | Data sharing storage method based on block chain, terminal equipment and storage medium | |
CN109361508A (en) | Data transmission method, electronic equipment and computer readable storage medium | |
US11676111B1 (en) | Apparatuses and methods for determining and processing dormant user data in a job resume immutable sequential listing | |
CN110224984A (en) | A kind of multi-party authorization method and device based on block chain technology | |
CN113420886B (en) | Training method, device, equipment and storage medium for longitudinal federal learning model | |
JP2022095852A (en) | Digital signature method, signature information verification method, related device, and electronic device | |
CN112734423A (en) | Transaction method based on block chain and terminal equipment | |
CN111935197A (en) | Bidding document encryption and decryption method and device | |
CN114154196A (en) | Heterogeneous data processing method and device and electronic equipment | |
CN111769945B (en) | Auction processing method based on block chain and block chain link point | |
CN110515591B (en) | Random number generation method and device based on block chain | |
CN107395350B (en) | Method and system for generating key and key handle and intelligent key safety equipment | |
CN115860768B (en) | Source tracing method and device based on blockchain and electronic equipment thereof | |
CN118160273A (en) | Generating a shared key | |
CN116384461A (en) | Model optimization training method and device based on joint learning | |
CN112837064A (en) | Signature method, signature verification method and device of alliance chain | |
CN112713992A (en) | Certificate-free anti-leakage authentication and key agreement method and system |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |